Search in sources :

Example 56 with Binding

use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.

the class QueryIterDefaulting method moveToNextBinding.

@Override
protected Binding moveToNextBinding() {
    if (isFinished())
        throw new NoSuchElementException(Lib.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;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) NoSuchElementException(java.util.NoSuchElementException)

Example 57 with Binding

use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.

the class QueryIterDistinct method hasNextBinding.

@Override
protected boolean hasNextBinding() {
    if (slot != null)
        return true;
    if (iterator != null)
        // Databag active.
        return iterator.hasNext();
    // At this point, we are currently in the initial pre-threshold mode.
    if (seen.size() < memThreshold) {
        Binding b = getInputNextUnseen();
        if (b == null)
            return false;
        seen.add(b);
        slot = b;
        return true;
    }
    // Hit the threshold.
    loadDataBag();
    // Switch to iterating from the data bag.  
    iterator = db.iterator();
    // Leave slot null.
    return iterator.hasNext();
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding)

Example 58 with Binding

use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.

the class QueryIterDistinct method moveToNextBinding.

@Override
protected Binding moveToNextBinding() {
    if (slot != null) {
        Binding b = slot;
        slot = null;
        return b;
    }
    if (iterator != null) {
        Binding b = iterator.next();
        return b;
    }
    throw new InternalErrorException();
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) InternalErrorException(org.apache.jena.atlas.lib.InternalErrorException)

Example 59 with Binding

use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.

the class QueryIterDistinctReduced method hasNextBinding.

@Override
protected final boolean hasNextBinding() {
    // Already waiting to go.
    if (slot != null)
        return true;
    // Always moves.
    for (; getInput().hasNext(); ) {
        Binding b = getInput().nextBinding();
        // Hide unnamed and internal variables.
        // Don't need to worry about rename scope vars 
        // (they are projected away in sub-SELECT ?var { ... }) 
        b = new BindingProjectNamed(b);
        if (isFreshSighting(b)) {
            slot = b;
            return true;
        }
    }
    return false;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) BindingProjectNamed(org.apache.jena.sparql.engine.binding.BindingProjectNamed)

Example 60 with Binding

use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.

the class QueryIterDistinctReduced method moveToNextBinding.

@Override
protected final Binding moveToNextBinding() {
    Binding r = slot;
    slot = null;
    return r;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding)

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