public static void computeForEach(ReadGraphImpl graph, final int r, final Predicates entry, final InternalProcedure<IntSet> procedure) throws DatabaseException {
-
- IntSet direct = QueryCache.resultDirectPredicates(graph, r, entry, null, procedure);
- IntSet result = new IntSet();
- direct.forEach(new TIntProcedure() {
- @Override
- public boolean execute(int value) {
- result.add(value);
- return true;
- }
- });
+ IntSet direct = QueryCache.resultDirectPredicates(graph, r, entry, null);
+ IntSet result = new IntSet(graph.processor.querySupport);
forAssertions(graph, r, entry, result);
-// DirectPredicates.queryEach(graph, r, processor, entry, null, new IntProcedure() {
-//
-// @Override
-// public void execute(ReadGraphImpl graph, final int pred) throws DatabaseException {
-// result.add(pred);
-// }
-//
-// @Override
-// public void finished(ReadGraphImpl graph) throws DatabaseException {
-//
-//
-// }
-//
-// @Override
-// public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
-// procedure.exception(graph, t);
-// }
-//
-// });
-
- if(entry != null) {
- entry.setResult(result);
- entry.setReady();
- }
+ if(result.isEmpty()) {
+
+ if(entry != null) {
+ entry.setResult(direct);
+ entry.setReady();
+ }
+
+ procedure.execute(graph, direct);
+
+ } else {
+
+ direct.forEach(new TIntProcedure() {
+ @Override
+ public boolean execute(int value) {
+ result.add(value);
+ return true;
+ }
+ });
+
+ if(entry != null) {
+ entry.setResult(result);
+ entry.setReady();
+ }
+
+ procedure.execute(graph, result);
+
+ }
- procedure.execute(graph, result);
}