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 @@ -2,7 +2,7 @@

import fr.inria.corese.core.next.query.impl.engine.model.Edge;
import fr.inria.corese.core.next.query.impl.engine.model.Node;
import fr.inria.corese.core.next.query.impl.engine.pattern.Query;
import fr.inria.corese.core.next.query.impl.engine.pattern.QueryPlan;
import fr.inria.corese.core.next.query.impl.engine.spi.Environment;
import fr.inria.corese.core.next.query.impl.engine.storage.StorageManagerProducer;
import fr.inria.corese.core.next.storage.api.StorageManager;
Expand Down Expand Up @@ -32,7 +32,7 @@ public DiagnosticProducer(StorageManager storage, ExecutionDiagnostics diagnosti
}

@Override
public long estimateCardinality(Query query, Node graphNode, Edge edge) {
public long estimateCardinality(QueryPlan query, Node graphNode, Edge edge) {
long count = super.estimateCardinality(query, graphNode, edge);
diagnostics.estimated(edge, count);
return count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import fr.inria.corese.core.next.query.impl.engine.model.Node;
import fr.inria.corese.core.next.query.impl.engine.path.PropertyPathEdge;
import fr.inria.corese.core.next.query.impl.engine.pattern.Exp;
import fr.inria.corese.core.next.query.impl.engine.pattern.Query;
import fr.inria.corese.core.next.query.impl.engine.pattern.QueryPlan;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -120,7 +120,7 @@ public void compilationTime(long nanos) {
* @param query completed runtime query
* @param nanos elapsed completion nanoseconds
*/
public void planned(Query query, long nanos) {
public void planned(QueryPlan query, long nanos) {
planningNanos += nanos;
visit(query, "query", null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.inria.corese.core.next.query.impl.engine.eval;

import fr.inria.corese.core.next.query.impl.engine.pattern.Exp;
import fr.inria.corese.core.next.query.impl.engine.pattern.Query;
import fr.inria.corese.core.next.query.impl.engine.pattern.QueryPlan;
import fr.inria.corese.core.next.query.impl.engine.solution.Mapping;
import fr.inria.corese.core.next.query.impl.engine.solution.Mappings;

Expand All @@ -18,7 +18,7 @@

public class EnvironmentImpl implements Environment {
protected static final String NOT_SUPPORTED_YET = "Not supported yet.";
protected Query query;
protected QueryPlan query;

public EnvironmentImpl(){
// The base environment starts without a query or bindings.
Expand Down Expand Up @@ -72,7 +72,7 @@ public int pathLength(Node node) {


@Override
public Query getQuery() {
public QueryPlan getQuery() {
return query;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import fr.inria.corese.core.next.query.impl.engine.model.Loopable;
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.pattern.Query;
import fr.inria.corese.core.next.query.impl.engine.pattern.QueryPlan;
import fr.inria.corese.core.next.query.impl.engine.solution.Mapping;
import fr.inria.corese.core.next.query.impl.engine.solution.MappingSet;
import fr.inria.corese.core.next.query.impl.engine.solution.Mappings;
Expand Down Expand Up @@ -73,7 +73,7 @@ public final class Eval implements ExpType {
Matcher match;
// Stacks for binding edges and nodes
Memory memory;
Query query;
QueryPlan query;

Mappings results;
// initial results to be completed
Expand Down Expand Up @@ -163,15 +163,15 @@ public void set(Evaluator e) {
/**
* Main eval function
*/
public Mappings query(Query q) {
public Mappings query(QueryPlan q) {
return query(null, q, null);
}

public Mappings query(Node graphNode, Query q, Mapping m) {
public Mappings query(Node graphNode, QueryPlan q, Mapping m) {
return queryBasic(graphNode, q, m);
}

Mappings queryBasic(Node graphNode, Query q, Mapping m) {
Mappings queryBasic(Node graphNode, QueryPlan q, Mapping m) {
initMemory(q);
share(m);
getProducer().start(q);
Expand Down Expand Up @@ -217,7 +217,7 @@ void share(ProcessVisitor vis) {
* use case: optional(A, B) map = relevant subset of results of A
* for main query and subquery
*/
Mappings eval(Node gNode, Query q, Mapping m, Mappings map) {
Mappings eval(Node gNode, QueryPlan q, Mapping m, Mappings map) {
init(q);
if (q.isValidate()) {
// just compile and complete query
Expand All @@ -241,8 +241,8 @@ Mappings eval(Node gNode, Query q, Mapping m, Mappings map) {
* Mappings map is results or previous statement, possibly null
* use case: optional(A, B) map = relevant subset of results of A
*/
@SuppressWarnings("java:S1845") // Query execution method named query by convention
void query(Node gNode, Query q, Mapping m, Mappings map) {
@SuppressWarnings("java:S1845") // QueryPlan execution method named query by convention
void query(Node gNode, QueryPlan q, Mapping m, Mappings map) {
if (m != null) {
// bind mapping variables into memory
bind(m);
Expand All @@ -261,7 +261,7 @@ void query(Node gNode, Query q, Mapping m, Mappings map) {
/**
* Bind external values one by one in memory and eval one by one
*/
void queryWithValues(Node gNode, Query q, Mappings map) {
void queryWithValues(Node gNode, QueryPlan q, Mappings map) {
Exp values = q.getValues();

if (!values.isPostpone()) {
Expand All @@ -279,7 +279,7 @@ void queryWithValues(Node gNode, Query q, Mappings map) {
eval(gNode, q, map);
}

void eval(Node gNode, Query q, Mappings map) {
void eval(Node gNode, QueryPlan q, Mappings map) {
evalExp(gNode, q.getBody(), map);
}
void evalExp(Node gNode, Exp exp, Mappings map) {
Expand All @@ -298,7 +298,7 @@ public void setMappings(Mappings lMap) {
* for optional, minus, union, join, graph
* not for subquery which has its own processing
*/
Mappings subEval(Query q, Node gNode, Stack stack, Mappings map, int n) {
Mappings subEval(QueryPlan q, Node gNode, Stack stack, Mappings map, int n) {
setSubEval(true);
starter(q);
eval(getProducer(), gNode, stack, map, n);
Expand Down Expand Up @@ -488,7 +488,7 @@ Eval copy(Memory m, Producer p, Evaluator e, boolean extern) {
* copy memory for sub query copy sub query select variables that are
* already bound in current memory Use case: subquery and exists
*/
private Memory copyMemory(Memory memory, Query query, Query sub, Exp exp) {
private Memory copyMemory(Memory memory, QueryPlan query, QueryPlan sub, Exp exp) {
Memory mem = new Memory(match, evaluator);
getEvaluator().init(mem);
if (sub == null) {
Expand Down Expand Up @@ -521,7 +521,7 @@ public BindingContext getBind() {
return getEnvironment().getBind();
}

public Query getQuery() {
public QueryPlan getQuery() {
return query;
}

Expand Down Expand Up @@ -558,16 +558,16 @@ public Mappings getResults() {
}

// total init (for global query)
public void init(Query q) {
public void init(QueryPlan q) {
initMemory(q);
start(q);
}

void initMemory(Query q) {
void initMemory(QueryPlan q) {
if (memory == null) {
// when subquery, memory is already assigned
// assign stack index to EDGE and NODE
q.complete(getProducer());//service while1 / Query
q.complete(getProducer());//service while1 / QueryPlan
memory = new Memory(match, evaluator);
memory.setEval(this);
getEvaluator().init(memory);
Expand All @@ -579,10 +579,10 @@ void initMemory(Query q) {
}

// partial init (for global query and subqueries)
public void start(Query q) {
public void start(QueryPlan q) {
state.setLimit(q.getLimitOffset());
// ASK only needs its first solution after OFFSET. Keep the requested
// Query modifiers intact, and evaluate fully when sorting/grouping needs it.
// QueryPlan modifiers intact, and evaluate fully when sorting/grouping needs it.
if (q.isAsk() && !q.isOrderBy() && !q.hasGroupBy() && !q.isAggregate()) {
state.setLimit((int) Math.min(state.getLimit(), (long) q.getOffset() + 1));
}
Expand All @@ -598,7 +598,7 @@ public int getLimit() {
}

// for sub exp
private void starter(Query q) {
private void starter(QueryPlan q) {
query = q;
// create result holder
if (initialResults != null) {
Expand Down Expand Up @@ -1018,7 +1018,7 @@ private int processServiceMappings(Producer p, Node graphNode, Stack stack, int

// process additional variable provided by service
// such as ?_server_0 in federated mode
void complete(Query q, Mapping map, boolean addNode) {
void complete(QueryPlan q, Mapping map, boolean addNode) {
int i = 0;
for (Node node : map.getQueryNodes()) {
Node out = q.getOuterNode(node);
Expand Down Expand Up @@ -1291,7 +1291,7 @@ private int edge(Producer p, Node graphNode, Exp exp, Mappings data, Stack stack
Memory env = getMemory();
// used by RuleEngine ResultWatcher ProducerImpl
env.setExp(exp);
Query qq = getQuery();
QueryPlan qq = getQuery();
// for default graph triple pattern, consider select from if any
// for named graph triple pattern, from named is useless here because graphNode = URI of one named graph
List<Node> graphNodeList = qq.getFrom(graphNode);
Expand Down Expand Up @@ -1395,7 +1395,7 @@ private int edge(Producer p, Node graphNode, Exp exp, Mappings data, Stack stack
*/
private int query(Producer p, Node graphNode, Exp exp, Mappings data, Stack stack, int n) {
int backtrack = n - 1;
Query subQuery = exp.getQuery();
QueryPlan subQuery = exp.getQuery();
Memory env = getMemory();
getVisitor().start(subQuery);

Expand Down Expand Up @@ -1448,11 +1448,11 @@ Mappings selectQueryMappings(Mappings data) {
* res is a result of sub query bind the select nodes of sub query into
* current memory retrieve outer node that correspond to sub node
*/
private boolean push(Query subQuery, Mapping res, int n) {
private boolean push(QueryPlan subQuery, Mapping res, int n) {
int k = 0;
Memory env = memory;
Matcher mm = match;
Query qq = query;
QueryPlan qq = query;

for (Exp exp : subQuery.getSelectFun()) {
Node subNode = exp.getNode();
Expand Down Expand Up @@ -1487,9 +1487,9 @@ private boolean push(Query subQuery, Mapping res, int n) {
/**
* pop select nodes of sub query
*/
private void pop(Query subQuery, Mapping ans) {
private void pop(QueryPlan subQuery, Mapping ans) {
Memory env = memory;
Query qq = query;
QueryPlan qq = query;

for (Node subNode : subQuery.getSelect()) {
if (ans.isBound(subNode)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.inria.corese.core.next.query.impl.engine.eval;

import fr.inria.corese.core.next.query.impl.engine.pattern.Exp;
import fr.inria.corese.core.next.query.impl.engine.pattern.Query;
import fr.inria.corese.core.next.query.impl.engine.pattern.QueryPlan;
import fr.inria.corese.core.next.query.impl.engine.solution.Mapping;
import fr.inria.corese.core.next.query.impl.engine.solution.Mappings;
import fr.inria.corese.core.next.query.impl.engine.solution.Memory;
Expand Down Expand Up @@ -105,7 +105,7 @@ private boolean isNamedGraph(Producer producer, Node graphNode, Node graph) {
*/
private Mappings graphNodes(Producer p, Exp exp, Mappings map) {
Memory env = engine.getMemory();
Query qq = engine.getQuery();
QueryPlan qq = engine.getQuery();
Matcher mm = engine.getMatcher();
Node name = exp.getGraphName();
Mappings res = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.inria.corese.core.next.query.impl.engine.eval;

import fr.inria.corese.core.next.query.impl.engine.pattern.Exp;
import fr.inria.corese.core.next.query.impl.engine.pattern.Query;
import fr.inria.corese.core.next.query.impl.engine.pattern.QueryPlan;
import fr.inria.corese.core.next.query.impl.engine.solution.Mapping;
import fr.inria.corese.core.next.query.impl.engine.solution.MappingSet;
import fr.inria.corese.core.next.query.impl.engine.solution.Mappings;
Expand Down Expand Up @@ -34,7 +34,7 @@ void setStop() {
stop = true;
}

Query getQuery() {
QueryPlan getQuery() {
return engine.getMemory().getQuery();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.inria.corese.core.next.query.impl.engine.eval;

import fr.inria.corese.core.next.query.impl.engine.pattern.Exp;
import fr.inria.corese.core.next.query.impl.engine.pattern.Query;
import fr.inria.corese.core.next.query.impl.engine.pattern.QueryPlan;
import fr.inria.corese.core.next.query.impl.engine.solution.Mapping;
import fr.inria.corese.core.next.query.impl.engine.solution.MappingSet;
import fr.inria.corese.core.next.query.impl.engine.solution.Mappings;
Expand Down Expand Up @@ -192,7 +192,7 @@ boolean filter(Environment memory, Producer p, Node gNode, Mapping map, Exp exp)
return true;
}

Query getQuery() {
QueryPlan getQuery() {
return engine.getMemory().getQuery();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import fr.inria.corese.core.next.query.impl.engine.model.ExpType.Type;
import fr.inria.corese.core.next.query.impl.engine.path.PropertyPathEdge;
import fr.inria.corese.core.next.query.impl.engine.pattern.Exp;
import fr.inria.corese.core.next.query.impl.engine.pattern.Query;
import fr.inria.corese.core.next.query.impl.engine.pattern.QueryPlan;
import fr.inria.corese.core.next.query.impl.engine.solution.Mapping;
import fr.inria.corese.core.next.query.impl.engine.solution.Memory;
import fr.inria.corese.core.next.query.impl.engine.spi.Producer;
Expand All @@ -35,7 +35,7 @@ public final class SelectCursor implements Iterator<Mapping>, AutoCloseable {
private final Node scopeGraph;
private final boolean nested;
private final boolean applySlice;
private final Query query;
private final QueryPlan query;
private final Memory memory;
private final Producer producer;
private final List<Exp> instructions = new ArrayList<>();
Expand All @@ -55,7 +55,7 @@ public final class SelectCursor implements Iterator<Mapping>, AutoCloseable {
* @param query completed execution query
* @return first materialization guard, or NONE for eligible algebra
*/
public static FallbackReason fallbackReason(Query query) {
public static FallbackReason fallbackReason(QueryPlan query) {
if (!query.isSelect()) return FallbackReason.QUERY_FORM;
if (query.isOrderBy()) return FallbackReason.ORDER_BY;
return operatorFallbackReason(query);
Expand All @@ -68,13 +68,13 @@ public static FallbackReason fallbackReason(Query query) {
* @param query completed execution query
* @return whether ORDER BY has a finite, representable LIMIT plus OFFSET and eligible input
*/
public static boolean supportsOrderedInput(Query query) {
public static boolean supportsOrderedInput(QueryPlan query) {
return query.isSelect() && query.isOrderBy() && query.getLimit() < Integer.MAX_VALUE
&& (long) query.getLimit() + query.getOffset() <= Integer.MAX_VALUE
&& operatorFallbackReason(query) == FallbackReason.NONE;
}

private static FallbackReason operatorFallbackReason(Query query) {
private static FallbackReason operatorFallbackReason(QueryPlan query) {
if (query.hasGroupBy() || query.isAggregate() || query.getHaving() != null) return FallbackReason.AGGREGATION;
return fallbackReason(query.getBody(), query.getValues() != null && !singleton(query.getValues()));
}
Expand Down Expand Up @@ -161,7 +161,7 @@ private static boolean tripleJoin(Exp exp) {
* @param query completed eligible SELECT
* @param bindings initial parameter bindings, or null
*/
public SelectCursor(Eval eval, Query query, Mapping bindings) {
public SelectCursor(Eval eval, QueryPlan query, Mapping bindings) {
this(null, eval, query, bindings, query.getBody(), null, true);
}

Expand All @@ -171,15 +171,15 @@ public SelectCursor(Eval eval, Query query, Mapping bindings) {
* The caller owns both this cursor and its producer's stable read view.
*
* @param eval fresh evaluator owned by this execution
* @param query completed query accepted by {@link #supportsOrderedInput(Query)}
* @param query completed query accepted by {@link #supportsOrderedInput(QueryPlan)}
* @param bindings initial parameter bindings, or null
* @return unsliced input cursor
*/
public static SelectCursor orderedInput(Eval eval, Query query, Mapping bindings) {
public static SelectCursor orderedInput(Eval eval, QueryPlan query, Mapping bindings) {
return new SelectCursor(null, eval, query, bindings, query.getBody(), null, false);
}

private SelectCursor(SelectCursor parent, Eval eval, Query query, Mapping bindings, Exp body, Node graph,
private SelectCursor(SelectCursor parent, Eval eval, QueryPlan query, Mapping bindings, Exp body, Node graph,
boolean applySlice) {
this.eval = eval;
this.query = query;
Expand Down Expand Up @@ -243,7 +243,7 @@ public boolean hasNext() {
}

private static void checkInterrupted() {
if (Thread.currentThread().isInterrupted()) throw new QueryEvaluationException("Query interrupted");
if (Thread.currentThread().isInterrupted()) throw new QueryEvaluationException("QueryPlan interrupted");
}

private boolean selectRow() {
Expand Down
Loading
Loading