public 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 protected Iterator<Binding> initializeIterator() { // Be careful about duplicates. // Used to use a TreeSet but, well, that's a set. List<Binding> x = new ArrayList<Binding>() ; for ( ; qIter.hasNext() ; ) { Binding b = qIter.next() ; x.add(b) ; } Binding[] y = x.toArray(new Binding[]{}) ; x = null ; // Drop the List now - might be big. Unlikely to really make a real difference. But we can try. Arrays.sort(y, comparator) ; x = Arrays.asList(y) ; return x.iterator() ; } };
@Override protected boolean hasNextBinding() { if ( binding != null ) return true ; if ( ! getInput().hasNext() ) return false ; binding = getInput().nextBinding() ; return true ; }
@Override protected Binding moveToNextBinding() { return output.nextBinding() ; }
@Override protected boolean hasNextBinding() { return output.hasNext() ; }
@Override protected void closeSubIterator() { if ( currentStage != null ) currentStage.close() ; }
@Override public void output(IndentedWriter out, SerializationContext sCxt) { iterator.output(out, sCxt) ; }
@Override protected Binding moveToNextBinding() { return iterator.next() ; }
/** * 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); } }
@Override protected boolean hasNextBinding() { if ( binding != null ) return true ; if ( ! getInput().hasNext() ) return false ; binding = getInput().nextBinding() ; return true ; }
@Override protected Binding moveToNextBinding() { return output.nextBinding() ; }
/** * Is there another possibility? */ public boolean hasNext() { if ( queryExecutionIter == null ) return false ; boolean r = queryExecutionIter.hasNext() ; return r; }
@Override protected void closeSubIterator() { if ( currentStage != null ) currentStage.close() ; }
@Override public void output(IndentedWriter out, SerializationContext sCxt) { iterator.output(out, sCxt) ; }
@Override protected Binding moveToNextBinding() { return iterator.next() ; }
private void materialize(QueryIterator qIter) { while (qIter.hasNext()) { Binding binding = qIter.nextBinding() ; addBinding(binding) ; } qIter.close() ; }
public LinearIndex(Set<Var> commonVars, QueryIterator data, Set<HashIndexTable.Key> loadedData, Map<Var,Integer> mappings) { this.commonVars = commonVars ; for ( HashIndexTable.Key key: loadedData ) table.add(toBinding(key, mappings)) ; while ( data.hasNext() ) table.add(data.next()) ; data.close() ; }
@Override protected Binding moveToNextBinding() { if ( isFinished() ) throw new NoSuchElementException(Utils.className(this)) ; if ( returnDefaultObject ) { haveReturnedSomeObject = true ; return defaultObject ; } Binding binding = null ; if ( iter != null && iter.hasNext() ) binding = iter.next() ; else { if ( haveReturnedSomeObject ) throw new NoSuchElementException("DefaultingIterator - without hasNext call first") ; binding = defaultObject ; } haveReturnedSomeObject = true ; return binding ; }