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=03b17bba5cfba708064f2a9ed84b115348af8f4d;hb=68ce0966a57f5153b133c6283fdbae10f683b745;hp=3841e1d14640777706ce30421c00d2bcce2d43ea;hpb=ad18bf76b19bec530bc68c6041ab5fb245b8ee4d;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..03b17bba5 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 @@ -77,7 +77,7 @@ final public class Predicates extends UnaryQuery> { } - @Override + //@Override public Object compute(ReadGraphImpl graph, final InternalProcedure procedure) throws DatabaseException { computeForEach(graph, id, this, procedure); return getResult(); @@ -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); }