diff --git a/bundles/io.github.linkedfactory.core/src/main/java/io/github/linkedfactory/core/rdf4j/kvin/KvinFederatedService.java b/bundles/io.github.linkedfactory.core/src/main/java/io/github/linkedfactory/core/rdf4j/kvin/KvinFederatedService.java index 9d7e1616..0fa31b98 100644 --- a/bundles/io.github.linkedfactory.core/src/main/java/io/github/linkedfactory/core/rdf4j/kvin/KvinFederatedService.java +++ b/bundles/io.github.linkedfactory.core/src/main/java/io/github/linkedfactory/core/rdf4j/kvin/KvinFederatedService.java @@ -110,13 +110,21 @@ public CloseableIteration evaluate( while (bindings.hasNext() && bindingSetList.size() < InnerJoinIterator.BATCH_SIZE) { bindingSetList.add(bindings.next()); } - resultIters.add(new AsyncIterator<>(() -> ((BatchQueryEvaluationStep) precompiled) - .evaluate(bindingSetList), executorService)); + if (! bindings.hasNext()) { + resultIters.add(((BatchQueryEvaluationStep) precompiled).evaluate(bindingSetList)); + } else { + resultIters.add(new AsyncIterator<>(() -> ((BatchQueryEvaluationStep) precompiled) + .evaluate(bindingSetList), executorService)); + } } } else { while (bindings.hasNext()) { BindingSet bs = bindings.next(); - resultIters.add(new AsyncIterator<>(() -> precompiled.evaluate(bs), executorService)); + if (! bindings.hasNext()) { + resultIters.add(precompiled.evaluate(bs)); + } else { + resultIters.add(new AsyncIterator<>(() -> precompiled.evaluate(bs), executorService)); + } } }