Search in sources :

Example 26 with Binding

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

the class TestExpressions3 method binding.

private static Binding binding(String bindingStr) {
    if (bindingStr == null || bindingStr.matches("\\s*\\(\\s*\\)\\s*"))
        return null;
    Item item = SSE.parse("(binding " + bindingStr + ")");
    Binding binding = BuilderBinding.build(item);
    return binding;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) BuilderBinding(org.apache.jena.sparql.sse.builders.BuilderBinding) Item(org.apache.jena.sparql.sse.Item)

Example 27 with Binding

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

the class TestExpressions3 method eval.

// From SPARQL syntax
private static void eval(String string, String bindingStr, boolean expected) {
    Binding binding = binding(bindingStr);
    Expr expr = ExprUtils.parse(string);
    NodeValue nv = expr.eval(binding, FunctionEnvBase.createTest());
    boolean b = XSDFuncOp.booleanEffectiveValue(nv);
    assertEquals(string, expected, b);
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) BuilderBinding(org.apache.jena.sparql.sse.builders.BuilderBinding)

Example 28 with Binding

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

the class AbstractTestDistinctReduced method distinct.

private void distinct(List<String> data, List<String> results) {
    // Distinct Iterators are not required to preserve order.
    List<Binding> input = build(data);
    List<Binding> output = build(results);
    QueryIterator qIter = createQueryIter(input);
    List<Binding> iterList = Iter.toList(qIter);
    assertEquals(output + " :: " + iterList, output.size(), iterList.size());
    // Assume results has no duplicates so same size, same members => order dependent same.
    Set<Binding> testExpected = new HashSet<>(output);
    Set<Binding> testResult = new HashSet<>(iterList);
    assertEquals(testExpected, testResult);
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) QueryIterator(org.apache.jena.sparql.engine.QueryIterator) HashSet(java.util.HashSet)

Example 29 with Binding

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

the class TestCancelDistinct method testCloseWhenBagPresent.

@Test
public void testCloseWhenBagPresent() {
    params.set(ARQ.spillToDiskThreshold, 0);
    QueryIteratorBase base = new MockQueryIterator(BindingFactory.create());
    QueryIterDistinct d = new QueryIterDistinct(base, c);
    assertNull(d.db);
    Binding ignored = d.next();
    assertNotNull(d.db);
    DistinctDataBag<Binding> bag = d.db;
    d.close();
    assertTrue(bag.isClosed());
    assertNull(d.db);
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) Test(org.junit.Test)

Example 30 with Binding

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

the class OpRewriter method visit.

@Override
public void visit(OpTable opTable) {
    Table tbl = opTable.getTable();
    boolean process = false;
    for (Var v : tbl.getVars()) {
        process = process | values.keySet().contains(v);
    }
    if (!process) {
        push(opTable);
    } else {
        TableN retTbl = new TableN(tbl.getVars());
        Iterator<Binding> iter = tbl.rows();
        while (iter.hasNext()) {
            retTbl.addBinding(rewrite(iter.next()));
        }
        push(OpTable.create(retTbl));
    }
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) Table(org.apache.jena.sparql.algebra.Table) TableN(org.apache.jena.sparql.algebra.table.TableN)

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