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;
}
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);
}
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);
}
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);
}
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));
}
}
Aggregations