Refine search
private static Triple bindingToTriple(Node vs, Node vp, Node vo, Binding binding) { Node sResult = vs ; Node pResult = vp ; Node oResult = vo ; if ( Var.isVar(vs) ) sResult = binding.get(Var.alloc(vs)) ; if ( Var.isVar(vp) ) pResult = binding.get(Var.alloc(vp)) ; if ( Var.isVar(vo) ) oResult = binding.get(Var.alloc(vo)) ; return Triple.create(sResult, pResult, oResult) ; }
@Override protected QueryIterator execOneList(Binding binding, Node listNode, Node predicate, Node member, ExecutionContext execCxt) { if ( Var.isVar(listNode) ) throw new QueryExecException("List : subject not a list or variable bound to a list") ; // Case : arg 1 (the list) is bound and arg 2 not bound => generate possibilities // Case : arg 1 is bound and arg 2 is bound => test for membership. if ( Var.isVar(member) ) return members(binding, listNode, Var.alloc(member) , execCxt) ; else return verify(binding, listNode, member, execCxt) ; }
@Override protected QueryIterator execOneList(Binding binding, Node listNode, Node predicate, List<Node> objectArgs, ExecutionContext execCxt) { if ( Var.isVar(listNode) ) throw new ExprEvalException("ListIndex : subject not a list or variable bound to a list") ; if ( objectArgs.size() != 2 ) throw new ExprEvalException("ListIndex : object not a list of length 2") ; Node indexNode = objectArgs.get(0) ; Node memberNode = objectArgs.get(1) ; Graph graph = execCxt.getActiveGraph() ; if ( Var.isVar(indexNode) && ! Var.isVar(memberNode) ) return findIndex(graph, binding, listNode, Var.alloc(indexNode), memberNode, execCxt) ; if ( ! Var.isVar(indexNode) && Var.isVar(memberNode) ) return getByIndex(graph, binding, listNode, indexNode, Var.alloc(memberNode), execCxt) ; if ( ! Var.isVar(indexNode) && ! Var.isVar(memberNode) ) return testSlotValue(graph, binding, listNode, indexNode, memberNode, execCxt) ; return findIndexMember(graph, binding, listNode, Var.alloc(indexNode), Var.alloc(memberNode), execCxt) ; }
private static QueryIterator evalGroundedOneEnd(Binding binding, Iterator<Node> iter, Node endNode, ExecutionContext execCxt) { List<Binding> results = new ArrayList<>() ; if (! Var.isVar(endNode)) throw new ARQInternalErrorException("Non-variable endnode in _execTriplePath") ; Var var = Var.alloc(endNode) ; // Assign. for (; iter.hasNext();) { Node n = iter.next() ; results.add(BindingFactory.binding(binding, var, n)) ; } return new QueryIterPlainWrapper(results.iterator(), execCxt) ; }
private static Quad bindingToQuad(Node vg, Node vs, Node vp, Node vo, Binding binding) { Node gResult = vg ; Node sResult = vs ; Node pResult = vp ; Node oResult = vo ; if ( Var.isVar(vg) ) gResult = binding.get(Var.alloc(vg)) ; if ( Var.isVar(vs) ) sResult = binding.get(Var.alloc(vs)) ; if ( Var.isVar(vp) ) pResult = binding.get(Var.alloc(vp)) ; if ( Var.isVar(vo) ) oResult = binding.get(Var.alloc(vo)) ; return Quad.create(gResult, sResult, pResult, oResult) ; }
/** Return null for variables, and for nodes, the node id or NodeDoesNotExist */ private static NodeId idFor(NodeTable nodeTable, BindingNodeId input, Node node) { if ( Var.isVar(node) ) { NodeId n = input.get((Var.alloc(node))) ; // Bound to NodeId or null. return n ; } // May return NodeId.NodeDoesNotExist which must not be null. return nodeTable.getNodeIdForNode(node) ; }
/** Return null for variables, and for nodes, the node id or NodeDoesNotExist */ private static NodeId idFor(NodeTable nodeTable, BindingNodeId input, Node node) { if ( Var.isVar(node) ) { NodeId n = input.get((Var.alloc(node))) ; // Bound to NodeId or null. return n ; } // May return NodeId.NodeDoesNotExist which must not be null. return nodeTable.getNodeIdForNode(node) ; }
@Override public Node apply(Node node) { if ( !Var.isVar(node) ) return node ; Var var = (Var)node ; String varName = var.getName() ; if ( repeatedly ) { while (varName.startsWith(varPrefix)) varName = varName.substring(varPrefix.length()); } else { if ( varName.startsWith(varPrefix) ) varName = varName.substring(varPrefix.length()); } if ( varName == var.getName() ) return node ; return Var.alloc(varName) ; } }
@Override public QueryIterator execOneList(Binding binding, Node listNode, Node predicate, Node length, ExecutionContext execCxt) { Graph graph = execCxt.getActiveGraph() ; if ( Var.isVar(listNode) ) throw new ARQInternalErrorException("listLength: Subject is a variable") ; // Case : arg 1 (the list) is bound and arg 2 not bound => generate possibilities // Case : arg 1 is bound and arg 2 is bound => test for membership. if ( Var.isVar(length) ) return length(binding, graph, listNode, Var.alloc(length) , execCxt) ; else return verify(binding, graph, listNode, length, execCxt) ; }