Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* enumerates the supported serialization formats for SPARQL SELECT and ASK
* results (CSV, TSV, JSON, XML). Serializer contracts live in
* {@code io.serializer}; reusable option facets live in
* {@code io.serializer.option}.
* The recommended high-level entry point is {@link
* fr.inria.corese.core.next.io.CoreseIO}.</p>
* {@code io.serializer.option}.</p>
*/
package fr.inria.corese.core.next.query.api.io;
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import fr.inria.corese.core.next.query.api.exception.QueryTypeErrorException;

import fr.inria.corese.core.next.data.Values;
import fr.inria.corese.core.next.query.impl.engine.event.ResultListener;
import fr.inria.corese.core.next.query.impl.engine.model.NodeImpl;
import fr.inria.corese.core.next.data.api.model.DatatypeValue;
import org.slf4j.Logger;
Expand Down Expand Up @@ -109,7 +108,6 @@ public Eval(Producer p, Evaluator e, Matcher m) {
evaluator = e;
match = m;
setVisitor(new ProcessVisitorDefault());
e.setKGRAM(this);
graphEvaluator = new EvalGraph(this);
join = new EvalJoin(this);
optional = new EvalOptional(this);
Expand Down Expand Up @@ -724,9 +722,6 @@ int eval(Producer p, Node graphNode, Stack stack, Mappings map, int n) {
state.updateMaxLevel(n);

Exp exp = stack.get(n);
if (visitors.hasListener()) {
exp = visitors.listen(exp, n);
}

// A false filter was detected at compile time, or this expression was
// identified as always failing: no use to evaluate it.
Expand Down Expand Up @@ -973,9 +968,6 @@ private int edge(Producer p, Node graphNode, Exp exp, Mappings data, Stack stack

if (entity != null) {
state.incrementEdge();
if (visitors.hasListener() && !visitors.listen(exp, qEdge, entity)) {
continue;
}

graph = entity.getGraph();
boolean bmatch = match(qEdge, entity, graphNode, graph, env);
Expand Down Expand Up @@ -1045,20 +1037,12 @@ Mappings selectQueryMappings(Mappings data) {
* Store a new result
*/
private int store(Producer p, Mapping m) {
boolean store = true;
if (getListener() != null) {
store = getListener().process(getMemory());
}
if (store) {
state.incrementResult();
}
if (store) {
Mapping ans = m;
if (m == null) {
ans = getMemory().store(getQuery(), p, isSubEval);
}
store(ans);
state.incrementResult();
Mapping ans = m;
if (m == null) {
ans = getMemory().store(getQuery(), p, isSubEval);
}
store(ans);
return -1;
}

Expand Down Expand Up @@ -1149,14 +1133,6 @@ public boolean isJoinMappings() {
return joinMappings;
}

public ResultListener getListener() {
return visitors.getListener();
}

public void setListener(ResultListener listener) {
visitors.setListener(listener);
}

public EvaluationState getState() {
return state;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ Mappings eval(Filter f, Environment env, Producer p, List<Node> nodes) {
int n = 1;
Expr exp = f.getExp();
if (exp.oper() == UNNEST) {
if (engine.getVisitorDispatcher().hasListener()) {
engine.getVisitorDispatcher().listen(exp);
}
if (exp.arity() == 2) {
DatatypeValue dt = eval(exp.getExp(1), env, p);
if (dt == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
package fr.inria.corese.core.next.query.impl.engine.eval;

import fr.inria.corese.core.next.data.api.model.DatatypeValue;
import fr.inria.corese.core.next.query.impl.engine.event.ProcessVisitor;
import fr.inria.corese.core.next.query.impl.engine.event.ProcessVisitorDefault;
import fr.inria.corese.core.next.query.impl.engine.event.ResultListener;
import fr.inria.corese.core.next.query.impl.engine.model.Edge;
import fr.inria.corese.core.next.query.impl.engine.model.Expr;
import fr.inria.corese.core.next.query.impl.engine.model.Node;
import fr.inria.corese.core.next.query.impl.engine.pattern.Exp;

import java.util.Objects;

/**
* Coordinates and dispatches execution lifecycle visitors and result listeners
* for SPARQL evaluation in {@link Eval}.
* Coordinates and dispatches execution lifecycle visitors for SPARQL evaluation in {@link Eval}.
*
* <p>Encapsulates the active {@link ProcessVisitor} (for query observation and reporting)
* and the optional {@link ResultListener} (for inference rule execution).</p>
* <p>Encapsulates the active {@link ProcessVisitor} for query observation and reporting.</p>
*/
public final class EvalVisitorDispatcher {

private ResultListener listener;
private ProcessVisitor visitor;

private boolean hasListener = false;
private boolean hasStatement = false;
private boolean hasCandidate = false;
private boolean hasFilter = false;
Expand All @@ -44,15 +34,9 @@ public void setVisitor(ProcessVisitor visitor) {
}

public void updateVisitorFlags() {
if (visitor != null) {
this.hasStatement = visitor.statement();
this.hasCandidate = visitor.candidate();
this.hasFilter = visitor.filter();
} else {
this.hasStatement = false;
this.hasCandidate = false;
this.hasFilter = false;
}
this.hasStatement = visitor.statement();
this.hasCandidate = visitor.candidate();
this.hasFilter = visitor.filter();
}

public boolean hasStatement() {
Expand All @@ -66,39 +50,4 @@ public boolean hasCandidate() {
public boolean hasFilter() {
return hasFilter;
}

// --- Listener ---

public ResultListener getListener() {
return listener;
}

public void setListener(ResultListener listener) {
this.listener = listener;
this.hasListener = (listener != null);
}

public boolean hasListener() {
return hasListener;
}

public Exp listen(Exp exp, int n) {
if (hasListener) {
return listener.listen(exp, n);
}
return exp;
}

public void listen(Expr exp) {
if (hasListener) {
listener.listen(exp);
}
}

public boolean listen(Exp exp, Edge qEdge, Edge entity) {
if (hasListener) {
return listener.listen(exp, qEdge, entity);
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,9 @@
public final class SparqlKgramEvaluator implements Evaluator {

private final OffsetDateTime queryEvaluationTime = OffsetDateTime.now(ZoneOffset.UTC);
private Mode mode = Mode.KGRAM_MODE;

@Override
public OffsetDateTime getQueryEvaluationTime() {
return queryEvaluationTime;
}

@Override
public Mode getMode() {
return mode;
}

@Override
public void setMode(Mode mode) {
this.mode = mode;
}
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,7 @@
package fr.inria.corese.core.next.query.impl.engine.event;

import fr.inria.corese.core.next.query.impl.engine.eval.Eval;
import fr.inria.corese.core.next.query.impl.engine.model.Node;
import fr.inria.corese.core.next.query.impl.engine.pattern.Exp;
import fr.inria.corese.core.next.query.impl.engine.solution.Mappings;

/**
* Default process visitor that forwards reporting events to the query binding context
* when query report is enabled.
* Default process visitor providing no-op implementations of execution lifecycle events.
*/
public final class ProcessVisitorDefault implements ProcessVisitor {

void visit(Eval eval, Node g, Exp e, Mappings m1, Mappings m2) {
if (eval.getQuery().isReportEnabled()) {
eval.getBind().visit(e, g, m1, m2);
}
}

@Override
public void graph(Eval eval, Node g, Exp e, Mappings m1) {
visit(eval, g, e, m1, null);
}

@Override
public void query(Eval eval, Node g, Exp e, Mappings m1) {
visit(eval, g, e, m1, null);
}

@Override
public void service(Eval eval, Node g, Exp e, Mappings m1) {
visit(eval, g, e, m1, null);
}

@Override
public void optional(Eval eval, Node g, Exp e, Mappings m1, Mappings m2) {
visit(eval, g, e, m1, m2);
}

@Override
public void minus(Eval eval, Node g, Exp e, Mappings m1, Mappings m2) {
visit(eval, g, e, m1, m2);
}

@Override
public void union(Eval eval, Node g, Exp e, Mappings m1, Mappings m2) {
visit(eval, g, e, m1, m2);
}

@Override
public void join(Eval eval, Node g, Exp e, Mappings m1, Mappings m2) {
visit(eval, g, e, m1, m2);
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,4 @@ default ProcessVisitor getVisitor() {
default void setVisitor(ProcessVisitor visitor) {
// By default, do nothing
}

/**
* Visit method for reporting.
* Used by ProcessVisitorDefault.
*
* @param e the expression
* @param g the graph node
* @param m1 the mappings 1
* @param m2 the mappings 2
*/
default void visit(Object e, Object g, Object m1, Object m2) {
// By default, do nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ default boolean isMatchArity() {
return false;
}

// nested rdf star triple <<s p o>>
default boolean isNested() {
return false;
}
default void setNested(boolean b) {
// RDF-star nesting is an optional capability of concrete edge implementations.
}

default DatatypeValue getGraphValue() {
Node node = getGraph();
if (node == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package fr.inria.corese.core.next.query.impl.engine.model;

/**
* Types of expression of KGRAM query language
*
* @author Olivier Corby, Edelweiss, INRIA 2010
* Expression types for SPARQL query algebra in KGRAM engine.
*/
public interface ExpType {

Expand All @@ -17,31 +15,21 @@ enum Type {
FILTER("FILTER"),
NODE("NODE"),
BGP("BGP"),
WATCH("WATCH"),
CONTINUE("CONTINUE"),
BACKJUMP("BACKJUMP"),
QUERY("QUERY"),
FORALL("FORALL"),
EXIST("EXIST"),
GRAPHNODE("GRAPHNODE"),
OPTIONAL("OPTIONAL"),
SCAN("SCAN"),
IF("IF"),
XPATH("XPATH"),
ACCEPT("ACCEPT"),
BIND("BIND"),
EVAL("EVAL"),
SCOPE("SCOPE"),
TEST("TEST"),
NEXT("NEXT"),
MINUS("MINUS"),
POP("POP"),
SERVICE("SERVICE"),
RESTORE("RESTORE"),
JOIN("JOIN"),
VALUES("VALUES"),
OPT_BIND("OPT_BIND");

private final String title;

Type(String title) {
this.title = title;
}
Expand Down
Loading
Loading