public static void addVarNodes(Collection<Var> acc, Collection<Node> nodes) { if ( nodes == null ) return ; for ( Node n : nodes ) addVar(acc, n) ; }
public static void addVars(Collection<Var> acc, Node graphNode, BasicPattern triples) { addVar(acc, graphNode) ; addVars(acc, triples) ; }
public static void addVars(Collection<Var> acc, PropFuncArg arg) { if ( arg.isNode() ) addVar(acc, arg.getArg()); else addVarNodes(acc, arg.getArgList()); } }
private static Placement placeQuadPattern(ExprList exprsIn, Node graphNode, BasicPattern pattern) { ExprList exprs = ExprList.copy(exprsIn) ; Set<Var> patternVarsScope = new HashSet<>() ; // Any filters that depend on no variables. Op op = insertAnyFilter$(exprs, patternVarsScope, null) ; if ( Var.isVar(graphNode) ) { // Add in the graph node of the quad block. VarUtils.addVar(patternVarsScope, Var.alloc(graphNode)) ; } for (Triple triple : pattern) { OpQuadPattern opQuad = getQuads(op) ; if ( opQuad == null ) { opQuad = new OpQuadPattern(graphNode, new BasicPattern()) ; op = OpSequence.create(op, opQuad) ; } opQuad.getBasicPattern().add(triple) ; // Update variables in scope. VarUtils.addVarsFromTriple(patternVarsScope, triple) ; op = insertAnyFilter$(exprs, patternVarsScope, op) ; } return result(op, exprs) ; }
private static Op transformFilterQuadPattern(ExprList exprs, Set<Var> patternVarsScope, Node graphNode, BasicPattern pattern) { // Any filters that depend on no variables. Op op = insertAnyFilter(exprs, patternVarsScope, null); if (Var.isVar(graphNode)) { // Add in the graph node of the quad block. // It's picked up after the first triple is processed. VarUtils.addVar(patternVarsScope, Var.alloc(graphNode)); } for (Triple triple : pattern) { OpQuadPattern opQuad = getQuads(op); if (opQuad == null) { opQuad = new OpQuadPattern(graphNode, new BasicPattern()); op = OpSequence.create(op, opQuad); } opQuad.getBasicPattern().add(triple); // Update variables in scope. VarUtils.addVarsFromTriple(patternVarsScope, triple); // Attempt to place any filters op = insertAnyFilter(exprs, patternVarsScope, op); } return op; }
@Override public void visit(ElementNamedGraph el) { VarUtils.addVar(acc, el.getGraphNameNode()) ; }
@Override public void visit(ElementNamedGraph el) { VarUtils.addVar(vars, el.getGraphNameNode()) ; }
@Override public void visit(OpDatasetNames dsNames) { addVar(defines, dsNames.getGraphNode()) ; }
@Override public void visit(ElementNamedGraph el) { VarUtils.addVar(vars, el.getGraphNameNode()) ; }
@Override public void visit(ElementService el) { VarUtils.addVar(vars, el.getServiceNode()); }
@Override public void visit(ElementService el) { VarUtils.addVar(vars, el.getServiceNode()); }
@Override public void visit(OpGroup opGroup) { // Only the group variables are visible. // So not the subOp, and not expressions. VarExprList varExprs = opGroup.getGroupVars() ; varExprs.forEachVar((v)->addVar(defines, v)) ; }
@Override public void visit(OpGraph opGraph) { addVar(defines, opGraph.getNode()); opGraph.getSubOp().visit(this); }