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;fp=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FPredicates.java;h=9445db03b4e048ca1488cb22f45eeaa56da9bdd1;hb=de8b6e194da6d56c410101d9c72763078b0e8717;hp=03b17bba5cfba708064f2a9ed84b115348af8f4d;hpb=880a8a4927805afbbf47005a807cef3f39406866;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 03b17bba5..9445db03b 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 @@ -12,16 +12,14 @@ package org.simantics.db.impl.query; import org.simantics.db.common.exception.DebugException; -import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; import org.simantics.db.impl.graph.ReadGraphImpl; import org.simantics.db.impl.procedure.InternalProcedure; -import org.simantics.db.procedure.ListenerBase; import org.simantics.db.request.RequestFlags; import gnu.trove.procedure.TIntProcedure; -final public class Predicates extends UnaryQuery> { +final public class Predicates extends UnaryQueryP { Predicates(final int r) { super(r); @@ -32,9 +30,9 @@ final public class Predicates extends UnaryQuery> { provider.cache.remove(this); } - final static private void forAssertions(ReadGraphImpl graph, int r, Predicates entry, final IntSet set) throws DatabaseException { + final static private void forAssertions(ReadGraphImpl graph, int r, Predicates parent, final IntSet set) throws DatabaseException { - QueryCache.runnerPrincipalTypes(graph, r, entry, null, new SyncIntProcedure() { + QueryCache.runnerPrincipalTypes(graph, r, parent, null, new SyncIntProcedure() { @Override public void run(ReadGraphImpl graph) throws DatabaseException { @@ -63,7 +61,7 @@ final public class Predicates extends UnaryQuery> { public void execute(ReadGraphImpl graph, int type) throws DatabaseException { inc(); - QueryCache.runnerAssertedPredicates(graph, type, entry, null, proc); + QueryCache.runnerAssertedPredicates(graph, type, parent, null, proc); } @@ -77,13 +75,14 @@ final public class Predicates extends UnaryQuery> { } - //@Override - public Object compute(ReadGraphImpl graph, final InternalProcedure procedure) throws DatabaseException { + @Override + public void compute(ReadGraphImpl graph, final InternalProcedure procedure) throws DatabaseException { computeForEach(graph, id, this, procedure); - return getResult(); } - public static void computeForEach(ReadGraphImpl graph, final int r, final Predicates entry, final InternalProcedure procedure) throws DatabaseException { + public static void computeForEach(ReadGraphImpl graph, final int r, final Predicates entry, final InternalProcedure procedure_) throws DatabaseException { + + InternalProcedure procedure = entry != null ? entry : procedure_; IntSet direct = QueryCache.resultDirectPredicates(graph, r, entry, null); @@ -91,16 +90,8 @@ final public class Predicates extends UnaryQuery> { forAssertions(graph, r, entry, result); 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) { @@ -108,16 +99,10 @@ final public class Predicates extends UnaryQuery> { return true; } }); - - if(entry != null) { - entry.setResult(result); - entry.setReady(); - } - procedure.execute(graph, result); - } - + + if(entry != null) entry.performFromCache(graph, procedure_); } @@ -126,61 +111,14 @@ final public class Predicates extends UnaryQuery> { return "Predicates[" + id + "]"; } - final public void finish(final ReadGraphImpl graph, QueryProcessor provider) { - - synchronized(this) { - setReady(); - } - - } - @Override public void clearResult(QuerySupport support) { setResult(new IntSet(support)); } - @Override - public Object performFromCache(final ReadGraphImpl graph, final InternalProcedure procedure) throws DatabaseException { - - assert(isReady()); - - if(handleException(graph, procedure)) return EXCEPTED; - - IntSet result = getResult(); - - procedure.execute(graph, result); - - return result; - - } - - @Override - public void recompute(ReadGraphImpl graph) throws DatabaseException { - - compute(graph, new InternalProcedure() { - - @Override - public void exception(ReadGraphImpl graph, Throwable t) { - throw new Error("Error in recompute.", t); - } - - @Override - public void execute(ReadGraphImpl graph, IntSet i) { - } - - }); - - } - @Override public int type() { return RequestFlags.IMMEDIATE_UPDATE; } - - - @Override - boolean isImmutable(ReadGraphImpl graph) { - return graph.processor.isImmutable(id); - } }