X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FPredicates.java;h=e5cb6dfa146e10f6cf5b6b909554e56abe532cc0;hb=ded784594eb0e1fb318fbb931135288152691cf2;hp=3841e1d14640777706ce30421c00d2bcce2d43ea;hpb=061c58a485fbfda0732a8dc597582762a97012e4;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/Predicates.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/Predicates.java index 3841e1d14..e5cb6dfa1 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/Predicates.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/Predicates.java @@ -85,45 +85,39 @@ final public class Predicates extends UnaryQuery> { public static void computeForEach(ReadGraphImpl graph, final int r, final Predicates entry, final InternalProcedure 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); }