Search in sources :

Example 31 with ExecutionContext

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();
    }
}
Also used : Context(org.apache.jena.sparql.util.Context) SerializationContext(org.apache.jena.sparql.serializer.SerializationContext) ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext) ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext) Test(org.junit.Test)

Example 32 with ExecutionContext

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());
}
Also used : Context(org.apache.jena.sparql.util.Context) SerializationContext(org.apache.jena.sparql.serializer.SerializationContext) ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext) ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext) Test(org.junit.Test)

Example 33 with ExecutionContext

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);
}
Also used : ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext) QueryIterator(org.apache.jena.sparql.engine.QueryIterator) TableN(org.apache.jena.sparql.algebra.table.TableN) HashSet(java.util.HashSet)

Example 34 with ExecutionContext

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);
}
Also used : FunctionEnv(org.apache.jena.sparql.function.FunctionEnv) ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext)

Example 35 with ExecutionContext

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));
}
Also used : Context(org.apache.jena.sparql.util.Context) ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext) ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext) QueryIterator(org.apache.jena.sparql.engine.QueryIterator)

Aggregations

ExecutionContext (org.apache.jena.sparql.engine.ExecutionContext)40 Context (org.apache.jena.sparql.util.Context)19 Node (org.apache.jena.graph.Node)14 SerializationContext (org.apache.jena.sparql.serializer.SerializationContext)12 Test (org.junit.Test)12 Binding (org.apache.jena.sparql.engine.binding.Binding)11 Triple (org.apache.jena.graph.Triple)9 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)9 Iterator (java.util.Iterator)8 Iter (org.apache.jena.atlas.iterator.Iter)8 Var (org.apache.jena.sparql.core.Var)8 Predicate (java.util.function.Predicate)7 Graph (org.apache.jena.graph.Graph)7 InternalErrorException (org.apache.jena.atlas.lib.InternalErrorException)6 Function (java.util.function.Function)5 ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)5 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)5 Quad (org.apache.jena.sparql.core.Quad)5 Substitute (org.apache.jena.sparql.core.Substitute)5 BindingFactory (org.apache.jena.sparql.engine.binding.BindingFactory)5