use of org.apache.jena.sparql.engine.iterator.QueryIterSort in project jena by apache.
the class TestQueryIterSort method testCancelInterruptsExternalSortAtStartOfIteration.
@Test(expected = QueryCancelledException.class)
public void testCancelInterruptsExternalSortAtStartOfIteration() {
iterator = new CallbackIterator(unsorted.iterator(), 25, null);
iterator.setCallback(() -> {
});
assertEquals(0, iterator.getReturnedElementCount());
Context context = new Context();
context.set(ARQ.spillToDiskThreshold, 10L);
ExecutionContext executionContext = new ExecutionContext(context, (Graph) null, (DatasetGraph) null, (OpExecutorFactory) null);
QueryIterSort qIter = new QueryIterSort(iterator, comparator, executionContext);
try {
assertTrue(qIter.hasNext());
assertEquals(49, DataBagExaminer.countTemporaryFiles(qIter.db));
assertNotNull(qIter.next());
assertTrue(qIter.hasNext());
qIter.cancel();
// throws a QueryCancelledException
qIter.hasNext();
} finally {
//assertTrue(iterator.isCanceled()) ;
assertEquals(500, iterator.getReturnedElementCount());
assertEquals(0, DataBagExaminer.countTemporaryFiles(qIter.db));
qIter.close();
}
assertEquals(0, DataBagExaminer.countTemporaryFiles(qIter.db));
}
use of org.apache.jena.sparql.engine.iterator.QueryIterSort in project jena by apache.
the class TestQueryIterSort method testCancelClosesSourceIterator.
@Test
public void testCancelClosesSourceIterator() {
Context context = new Context();
ExecutionContext ec = new ExecutionContext(context, (Graph) null, (DatasetGraph) null, (OpExecutorFactory) null);
QueryIterSort qis = new QueryIterSort(iterator, comparator, ec);
try {
while (qis.hasNext()) qis.next();
fail("query should have been cancelled by trigger");
} catch (QueryCancelledException q) {
assertTrue("source iterator should have been closed", iterator.isClosed());
}
}
use of org.apache.jena.sparql.engine.iterator.QueryIterSort 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.iterator.QueryIterSort in project jena by apache.
the class TestQueryIterSort method testCleanAfterClose.
@Test
public void testCleanAfterClose() {
// Do nothing.
iterator.setCallback(() -> {
});
assertEquals(0, iterator.getReturnedElementCount());
Context context = new Context();
context.set(ARQ.spillToDiskThreshold, 10L);
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(49, DataBagExaminer.countTemporaryFiles(qIter.db));
} finally {
qIter.close();
}
assertEquals(0, DataBagExaminer.countTemporaryFiles(qIter.db));
}
Aggregations