private void binaryOpMeet(TupleExpr theCurrentExpr, TupleExpr theLeftExpr, TupleExpr theRightExpr) throws Exception { theLeftExpr.visit(this); Var aLeftCtx = mContexts.get(theLeftExpr); theRightExpr.visit(this); Var aRightCtx = mContexts.get(theRightExpr); sameCtxCheck(theCurrentExpr, theLeftExpr, aLeftCtx, theRightExpr, aRightCtx); }
/** * Applies generally applicable optimizations to the supplied query: variable assignments are inlined. */ public void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings) { tupleExpr.visit(new CompareVisitor()); }
@Override public void meet(Projection node) { projection = node; node.getArg().visit(this); projection = null; }
/** * Applies generally applicable optimizations: path expressions are sorted from more to less specific. * * @param tupleExpr */ @Override public void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings) { tupleExpr.visit(new JoinVisitor()); }
@Override public void meet(Order node) throws RDFHandlerException { // skip over OrderElem - leave this to the OrderVisitor later node.getArg().visit(this); }
@Override public void meet(Extension node) throws RDFHandlerException { node.getArg().visit(this); }
static Map<TupleExpr, Var> collectContexts(TupleExpr theTupleExpr) throws Exception { ContextCollector aContextVisitor = new ContextCollector(); theTupleExpr.visit(aContextVisitor); return aContextVisitor.mContexts; }
/** * Applies generally applicable optimizations: path expressions are sorted from more to less specific. * * @param tupleExpr */ public void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings) { tupleExpr.visit(new TreeSanitizer()); }
@Override public void meet(Filter filter) { // Filters are commutative filter.getArg().visit(this); }
@Override public void meet(Reduced node) throws RDFHandlerException { if (!isSubQuery) { // ignore root reduced node.getArg().visit(this); } else { super.meet(node); } }
private TupleExpr replaceVarOccurrence(TupleExpr te, List<ValueExpr> objectList, Var replacementVar) throws VisitorException { for (ValueExpr objExpr : objectList) { Var objVar = mapValueExprToVar(objExpr); VarReplacer replacer = new VarReplacer(objVar, replacementVar); te.visit(replacer); } return te; }
private TupleExpr replaceVarOccurrence(TupleExpr te, List<ValueExpr> objectList, Var replacementVar) throws VisitorException { for (ValueExpr objExpr : objectList) { Var objVar = mapValueExprToVar(objExpr); VarReplacer replacer = new VarReplacer(objVar, replacementVar); te.visit(replacer); } return te; }
@Override public void meet(Extension node) { if (node.getArg().getBindingNames().containsAll(filterVars)) { node.getArg().visit(this); } else { relocate(filter, node); } }
private void bindVar(Var var, Value value, Filter filter) { // Set the value on all occurences of the variable filter.getArg().visit(new VarBinder(var.getName(), value)); } }
@Override public void meet(Extension node) { if (node.getArg().getBindingNames().containsAll(filterVars)) { node.getArg().visit(this); } else { relocate(filter, node); } }
private void visitWhere(TupleExpr where) throws RDFHandlerException { Resource whereBNode = valueFactory.createBNode(); handler.handleStatement(valueFactory.createStatement(subject, SP.WHERE_PROPERTY, whereBNode)); isSubQuery = true; // further projection elements are for // sub-queries ListContext ctx = newList(whereBNode); where.visit(this); endList(ctx); }
public TupleExpr buildConstructor(TupleExpr bodyExpr, boolean distinct, boolean reduced) throws MalformedQueryException { // check that bodyExpr contains _only_ a basic graph pattern. BasicPatternVerifier verifier = new BasicPatternVerifier(); bodyExpr.visit(verifier); if (!verifier.isBasicPattern()) { throw new MalformedQueryException( "can not use shorthand CONSTRUCT: graph pattern in WHERE clause is not a basic pattern."); } return buildConstructor(bodyExpr, bodyExpr, false, distinct, reduced); }
public TupleExpr buildConstructor(TupleExpr bodyExpr, boolean distinct, boolean reduced) throws MalformedQueryException { // check that bodyExpr contains _only_ a basic graph pattern. BasicPatternVerifier verifier = new BasicPatternVerifier(); bodyExpr.visit(verifier); if (!verifier.isBasicPattern()) { throw new MalformedQueryException( "can not use shorthand CONSTRUCT: graph pattern in WHERE clause is not a basic pattern."); } return buildConstructor(bodyExpr, bodyExpr, false, distinct, reduced); }