public TupleExpr getTupleExpr() { return _tupleExpr.clone(); }
@Override public Modify clone() { TupleExpr deleteClone = deleteExpr != null ? deleteExpr.clone() : null; TupleExpr insertClone = insertExpr != null ? insertExpr.clone() : null; TupleExpr whereClone = whereExpr != null ? whereExpr.clone() : null; return new Modify(deleteClone, insertClone, whereClone); }
private static List<TupleExpr> getPlans(List<Map<Join, List<TupleExpr>>> reOrderings, TupleExpr te) { List<TupleExpr> queryPlans = Lists.newArrayList(); PermInserter pm = new PermInserter(); for (Map<Join, List<TupleExpr>> order : reOrderings) { TupleExpr clone = te.clone(); pm.setReOrderMap(order); clone.visit(pm); queryPlans.add(clone); } return queryPlans; }
public static TupleExpr rewriteGraph(final TupleExpr expr, final Var graphVar) { if (expr == null) { return null; } final TupleExpr result = expr.clone(); result.setParentNode(null); result.visit(new QueryModelVisitorBase<RuntimeException>() { @Override public void meet(final StatementPattern pattern) throws RuntimeException { pattern.setContextVar(graphVar); } }); return result; }
@Override public UnaryTupleOperator clone() { UnaryTupleOperator clone = (UnaryTupleOperator)super.clone(); clone.setArg(getArg().clone()); return clone; } }
@Override public SubQueryValueOperator clone() { SubQueryValueOperator clone = (SubQueryValueOperator)super.clone(); clone.setSubQuery(getSubQuery().clone()); return clone; } }
@Override public PeriodicQueryNode clone() { PeriodicQueryNode clone = (PeriodicQueryNode)super.clone(); clone.setArg(getArg().clone()); clone.periodDuration = periodDuration; clone.windowDuration = windowDuration; clone.unit = unit; clone.temporalVar = temporalVar; return clone; }
private void meetOwnedTupleExpr(OwnedTupleExpr node) { if (owned == null) { owned = node; super.meetOther(node); owned = null; } else { // no nested OwnedTupleExpr TupleExpr replacement = node.getArg().clone(); node.replaceWith(replacement); replacement.visit(this); } }
private void addDistinctOwnersNonLocal(LeftJoin node, RepositoryConnection leftOwner, RepositoryConnection rightOwner) { if (leftOwner != null) { node.getLeftArg().replaceWith(new OwnedTupleExpr(leftOwner, node.getLeftArg().clone())); } if (rightOwner != null) { node.getRightArg().replaceWith(new OwnedTupleExpr(rightOwner, node.getRightArg().clone())); } }
private void meetOwnedTupleExpr(OwnedTupleExpr node) { if (owned == null) { owned = node; super.meetOther(node); owned = null; // NOPMD } else { // no nested OwnedTupleExpr TupleExpr replacement = node.getArg().clone(); node.replaceWith(replacement); replacement.visit(this); } }
@Override public void meet(Slice node) throws RuntimeException { TupleExpr child = node.getArg(); if(!isSupported(child) && child instanceof UnaryTupleOperator) { UnaryTupleOperator replacement = (UnaryTupleOperator)child.clone(); // switch positions of child and node node.replaceWith(replacement); node.setArg(((UnaryTupleOperator) child).getArg().clone()); replacement.setArg(node.clone()); // visit the newly inserted replacement node (i.e. the clone of child now containing the old "node" as // child, so "node" can be bubbled down further if needed) replacement.visit(this); } }
@Override public void meet(Distinct node) throws RuntimeException { TupleExpr child = node.getArg(); if(!isSupported(child) && child instanceof UnaryTupleOperator) { UnaryTupleOperator replacement = (UnaryTupleOperator)child.clone(); // switch positions of child and node node.replaceWith(replacement); node.setArg(((UnaryTupleOperator) child).getArg().clone()); replacement.setArg(node.clone()); // visit the newly inserted replacement node (i.e. the clone of child now containing the old "node" as // child, so "node" can be bubbled down further if needed) replacement.visit(this); } }
@Override public void meet(Reduced node) throws RuntimeException { TupleExpr child = node.getArg(); if(!isSupported(child) && child instanceof UnaryTupleOperator) { UnaryTupleOperator replacement = (UnaryTupleOperator)child.clone(); // switch positions of child and node node.replaceWith(replacement); node.setArg(((UnaryTupleOperator) child).getArg().clone()); replacement.setArg(node.clone()); // visit the newly inserted replacement node (i.e. the clone of child now containing the old "node" as // child, so "node" can be bubbled down further if needed) replacement.visit(this); } }
@Override public CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluate(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings, boolean includeInferred) throws SailException { // Don't modify the original tuple expression tupleExpr = tupleExpr.clone(); // Inline any externally set bindings, lucene statement patterns can also // use externally bound variables new BindingAssigner().optimize(tupleExpr, dataset, bindings); List<SearchQueryEvaluator> queries = new ArrayList<SearchQueryEvaluator>(); for(SearchQueryInterpreter interpreter : sail.getSearchQueryInterpreters()) { interpreter.process(tupleExpr, bindings, queries); } // evaluate lucene queries if (!queries.isEmpty()) { evaluateLuceneQueries(queries, tupleExpr); } // let the lower sail evaluate the remaining query return super.evaluate(tupleExpr, dataset, bindings, includeInferred); }
private void meetNodeLocalParentNotOwned(StringBuilder builder, boolean mapping, Map<String, String> bindings, ProjectionElemList list) throws RepositoryException, MalformedQueryException { OwnedTupleExpr owned = new OwnedTupleExpr(owner.getOwner(), patternNode.clone()); owned.prepare(QueryLanguage.SPARQL, builder.toString(), bindings); if (mapping) { Projection proj = new Projection(owned, list); patternNode.replaceWith(proj); } else { patternNode.replaceWith(owned); } }
public void visitDeleteWhere(Resource query) throws OpenRDFException { SingletonSet stub = new SingletonSet(); tupleRoot = new QueryRoot(stub); tupleNode = stub; visitWhere(query); tupleNode.setParentNode(null); updateRoot = new Modify(tupleNode, null, tupleNode.clone()); }
public TupleExpr optimize(TupleExpr expr, Dataset dataset, BindingSet bindings, EvaluationStrategy strategy) { // Clone the tuple expression to allow for more aggressive optimisations TupleExpr tupleExpr = expr.clone(); if (!(tupleExpr instanceof QueryRoot)) { // Add a dummy root node to the tuple expressions to allow the // optimisers to modify the actual root node tupleExpr = new QueryRoot(tupleExpr); } coreOptimizations(strategy, tupleExpr, dataset, bindings); rdbmsOptimizations(tupleExpr, dataset, bindings); new SqlConstantOptimizer().optimize(tupleExpr, dataset, bindings); return tupleExpr; }
@Override public ArbitraryLengthPath clone() { ArbitraryLengthPath clone = (ArbitraryLengthPath)super.clone(); clone.setSubjectVar(getSubjectVar().clone()); clone.setPathExpression(getPathExpression().clone()); clone.setObjectVar(getObjectVar().clone()); if (getContextVar() != null) { clone.setContextVar(getContextVar().clone()); } return clone; } }
@Override public void meet(Order node) { for (OrderElem e : node.getElements()) { e.visit(this); } if (variablesProjected) { QueryModelNode parent = node.getParentNode(); if (projection == parent) { node.replaceWith(node.getArg().clone()); node.setArg(projection.clone()); Order replacement = node.clone(); projection.replaceWith(replacement); QueryModelNode distinct = replacement.getParentNode(); if (distinct instanceof Distinct) { distinct.replaceWith(new Reduced(replacement.clone())); } } } }