Search in sources :

Example 1 with Binding

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;
            }
        }
    };
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) IteratorDelayedInitialization(org.apache.jena.atlas.iterator.IteratorDelayedInitialization) QueryCancelledException(org.apache.jena.query.QueryCancelledException)

Example 2 with Binding

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;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding)

Example 3 with Binding

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;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding)

Example 4 with Binding

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;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) QueryIterator(org.apache.jena.sparql.engine.QueryIterator)

Example 5 with Binding

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;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) QueryIterator(org.apache.jena.sparql.engine.QueryIterator)

Aggregations

Binding (org.apache.jena.sparql.engine.binding.Binding)132 Node (org.apache.jena.graph.Node)39 ArrayList (java.util.ArrayList)36 Var (org.apache.jena.sparql.core.Var)33 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)27 Test (org.junit.Test)21 QueryIterPlainWrapper (org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper)16 BindingMap (org.apache.jena.sparql.engine.binding.BindingMap)10 BindingComparator (org.apache.jena.sparql.engine.binding.BindingComparator)8 BuilderBinding (org.apache.jena.sparql.sse.builders.BuilderBinding)8 NoSuchElementException (java.util.NoSuchElementException)7 Triple (org.apache.jena.graph.Triple)7 ResultSetStream (org.apache.jena.sparql.engine.ResultSetStream)7 ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)5 Op (org.apache.jena.sparql.algebra.Op)5 BasicPattern (org.apache.jena.sparql.core.BasicPattern)5 ResultSet (org.apache.jena.query.ResultSet)4 SortCondition (org.apache.jena.query.SortCondition)4 TableN (org.apache.jena.sparql.algebra.table.TableN)4 File (java.io.File)3