@Override protected QueryIterator execObjectList(Binding binding, Var listVar, Node predicate, List<Node> objectArgs, ExecutionContext execCxt) { // subject a variable. 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) ; final Collection<Node> x ; if ( ! Var.isVar(memberNode) ) // If memberNode is defined, find lists containing it. x = GraphList.listFromMember(new GNode(execCxt.getActiveGraph(), memberNode)) ; else // Hard. Subject unbound, no fixed member. Find every list and use BFI. x = GraphList.findAllLists(execCxt.getActiveGraph()) ; return super.allLists(binding, x, listVar, predicate, new PropFuncArg(objectArgs, null), execCxt) ; }
/** Calculate ?s list:member ?o as if it were a graph.find */ public static Iterator<Triple> listMember(Graph graph, final Node s, Node o) { if ( isAny(s) ) { Set<Node> x = findAllLists(graph) ; IteratorConcat<Triple> iterConcat = new IteratorConcat<>() ; for ( Node s2 : x ) { Iterator<Triple> iter = listMember(graph, s2, o) ; if ( iter.hasNext() ) iterConcat.add(iter); } return iterConcat ; } GNode gn = new GNode(graph, s) ; if ( ! isAny(o) ) { if ( contains(gn, o) ) return Iter.singleton(Triple.create(s, ListPFunction.nListMember, o)) ; else return Iter.nullIterator() ; } List<Node> x = members(gn) ; return Iter.map(x.iterator(), t -> Triple.create(s, ListPFunction.nListMember, t)) ; }
Set<Node> x = GraphList.findAllLists(graph) ; return allLists(binding, x, listVar, obj, argObject, execCxt) ;