use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class QueryIterTopN method sortTopN.
private Iterator<Binding> sortTopN(final QueryIterator qIter, final Comparator<Binding> comparator) {
return new IteratorDelayedInitialization<Binding>() {
@Override
protected Iterator<Binding> initializeIterator() {
try {
while (qIter.hasNext()) {
Binding binding = qIter.next();
if (heap.size() < limit)
add(binding);
else {
Binding currentMaxLeastN = heap.peek();
if (comparator.compare(binding, currentMaxLeastN) < 0)
add(binding);
}
}
qIter.close();
Binding[] y = heap.toArray(new Binding[] {});
heap = null;
Arrays.sort(y, comparator);
return asList(y).iterator();
} catch (QueryCancelledException e) {
QueryIterTopN.this.close();
this.close();
throw e;
}
}
};
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class QueryIteratorCaching method moveToNextBinding.
@Override
protected Binding moveToNextBinding() {
Binding b = super.moveToNextBinding();
cache.add(b);
return b;
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class AbstractIterHashJoin method buildHashTable.
private void buildHashTable(QueryIterator iter1) {
state = Phase.HASH;
for (; iter1.hasNext(); ) {
Binding row1 = iter1.next();
s_countProbe++;
hashTable.put(row1);
}
iter1.close();
state = Phase.STREAM;
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class OpExecutor method execute.
protected QueryIterator execute(OpJoin opJoin, QueryIterator input) {
if (false) {
// If needed, applies to OpDiff and OpLeftJoin as well.
List<Binding> a = all(input);
QueryIterator qIter1 = new QueryIterPlainWrapper(a.iterator(), execCxt);
QueryIterator qIter2 = new QueryIterPlainWrapper(a.iterator(), execCxt);
QueryIterator left = exec(opJoin.getLeft(), qIter1);
QueryIterator right = exec(opJoin.getRight(), qIter2);
QueryIterator qIter = Join.join(left, right, execCxt);
return qIter;
}
QueryIterator left = exec(opJoin.getLeft(), input);
QueryIterator right = exec(opJoin.getRight(), root());
// Join key.
QueryIterator qIter = Join.join(left, right, execCxt);
return qIter;
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class QueryIterRepeatApply method makeNextStage.
private QueryIterator makeNextStage() {
count++;
if (getInput() == null)
return null;
if (!getInput().hasNext()) {
getInput().close();
return null;
}
Binding binding = getInput().next();
QueryIterator iter = nextStage(binding);
return iter;
}
Aggregations