private void materialize(QueryIterator qIter) { while (qIter.hasNext()) { Binding binding = qIter.nextBinding() ; addBinding(binding) ; } qIter.close() ; }
@Override protected void requestCancel() { if ( iterator != null ) { iterator.cancel(); } } }
@Override public QueryIterator exec(QueryIterator input, PropFuncArg argSubject, Node predicate, PropFuncArg argObject, ExecutionContext execCxt) { List<Binding> bindings = new ArrayList<>() ; for ( ; input.hasNext() ; ) bindings.add(input.nextBinding()) ; return new QueryIterPlainWrapper(bindings.iterator(), execCxt) ; }
@Override protected boolean hasNextBinding() { return iterator.hasNext() ; } }
@Override protected void closeSubIterator() { if ( output != null ) output.close() ; output = null ; }
@Override protected Binding moveToNextBinding() { return output.nextBinding() ; }
/** * Creates a new index table * * @param commonVars * Common Variables * @param data * Data */ public SetIndexTable(Set<Var> commonVars, QueryIterator data) { if (commonVars.size() != 1) throw new IllegalArgumentException("Common Variables must be of size 1"); this.var = commonVars.iterator().next(); while (data.hasNext()) { Binding binding = data.next(); Node value = binding.get(this.var); if (value == null) continue; this.values.add(value); } }
protected QueryIterator execute(BasicPattern pattern, ReorderTransformation reorder, StageGenerator execution, QueryIterator input, ExecutionContext execCxt) { Explain.explain(pattern, execCxt.getContext()) ; if ( ! input.hasNext() ) return input ; if ( reorder != null && pattern.size() >= 2 ) { // If pattern size is 0 or 1, nothing to do. BasicPattern bgp2 = pattern ; // Try to ground the pattern if ( ! input.isJoinIdentity() ) { QueryIterPeek peek = QueryIterPeek.create(input, execCxt) ; // And now use this one input = peek ; Binding b = peek.peek() ; bgp2 = Substitute.substitute(pattern, b) ; } ReorderProc reorderProc = reorder.reorderIndexes(bgp2) ; pattern = reorderProc.reorder(pattern) ; } Explain.explain("Reorder/generic", pattern, execCxt.getContext()) ; return QueryIterBlockTriples.create(input, pattern, execCxt) ; } }
public static Table create(QueryIterator queryIterator) { if ( queryIterator.isJoinIdentity() ) { queryIterator.close(); return createUnit() ; } return new TableN(queryIterator) ; }
@Override protected boolean hasNextBinding() { if ( binding != null ) return true ; if ( ! getInput().hasNext() ) return false ; binding = getInput().nextBinding() ; return true ; }
@Override protected boolean hasNextBinding() { return output.hasNext() ; }
@Override protected void closeSubIterator() { if ( currentStage != null ) currentStage.close() ; }
/** * Create a hashjoin QueryIterator. * @param joinKey Join key - if null, one is guessed by snooping the input QueryIterators * @param left * @param right * @param conditions * @param execCxt * @return QueryIterator */ public static QueryIterator create(JoinKey joinKey, QueryIterator left, QueryIterator right, ExprList conditions, ExecutionContext execCxt) { // Easy cases. if ( ! left.hasNext() ) { left.close() ; right.close() ; return QueryIterNullIterator.create(execCxt) ; } if ( ! right.hasNext() ) { right.close() ; return left ; } if ( joinKey != null && joinKey.length() > 1 ) Log.warn(QueryIterHashLeftJoin_Left.class, "Multivariable join key") ; return new QueryIterHashLeftJoin_Left(joinKey, left, right, conditions, execCxt) ; }
@Override protected Binding moveToNextBinding() { return iterator.nextBinding() ; }
/** Very simple, materializing version - useful for debugging. * Builds output early. Materializes left, streams right. * Does <b>not</b> scale. * No cancellation, no stats. * * @see #nestedLoopJoin */ public static QueryIterator nestedLoopJoinBasic(QueryIterator left, QueryIterator right, ExecutionContext execCxt) { List<Binding> leftRows = Iter.toList(left) ; List<Binding> output = new ArrayList<>() ; for ( ; right.hasNext() ; ) { Binding row2 = right.next() ; for ( Binding row1 : leftRows ) { Binding r = Algebra.merge(row1, row2) ; if ( r != null ) output.add(r) ; } } return new QueryIterPlainWrapper(output.iterator(), execCxt) ; }
protected QueryIterator execute(OpTable opTable, QueryIterator input) { if (opTable.isJoinIdentity()) return input ; if (input.isJoinIdentity() ) { input.close() ; return opTable.getTable().iterator(execCxt); } QueryIterator qIterT = opTable.getTable().iterator(execCxt) ; QueryIterator qIter = Join.join(input, qIterT, execCxt) ; return qIter ; }
public QueryIteratorCopy(QueryIterator qIter) { for ( ; qIter.hasNext() ; ) elements.add(qIter.nextBinding()) ; qIter.close() ; iterator = copy() ; original = qIter ; }