X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FTypeHierarchy.java;h=cc8ee07ded8fc2937bfa43926c6cb9e4c2b0b254;hb=de8b6e194da6d56c410101d9c72763078b0e8717;hp=ad4581bb6a3e6045c877193dd9aecf8e6c316fd7;hpb=880a8a4927805afbbf47005a807cef3f39406866;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/TypeHierarchy.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/TypeHierarchy.java index ad4581bb6..cc8ee07de 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/TypeHierarchy.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/TypeHierarchy.java @@ -18,7 +18,7 @@ import org.simantics.db.procedure.ListenerBase; import gnu.trove.procedure.TIntProcedure; -final public class TypeHierarchy extends UnaryQuery> { +final public class TypeHierarchy extends UnaryQueryP { TypeHierarchy(final int resource) { super(resource); @@ -33,8 +33,14 @@ final public class TypeHierarchy extends UnaryQuery> { provider.cache.remove(this); } - //@Override - public IntSet compute(ReadGraphImpl graph, final InternalProcedure procedure) throws DatabaseException { + @Override + public void compute(final ReadGraphImpl graph, final InternalProcedure procedure) throws DatabaseException { + computeForEach(graph, id, this, procedure); + } + + public static IntSet computeForEach(ReadGraphImpl graph, int id, TypeHierarchy entry, final InternalProcedure procedure_) throws DatabaseException { + + InternalProcedure procedure = entry != null ? entry : procedure_; QueryProcessor processor = graph.processor; @@ -48,15 +54,12 @@ final public class TypeHierarchy extends UnaryQuery> { } }; - QueryCache.runnerSuperTypes(graph, id, TypeHierarchy.this, null, new InternalProcedure() { + QueryCache.runnerSuperTypes(graph, id, entry, null, new InternalProcedure() { @Override public void execute(ReadGraphImpl graph, IntSet types) throws DatabaseException { - types.forEach(addToResult); - addOrSet(graph, result, processor); procedure.execute(graph, result); - } @Override @@ -66,65 +69,15 @@ final public class TypeHierarchy extends UnaryQuery> { }); - return result; - - } - - @Override - public String toString() { - return "TypeHierarchy[" + id + "]"; - } - - private void addOrSet(ReadGraphImpl graph, final IntSet value, QueryProcessor provider) { - - assert(!isReady()); - - synchronized(this) { - - value.trim(); - setResult(value); - setReady(); - - } - - } - - @Override - public Object performFromCache(ReadGraphImpl graph, InternalProcedure procedure) throws DatabaseException { - - assert(isReady()); - - if(handleException(graph, procedure)) return null; - - IntSet result = getResult(); - - procedure.execute(graph, result); + if(entry != null) entry.performFromCache(graph, procedure_); return result; - - } - - @Override - public void recompute(ReadGraphImpl graph) throws DatabaseException { - - compute(graph, new InternalProcedure() { - - @Override - public void execute(ReadGraphImpl graph, IntSet result) { - } - - @Override - public void exception(ReadGraphImpl graph, Throwable t) { - new Error("Error in recompute.", t).printStackTrace(); - } - }); - } @Override - boolean isImmutable(ReadGraphImpl graph) { - return graph.processor.isImmutable(id); + public String toString() { + return "TypeHierarchy[" + id + "]"; } }