Search in sources :

Example 76 with Binding

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

the class QueryIterDistinct method getInputNext.

/** Return the binding from the input, hiding any variables to be ignored. */
private Binding getInputNext() {
    Binding b = getInput().next();
    // Hide unnamed and internal variables.
    b = new BindingProjectNamed(b);
    return b;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) BindingProjectNamed(org.apache.jena.sparql.engine.binding.BindingProjectNamed)

Example 77 with Binding

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

the class QueryIterDistinct method loadDataBag.

/** Load the data bag with. Filter incoming by the already seen in-memory elements */
private void loadDataBag() {
    ThresholdPolicy<Binding> policy = ThresholdPolicyFactory.policyFromContext(super.getExecContext().getContext());
    Comparator<Binding> comparator = new BindingComparator(new ArrayList<SortCondition>(), super.getExecContext());
    this.db = BagFactory.newDistinctBag(policy, SerializationFactoryFinder.bindingSerializationFactory(), comparator);
    for (; ; ) {
        Binding b = getInputNextUnseen();
        if (b == null)
            break;
        db.add(b);
    }
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) SortCondition(org.apache.jena.query.SortCondition) BindingComparator(org.apache.jena.sparql.engine.binding.BindingComparator)

Example 78 with Binding

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

the class QueryIterMinus method moveToNextBinding.

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

Example 79 with Binding

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

the class QueryIterPeek method moveToNextBinding.

@Override
protected Binding moveToNextBinding() {
    if (!hasNextBinding())
        throw new ARQInternalErrorException("No next binding");
    Binding b = binding;
    binding = null;
    return b;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException)

Example 80 with Binding

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

the class TestCancelDistinct method testBaggedCancelPropagates.

/**
       test that of a QueryIterDistinct with an active databag is 
       cancelled, so is the iterator that it wraps.
    */
@Test
public void testBaggedCancelPropagates() {
    params.set(ARQ.spillToDiskThreshold, 0);
    QueryIteratorBase base = new MockQueryIterator(BindingFactory.create());
    QueryIterDistinct d = new QueryIterDistinct(base, c);
    assertNull(d.db);
    Binding b = d.next();
    assertNotNull(d.db);
    DistinctDataBag<Binding> db = d.db;
    assertFalse(base.getRequestingCancel());
    d.cancel();
    assertTrue(base.getRequestingCancel());
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) Test(org.junit.Test)

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