use of org.apache.jena.sparql.engine.ExecutionContext in project jena by apache.
the class TestQueryIterSort method testNoSpill.
@Test
public void testNoSpill() {
iterator.setCallback(() -> {
});
// new Callback() { @Override
// public void call() { /* do nothing */ } });
assertEquals(0, iterator.getReturnedElementCount());
Context context = new Context();
ExecutionContext executionContext = new ExecutionContext(context, (Graph) null, (DatasetGraph) null, (OpExecutorFactory) null);
QueryIterSort qIter = new QueryIterSort(iterator, comparator, executionContext);
try {
assertEquals(0, iterator.getReturnedElementCount());
assertEquals(0, DataBagExaminer.countTemporaryFiles(qIter.db));
qIter.hasNext();
assertEquals(500, iterator.getReturnedElementCount());
assertEquals(0, DataBagExaminer.countTemporaryFiles(qIter.db));
} finally {
qIter.close();
}
}
use of org.apache.jena.sparql.engine.ExecutionContext in project jena by apache.
the class TestQueryIterSort method testExhaustionClosesSourceIterator.
@Test
public void testExhaustionClosesSourceIterator() {
iterator.setCallback(() -> {
});
Context context = new Context();
ExecutionContext ec = new ExecutionContext(context, (Graph) null, (DatasetGraph) null, (OpExecutorFactory) null);
QueryIterSort qis = new QueryIterSort(iterator, comparator, ec);
while (qis.hasNext()) qis.next();
assertTrue("source iterator should have been closed", iterator.isClosed());
}
use of org.apache.jena.sparql.engine.ExecutionContext in project jena by apache.
the class TestTableJoin method test.
private void test(Table left, Table right, boolean normalJoin, ExprList exprs, Table expected) {
ExecutionContext execCxt = new ExecutionContext(ARQ.getContext(), null, null, null);
QueryIterator leftIter = left.iterator(execCxt);
QueryIterator qIter = normalJoin ? TableJoin.join(leftIter, right, exprs, execCxt) : TableJoin.leftJoin(leftIter, right, exprs, execCxt);
// Order issues
Set<String> vars1 = new HashSet<>();
vars1.addAll(left.getVarNames());
vars1.addAll(right.getVarNames());
TableN results = new TableN(qIter);
boolean b = TableCompare.equalsByTerm(expected, results);
if (!b) {
System.out.println("** Expected");
System.out.println(expected);
System.out.println("** Actual");
System.out.println(results);
}
assertTrue(b);
}
use of org.apache.jena.sparql.engine.ExecutionContext in project jena by apache.
the class TestCastXSD method cast.
private NodeValue cast(String input$) {
Expr input = ExprUtils.parse(input$);
ARQ.getContext().set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime());
FunctionEnv env = new ExecutionContext(ARQ.getContext(), null, null, null);
return input.eval(null, env);
}
use of org.apache.jena.sparql.engine.ExecutionContext in project jena by apache.
the class TestDistinctDataBagLimited method createQueryIter.
@Override
protected QueryIterator createQueryIter(List<Binding> data) {
QueryIterator qIter = QueryIterPlainWrapper.create(data.iterator());
Context cxt = new Context();
cxt.set(ARQ.spillToDiskThreshold, 2L);
return new QueryIterDistinct(qIter, null, new ExecutionContext(cxt, null, null, null));
}
Aggregations