public ExtendedIterator<Domain> executeBindings( List<Stage> outStages, NamedGraphMap args, Node[] nodes) { Mapping map = new Mapping(nodes); ArrayList<Stage> stages = new ArrayList<Stage>(); addStages(stages, args, map); if (constraint.isComplex()) stages.add(new ConstraintStage(map, constraint)); outStages.addAll(stages); variableCount = map.size(); return filter(connectStages(stages, variableCount)); }
private void addStages(ArrayList<Stage> stages, NamedGraphMap arguments, Mapping map) { Iterator<Map.Entry<String, Cons>> it2 = triples.entrySetIterator(); while (it2.hasNext()) { Map.Entry<String, Cons> e = it2.next(); String name = e.getKey(); Cons nodeTriples = e.getValue(); Graph g = arguments.get(name); int nBlocks = Cons.size(nodeTriples), i = nBlocks; Triple[] nodes = new Triple[nBlocks]; while (nodeTriples != null) { nodes[--i] = nodeTriples.head; nodeTriples = nodeTriples.tail; } nodes = sortTriples(nodes); Stage next = g.queryHandler().patternStage(map, constraint, nodes); stages.add(next); } }
private Stage connectStages(ArrayList<Stage> stages, int count) { Stage current = Stage.initial(count); for (int i = 0; i < stages.size(); i += 1) current = stages.get(i).connectFrom(current); return current; }