From: Antti Villberg Date: Tue, 3 Apr 2018 07:15:13 +0000 (+0300) Subject: Multiple simultaneous readers X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;ds=sidebyside;h=1e957fc9da518f3bef8a2c19cad72772087e1b6a;p=simantics%2Fplatform.git Multiple simultaneous readers refs #6961 Change-Id: If2374874965c23d07a2fbe1f0075c515e1e12d5c --- diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/primitiverequest/IsInstanceOf.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/primitiverequest/IsInstanceOf.java index 63a5ddcb3..d121839ed 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/primitiverequest/IsInstanceOf.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/primitiverequest/IsInstanceOf.java @@ -11,20 +11,20 @@ *******************************************************************************/ package org.simantics.db.common.primitiverequest; -import org.simantics.db.AsyncReadGraph; +import org.simantics.db.ReadGraph; import org.simantics.db.Resource; -import org.simantics.db.common.request.ResourceAsyncRead2; -import org.simantics.db.procedure.AsyncProcedure; +import org.simantics.db.common.request.ResourceRead2; +import org.simantics.db.exception.DatabaseException; -final public class IsInstanceOf extends ResourceAsyncRead2 { +final public class IsInstanceOf extends ResourceRead2 { public IsInstanceOf(Resource resource, Resource resource2) { super(resource, resource2); } - @Override - public void perform(AsyncReadGraph graph, AsyncProcedure procedure) { - graph.forIsInstanceOf(resource, resource2, procedure); - } + @Override + public Boolean perform(ReadGraph graph) throws DatabaseException { + return graph.isInstanceOf(resource2, resource2); + } } diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/PossibleTypedParent.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/PossibleTypedParent.java index 668791821..bae974e3e 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/PossibleTypedParent.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/PossibleTypedParent.java @@ -12,59 +12,77 @@ package org.simantics.db.common.request; import org.simantics.db.AsyncReadGraph; +import org.simantics.db.ReadGraph; import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; import org.simantics.db.procedure.AsyncProcedure; import org.simantics.layer0.Layer0; -public class PossibleTypedParent extends ResourceAsyncRead2 { +public class PossibleTypedParent extends ResourceRead2 { public PossibleTypedParent(Resource resource, Resource type) { super(resource, type); } - @Override - public void perform(AsyncReadGraph graph, final AsyncProcedure procedure) { - - final Layer0 l0 = graph.getService(Layer0.class); - - graph.forIsInstanceOf(resource, resource2, new AsyncProcedure() { - - @Override - public void execute(AsyncReadGraph graph, Boolean isInstance) { - if(isInstance) { - procedure.execute(graph, resource); - } else { - - graph.forPossibleObject(resource, l0.PartOf, new AsyncProcedure() { - - @Override - public void execute(AsyncReadGraph graph, final Resource parent) { - if(parent == null) { - procedure.execute(graph, null); - } else { - graph.asyncRequest(new PossibleTypedParent(parent, resource2), procedure); - } - - } - - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - procedure.exception(graph, throwable); - } - - }); - - } - } - - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - procedure.exception(graph, throwable); + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + if(graph.isInstanceOf(resource, resource2)) { + return resource; + } else { + Layer0 L0 = Layer0.getInstance(graph); + Resource possibleParent = graph.getPossibleObject(resource, L0.PartOf); + if(possibleParent != null) { + return graph.syncRequest(new PossibleTypedParent(possibleParent, resource2)); + } else { + return null; } - }); - - + } } +// @Override +// public void perform(AsyncReadGraph graph, final AsyncProcedure procedure) { +// +// final Layer0 l0 = graph.getService(Layer0.class); +// +// graph.forIsInstanceOf(resource, resource2, new AsyncProcedure() { +// +// @Override +// public void execute(AsyncReadGraph graph, Boolean isInstance) { +// if(isInstance) { +// procedure.execute(graph, resource); +// } else { +// +// graph.forPossibleObject(resource, l0.PartOf, new AsyncProcedure() { +// +// @Override +// public void execute(AsyncReadGraph graph, final Resource parent) { +// +// if(parent == null) { +// procedure.execute(graph, null); +// } else { +// graph.asyncRequest(new PossibleTypedParent(parent, resource2), procedure); +// } +// +// } +// +// @Override +// public void exception(AsyncReadGraph graph, Throwable throwable) { +// procedure.exception(graph, throwable); +// } +// +// }); +// +// } +// } +// +// @Override +// public void exception(AsyncReadGraph graph, Throwable throwable) { +// procedure.exception(graph, throwable); +// } +// }); +// +// +// } + } diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java index 3337e55b8..25438ef1e 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java @@ -137,6 +137,7 @@ import org.simantics.db.impl.procedure.CallWrappedSingleQueryProcedure4; import org.simantics.db.impl.procedure.ResultCallWrappedQueryProcedure4; import org.simantics.db.impl.procedure.ResultCallWrappedSingleQueryProcedure4; import org.simantics.db.impl.query.CacheEntry; +import org.simantics.db.impl.query.QueryCache; import org.simantics.db.impl.query.QueryProcessor; import org.simantics.db.impl.query.QuerySupport; import org.simantics.db.impl.query.TripleIntProcedure; @@ -1896,7 +1897,9 @@ public class ReadGraphImpl implements ReadGraph { assert (request != null); - return processor.query(this, request, parent, null, null); + return QueryCache.resultReadEntry(this, request, parent, null, null); + + //return processor.query(this, request, parent, null, null); // if (parent != null) { // @@ -1948,7 +1951,9 @@ public class ReadGraphImpl implements ReadGraph { ListenerBase listener = procedure != null ? getListenerBase(procedure) : null; - return processor.query(this, request, parent, procedure, listener); + return QueryCache.resultReadEntry(this, request, parent, listener, procedure); + +// return processor.query(this, request, parent, procedure, listener); // if (parent != null || listener != null) { @@ -2079,7 +2084,9 @@ public class ReadGraphImpl implements ReadGraph { final ResultCallWrappedSingleQueryProcedure4 wrapper = new ResultCallWrappedSingleQueryProcedure4( procedure, request); - processor.query(this, request, parent, wrapper, listener); + QueryCache.runnerAsyncReadEntry(this, request, parent, listener, wrapper); + + //processor.query(this, request, parent, wrapper, listener); return wrapper.getResult(); @@ -2147,35 +2154,12 @@ public class ReadGraphImpl implements ReadGraph { assert (request != null); ListenerBase listener = getListenerBase(procedure); + assert(listener == null); - final ResultCallWrappedSingleQueryProcedure4 wrapper = new ResultCallWrappedSingleQueryProcedure4( - procedure, request); - - processor.query(this, request, parent, wrapper, listener); +// final ResultCallWrappedSingleQueryProcedure4 wrapper = new ResultCallWrappedSingleQueryProcedure4( +// procedure, request); -// if (parent != null || listener != null || ((request.getFlags() & RequestFlags.SCHEDULE) > 0)) { -// -// -// } else { -// -// try { -// -//// final ReadGraphImpl newGraph = newSync(); -// processor.tryQuery(this, request, procedure); -//// newGraph.waitAsync(null); -// waitAsyncProcedure(procedure); -// -// } catch (Throwable t) { -// if(Development.DEVELOPMENT) { -// if(Development.getProperty(DevelopmentKeys.WRITEGRAPH_EXCEPTION_STACKTRACES, Bindings.BOOLEAN)) { -// t.printStackTrace(); -// } -// } -// procedure.exception(this, t); -// waitAsyncProcedure(procedure); -// } -// -// } + QueryCache.runnerAsyncReadEntry(this, request, parent, listener, procedure); } @@ -5408,7 +5392,8 @@ public class ReadGraphImpl implements ReadGraph { if (parent != null || listener != null) { try { - processor.query(this, request, parent, procedure,listener); + QueryCache.runnerReadEntry(this, request, parent, listener, procedure); + //processor.query(this, request, parent, procedure,listener); } catch (DatabaseException e) { Logger.defaultLogError(e); // This throwable has already been transferred to procedure at this point - do nothing about it @@ -5518,7 +5503,8 @@ public class ReadGraphImpl implements ReadGraph { if (parent != null || listener != null) { try { - processor.query(this, request, parent, procedure, listener); + QueryCache.runnerAsyncReadEntry(this, request, parent, listener, procedure); + //processor.query(this, request, parent, procedure, listener); } catch (DatabaseException e) { Logger.defaultLogError(e); } diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphSupport.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphSupport.java index 4f8dfd2ee..d8fda07b7 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphSupport.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphSupport.java @@ -85,9 +85,9 @@ public interface ReadGraphSupport { void forHasValue(ReadGraphImpl graph, Resource subject, AsyncProcedure procedure); void forOrderedSet(ReadGraphImpl graph, Resource subject, AsyncMultiProcedure procedure); - T query(ReadGraphImpl graph, Read request, CacheEntry parent, AsyncProcedure procedure, ListenerBase listener) throws DatabaseException; + // T query(ReadGraphImpl graph, Read request, CacheEntry parent, AsyncProcedure procedure, ListenerBase listener) throws DatabaseException; void query(ReadGraphImpl graph, MultiRead request, CacheEntry parent, AsyncMultiProcedure procedure, ListenerBase listener); - void query(ReadGraphImpl graph, AsyncRead request, CacheEntry parent, AsyncProcedure procedure, ListenerBase listener) throws DatabaseException; +// void query(ReadGraphImpl graph, AsyncRead request, CacheEntry parent, AsyncProcedure procedure, ListenerBase listener) throws DatabaseException; void query(ReadGraphImpl graph, AsyncMultiRead request, CacheEntry parent, AsyncMultiProcedure procedure, ListenerBase listener); void query(ReadGraphImpl graph, ExternalRead request, CacheEntry parent, Procedure procedure, ListenerBase listener); diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java index 767a82bd5..8e6cbd145 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java @@ -144,9 +144,85 @@ final public class AsyncReadEntry extends CacheEntryBase> { @Override public Object compute(ReadGraphImpl graph, AsyncProcedure procedure) throws DatabaseException { - return graph.processor.cache.performQuery(graph, request, this, procedure); + + ReadGraphImpl queryGraph = graph.withParent(this); + + request.perform(queryGraph, new AsyncProcedure() { + + @Override + public void execute(AsyncReadGraph returnGraph, T result) { + ReadGraphImpl impl = (ReadGraphImpl)returnGraph; + AsyncReadEntry.this.addOrSet(graph, result); + try { + procedure.execute(graph, result); + } catch (Throwable t) { + t.printStackTrace(); + } + // parentBarrier.dec(query); + } + + @Override + public void exception(AsyncReadGraph returnGraph, Throwable t) { + ReadGraphImpl impl = (ReadGraphImpl)returnGraph; + // AsyncReadGraph resumeGraph = finalParentGraph.newAsync(); + AsyncReadEntry.this.except(graph, t); + try { + procedure.exception(graph, t); + } catch (Throwable t2) { + t2.printStackTrace(); + } + // parentBarrier.dec(query); + } + + @Override + public String toString() { + return procedure.toString(); + } + + }); + + return getResult(); + + } + + public static void computeForEach(ReadGraphImpl parentGraph, AsyncRead request, AsyncReadEntry entry, AsyncProcedure procedure) throws DatabaseException { + + ReadGraphImpl queryGraph = parentGraph.withParent(entry); + + request.perform(queryGraph, new AsyncProcedure() { + + @Override + public void execute(AsyncReadGraph returnGraph, T result) { + ReadGraphImpl impl = (ReadGraphImpl)returnGraph; + if(entry != null) entry.addOrSet(parentGraph, result); + try { + procedure.execute(parentGraph, result); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override + public void exception(AsyncReadGraph returnGraph, Throwable t) { + ReadGraphImpl impl = (ReadGraphImpl)returnGraph; + if(entry != null) entry.except(parentGraph, t); + try { + procedure.exception(parentGraph, t); + } catch (Throwable t2) { + t2.printStackTrace(); + } + } + + @Override + public String toString() { + return procedure.toString(); + } + + }); + } + @Override public String toString() { if(isDiscarded()) return "DISCARDED " + request.toString(); diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CodeGen.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CodeGen.java index 3bceb1272..857d93487 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CodeGen.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CodeGen.java @@ -44,7 +44,7 @@ public class CodeGen { public void generateRunner(StringBuilder content, String clazz, String[] signature, boolean shortcut) { - line(content, "static void runner" + clazz + "(ReadGraphImpl graph, " + signature[0] + ", CacheEntry parent, ListenerBase listener, " + signature[4] + " procedure) throws DatabaseException {"); + line(content, "public static void runner" + clazz + "(ReadGraphImpl graph, " + signature[0] + ", CacheEntry parent, ListenerBase listener, " + signature[4] + " procedure) throws DatabaseException {"); if(shortcut) { line(content, " if(parent == null && listener == null) {"); line(content, " " + clazz + ".computeForEach(graph, " + signature[1] + ", null, procedure);"); @@ -155,16 +155,16 @@ public class CodeGen { generateQuery(content, "DirectPredicates", signatureR1IntSet, true); generateQuery(content, "Predicates", signatureR1IntSet, true); generateQuery(content, "ReadEntry", signatureRead, true); + generateQuery(content, "AsyncReadEntry", signatureAsyncRead, true); generateQuery(content, "Types", signatureR1IntSet, true); + generateQuery(content, "NamespaceIndex", signatureID2, true); generateQuery(content, "AssertedStatements", signatureR2TIP, false); - generateQuery(content, "NamespaceIndex", signatureID2, false); generateQuery(content, "AssertedPredicates", signatureR1IP, false); generateQuery(content, "DirectSuperRelations", signatureR1IP, false); generateQuery(content, "SuperTypes", signatureR1IntSet, false); generateQuery(content, "TypeHierarchy", signatureR1IntSet, false); generateQuery(content, "SuperRelations", signatureR1IntSet, false); - generateQuery(content, "AsyncReadEntry", signatureAsyncRead, false); generateQuery(content, "MultiReadEntry", signatureMultiRead, false); generateQuery(content, "AsyncMultiReadEntry", signatureAsyncMultiRead, false); generateQuery(content, "ExternalReadEntry", signatureExternalRead, false); diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/NamespaceIndex.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/NamespaceIndex.java index e55e99c61..884f3f6d4 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/NamespaceIndex.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/NamespaceIndex.java @@ -33,32 +33,30 @@ final public class NamespaceIndex extends StringQuery> procedure) throws DatabaseException { + final static private void index(ReadGraphImpl graph, int root, NamespaceIndex entry, final InternalProcedure> procedure) throws DatabaseException { if(root == 0) { - add2(graph, null); + if(entry != null) + entry.add2(graph, null); procedure.execute(graph, null); // System.err.println("NamespaceIndex[" + id + "]->null"); return; } - final int consistsOf = provider.getConsistsOf(); - final int hasName = provider.getHasName(); + QueryProcessor processor = graph.processor; + + final int consistsOf = processor.getConsistsOf(); + final int hasName = processor.getHasName(); final TObjectIntHashMap result = new TObjectIntHashMap(); - QueryCache.runnerObjects(graph, root, consistsOf, graph.parent, null, new SyncIntProcedure() { + QueryCache.runnerObjects(graph, root, consistsOf, entry, null, new SyncIntProcedure() { @Override public void run(ReadGraphImpl graph) throws DatabaseException { - if(isPending()) { - add2(graph, result); - procedure.execute(graph, result); -// System.err.println("NamespaceIndex[" + id + "]->" + result.size()); - } else { - procedure.exception(graph, (Throwable)statusOrException); - } + if(entry != null) entry.add2(graph, result); + procedure.execute(graph, result); } @@ -74,14 +72,14 @@ final public class NamespaceIndex extends StringQuery() { + QueryCache.runnerValueQuery(graph, i, entry, null, new InternalProcedure() { @Override public void execute(ReadGraphImpl graph, byte[] value) throws DatabaseException { @@ -112,7 +110,7 @@ final public class NamespaceIndex extends StringQuery> procedure) throws DatabaseException { + computeForEach(graph, id, this, procedure); + return getResult(); + } + + public static void computeForEach(ReadGraphImpl graph, final String id, final NamespaceIndex entry, final InternalProcedure> procedure) throws DatabaseException { QueryProcessor processor = graph.processor; // System.err.println("NamespaceIndex " + id); if("http://".equals(id) || "http:/".equals(id)) { - index(graph, processor, processor.getRootLibrary(), procedure); + index(graph, processor.getRootLibrary(), entry, procedure); } else { final String[] parts = URIStringUtils.splitURI(id); if(parts != null) { - QueryCache.runnerNamespaceIndex(graph, parts[0], this, null, new InternalProcedure>() { + QueryCache.runnerNamespaceIndex(graph, parts[0], entry, null, new InternalProcedure>() { @Override public void execute(ReadGraphImpl graph, TObjectIntHashMap index) throws DatabaseException { if(index != null) { - index(graph, processor, index.get(parts[1]), procedure); + index(graph, index.get(parts[1]), entry, procedure); } else { - add2(graph, null); + if(entry != null) entry.add2(graph, null); procedure.execute(graph, null); // System.err.println("NamespaceIndex[" + id + "]->null"); } @@ -169,21 +173,19 @@ final public class NamespaceIndex extends StringQuerynull"); } } - return getResult(); - } @Override @@ -191,12 +193,6 @@ final public class NamespaceIndex extends StringQuery result) { - - throw new Error("Not possible!"); - - } - private void add2(ReadGraphImpl graph, TObjectIntHashMap result) { if(!isPending()) { @@ -205,22 +201,12 @@ final public class NamespaceIndex extends StringQuery>> p = null; - synchronized(this) { setResult(result); setReady(); -// p = procs; -// procs = null; } - -// if(p != null) { -// -// for(InternalProcedure> proc : p) proc.execute(graph, result); -// -// } } diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCache.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCache.java index 4be12da47..dbd0068c3 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCache.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCache.java @@ -47,7 +47,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerObjects(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { + public static void runnerObjects(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { if(parent == null && listener == null) { Objects.computeForEach(graph, r1,r2, null, procedure); return; @@ -89,7 +89,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerStatements(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, TripleIntProcedure procedure) throws DatabaseException { + public static void runnerStatements(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, TripleIntProcedure procedure) throws DatabaseException { if(parent == null && listener == null) { Statements.computeForEach(graph, r1,r2, null, procedure); return; @@ -131,7 +131,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerDirectObjects(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { + public static void runnerDirectObjects(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { if(parent == null && listener == null) { DirectObjects.computeForEach(graph, r1,r2, null, procedure); return; @@ -173,7 +173,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerRelationInfoQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + public static void runnerRelationInfoQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { if(parent == null && listener == null) { RelationInfoQuery.computeForEach(graph, r, null, procedure); return; @@ -215,7 +215,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerURIToResource(ReadGraphImpl graph, String id, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + public static void runnerURIToResource(ReadGraphImpl graph, String id, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { if(parent == null && listener == null) { URIToResource.computeForEach(graph, id, null, procedure); return; @@ -257,7 +257,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerValueQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + public static void runnerValueQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { if(parent == null && listener == null) { ValueQuery.computeForEach(graph, r, null, procedure); return; @@ -299,7 +299,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerOrderedSet(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { + public static void runnerOrderedSet(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { if(parent == null && listener == null) { OrderedSet.computeForEach(graph, r, null, procedure); return; @@ -341,7 +341,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerPrincipalTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { + public static void runnerPrincipalTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { if(parent == null && listener == null) { PrincipalTypes.computeForEach(graph, r, null, procedure); return; @@ -383,7 +383,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerDirectPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + public static void runnerDirectPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { if(parent == null && listener == null) { DirectPredicates.computeForEach(graph, r, null, procedure); return; @@ -425,7 +425,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + public static void runnerPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { if(parent == null && listener == null) { Predicates.computeForEach(graph, r, null, procedure); return; @@ -467,7 +467,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerReadEntry(ReadGraphImpl graph, Read r, CacheEntry parent, ListenerBase listener, AsyncProcedure procedure) throws DatabaseException { + public static void runnerReadEntry(ReadGraphImpl graph, Read r, CacheEntry parent, ListenerBase listener, AsyncProcedure procedure) throws DatabaseException { if(parent == null && listener == null) { ReadEntry.computeForEach(graph, r, null, procedure); return; @@ -483,6 +483,48 @@ public class QueryCache extends QueryCacheBase { } } + AsyncReadEntry getOrCreateAsyncReadEntry(AsyncRead r) throws DatabaseException { + AsyncReadEntry existing = null; + synchronized(asyncReadEntryMap) { + existing = (AsyncReadEntry)asyncReadEntryMap.get(r); + if(existing == null) { + existing = new AsyncReadEntry(r); + existing.clearResult(querySupport); + existing.setPending(); + asyncReadEntryMap.put(id(r), existing); + return existing; + } + if(existing.requiresComputation()) { + existing.setPending(); + return existing; + } + } + if(existing.isPending()) waitPending(existing); + return existing; + } + + void remove(AsyncReadEntry entry) { + synchronized(asyncReadEntryMap) { + asyncReadEntryMap.remove(entry.request); + } + } + + public static void runnerAsyncReadEntry(ReadGraphImpl graph, AsyncRead r, CacheEntry parent, ListenerBase listener, AsyncProcedure procedure) throws DatabaseException { + if(parent == null && listener == null) { + AsyncReadEntry.computeForEach(graph, r, null, procedure); + return; + } + QueryCache cache = graph.processor.cache; + if(procedure == null) procedure = emptyProcedureAsyncReadEntry; + AsyncReadEntry entry = (AsyncReadEntry)cache.getOrCreateAsyncReadEntry(r); + ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); + if(entry.isReady()) entry.performFromCache(graph, procedure); + else { + AsyncReadEntry.computeForEach(graph, r, entry, procedure); + if(listenerEntry != null) cache.primeListenerEntry(listenerEntry, entry.getResult()); + } + } + Types getOrCreateTypes(int r) throws DatabaseException { Types existing = null; synchronized(typesMap) { @@ -509,7 +551,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + public static void runnerTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { if(parent == null && listener == null) { Types.computeForEach(graph, r, null, procedure); return; @@ -525,15 +567,15 @@ public class QueryCache extends QueryCacheBase { } } - AssertedStatements getOrCreateAssertedStatements(int r1, int r2) throws DatabaseException { - AssertedStatements existing = null; - synchronized(assertedStatementsMap) { - existing = (AssertedStatements)assertedStatementsMap.get(r1,r2); + NamespaceIndex getOrCreateNamespaceIndex(String id) throws DatabaseException { + NamespaceIndex existing = null; + synchronized(namespaceIndexMap) { + existing = (NamespaceIndex)namespaceIndexMap.get(id); if(existing == null) { - existing = new AssertedStatements(r1,r2); + existing = new NamespaceIndex(id); existing.clearResult(querySupport); existing.setPending(); - assertedStatementsMap.put(keyR2(r1,r2), existing); + namespaceIndexMap.put(keyID(id), existing); return existing; } if(existing.requiresComputation()) { @@ -545,33 +587,37 @@ public class QueryCache extends QueryCacheBase { return existing; } - void remove(AssertedStatements entry) { - synchronized(assertedStatementsMap) { - assertedStatementsMap.remove(entry.id); + void remove(NamespaceIndex entry) { + synchronized(namespaceIndexMap) { + namespaceIndexMap.remove(entry.id); } } - static void runnerAssertedStatements(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, TripleIntProcedure procedure) throws DatabaseException { + public static void runnerNamespaceIndex(ReadGraphImpl graph, String id, CacheEntry parent, ListenerBase listener, InternalProcedure> procedure) throws DatabaseException { + if(parent == null && listener == null) { + NamespaceIndex.computeForEach(graph, id, null, procedure); + return; + } QueryCache cache = graph.processor.cache; - if(procedure == null) procedure = emptyProcedureAssertedStatements; - AssertedStatements entry = (AssertedStatements)cache.getOrCreateAssertedStatements(r1,r2); + if(procedure == null) procedure = emptyProcedureNamespaceIndex; + NamespaceIndex entry = (NamespaceIndex)cache.getOrCreateNamespaceIndex(id); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); if(entry.isReady()) entry.performFromCache(graph, procedure); else { - entry.compute(graph, procedure); + NamespaceIndex.computeForEach(graph, id, entry, procedure); if(listenerEntry != null) cache.primeListenerEntry(listenerEntry, entry.getResult()); } } - NamespaceIndex getOrCreateNamespaceIndex(String id) throws DatabaseException { - NamespaceIndex existing = null; - synchronized(namespaceIndexMap) { - existing = (NamespaceIndex)namespaceIndexMap.get(id); + AssertedStatements getOrCreateAssertedStatements(int r1, int r2) throws DatabaseException { + AssertedStatements existing = null; + synchronized(assertedStatementsMap) { + existing = (AssertedStatements)assertedStatementsMap.get(r1,r2); if(existing == null) { - existing = new NamespaceIndex(id); + existing = new AssertedStatements(r1,r2); existing.clearResult(querySupport); existing.setPending(); - namespaceIndexMap.put(keyID(id), existing); + assertedStatementsMap.put(keyR2(r1,r2), existing); return existing; } if(existing.requiresComputation()) { @@ -583,16 +629,16 @@ public class QueryCache extends QueryCacheBase { return existing; } - void remove(NamespaceIndex entry) { - synchronized(namespaceIndexMap) { - namespaceIndexMap.remove(entry.id); + void remove(AssertedStatements entry) { + synchronized(assertedStatementsMap) { + assertedStatementsMap.remove(entry.id); } } - static void runnerNamespaceIndex(ReadGraphImpl graph, String id, CacheEntry parent, ListenerBase listener, InternalProcedure> procedure) throws DatabaseException { + public static void runnerAssertedStatements(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, TripleIntProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; - if(procedure == null) procedure = emptyProcedureNamespaceIndex; - NamespaceIndex entry = (NamespaceIndex)cache.getOrCreateNamespaceIndex(id); + if(procedure == null) procedure = emptyProcedureAssertedStatements; + AssertedStatements entry = (AssertedStatements)cache.getOrCreateAssertedStatements(r1,r2); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); if(entry.isReady()) entry.performFromCache(graph, procedure); else { @@ -627,7 +673,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerAssertedPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { + public static void runnerAssertedPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureAssertedPredicates; AssertedPredicates entry = (AssertedPredicates)cache.getOrCreateAssertedPredicates(r); @@ -665,7 +711,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerDirectSuperRelations(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { + public static void runnerDirectSuperRelations(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureDirectSuperRelations; DirectSuperRelations entry = (DirectSuperRelations)cache.getOrCreateDirectSuperRelations(r); @@ -703,7 +749,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerSuperTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + public static void runnerSuperTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureSuperTypes; SuperTypes entry = (SuperTypes)cache.getOrCreateSuperTypes(r); @@ -741,7 +787,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerTypeHierarchy(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + public static void runnerTypeHierarchy(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureTypeHierarchy; TypeHierarchy entry = (TypeHierarchy)cache.getOrCreateTypeHierarchy(r); @@ -779,7 +825,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerSuperRelations(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + public static void runnerSuperRelations(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureSuperRelations; SuperRelations entry = (SuperRelations)cache.getOrCreateSuperRelations(r); @@ -791,44 +837,6 @@ public class QueryCache extends QueryCacheBase { } } - AsyncReadEntry getOrCreateAsyncReadEntry(AsyncRead r) throws DatabaseException { - AsyncReadEntry existing = null; - synchronized(asyncReadEntryMap) { - existing = (AsyncReadEntry)asyncReadEntryMap.get(r); - if(existing == null) { - existing = new AsyncReadEntry(r); - existing.clearResult(querySupport); - existing.setPending(); - asyncReadEntryMap.put(id(r), existing); - return existing; - } - if(existing.requiresComputation()) { - existing.setPending(); - return existing; - } - } - if(existing.isPending()) waitPending(existing); - return existing; - } - - void remove(AsyncReadEntry entry) { - synchronized(asyncReadEntryMap) { - asyncReadEntryMap.remove(entry.request); - } - } - - static void runnerAsyncReadEntry(ReadGraphImpl graph, AsyncRead r, CacheEntry parent, ListenerBase listener, AsyncProcedure procedure) throws DatabaseException { - QueryCache cache = graph.processor.cache; - if(procedure == null) procedure = emptyProcedureAsyncReadEntry; - AsyncReadEntry entry = (AsyncReadEntry)cache.getOrCreateAsyncReadEntry(r); - ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); - if(entry.isReady()) entry.performFromCache(graph, procedure); - else { - entry.compute(graph, procedure); - if(listenerEntry != null) cache.primeListenerEntry(listenerEntry, entry.getResult()); - } - } - MultiReadEntry getOrCreateMultiReadEntry(MultiRead r) throws DatabaseException { MultiReadEntry existing = null; synchronized(multiReadEntryMap) { @@ -855,7 +863,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerMultiReadEntry(ReadGraphImpl graph, MultiRead r, CacheEntry parent, ListenerBase listener, AsyncMultiProcedure procedure) throws DatabaseException { + public static void runnerMultiReadEntry(ReadGraphImpl graph, MultiRead r, CacheEntry parent, ListenerBase listener, AsyncMultiProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureMultiReadEntry; MultiReadEntry entry = (MultiReadEntry)cache.getOrCreateMultiReadEntry(r); @@ -893,7 +901,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerAsyncMultiReadEntry(ReadGraphImpl graph, AsyncMultiRead r, CacheEntry parent, ListenerBase listener, AsyncMultiProcedure procedure) throws DatabaseException { + public static void runnerAsyncMultiReadEntry(ReadGraphImpl graph, AsyncMultiRead r, CacheEntry parent, ListenerBase listener, AsyncMultiProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureAsyncMultiReadEntry; AsyncMultiReadEntry entry = (AsyncMultiReadEntry)cache.getOrCreateAsyncMultiReadEntry(r); @@ -931,7 +939,7 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerExternalReadEntry(ReadGraphImpl graph, ExternalRead r, CacheEntry parent, ListenerBase listener, AsyncProcedure procedure) throws DatabaseException { + public static void runnerExternalReadEntry(ReadGraphImpl graph, ExternalRead r, CacheEntry parent, ListenerBase listener, AsyncProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureExternalReadEntry; ExternalReadEntry entry = (ExternalReadEntry)cache.getOrCreateExternalReadEntry(r); diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java index 4056f060b..e2737f891 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java @@ -100,64 +100,64 @@ public class QueryCacheBase { listeners = new THashMap>(10, 0.75f); } - public Object performQuery(ReadGraphImpl parentGraph, final AsyncRead query, final CacheEntryBase entry_, AsyncProcedure procedure_) throws DatabaseException { - - AsyncReadEntry entry = (AsyncReadEntry)entry_; - AsyncProcedure procedure = (AsyncProcedure)procedure_; - - ReadGraphImpl queryGraph = parentGraph.withParent(entry_); - - try { - - query.perform(queryGraph, new AsyncProcedure() { - - @Override - public void execute(AsyncReadGraph returnGraph, T result) { - ReadGraphImpl impl = (ReadGraphImpl)returnGraph; - entry.addOrSet(parentGraph, result); - try { - procedure.execute(parentGraph, result); - } catch (Throwable t) { - t.printStackTrace(); - } -// parentBarrier.dec(query); - } - - @Override - public void exception(AsyncReadGraph returnGraph, Throwable t) { - ReadGraphImpl impl = (ReadGraphImpl)returnGraph; -// AsyncReadGraph resumeGraph = finalParentGraph.newAsync(); - entry.except(parentGraph, t); - try { - procedure.exception(parentGraph, t); - } catch (Throwable t2) { - t2.printStackTrace(); - } -// parentBarrier.dec(query); - } - - @Override - public String toString() { - return procedure.toString(); - } - - }); - - } catch (Throwable t) { - - entry.except(t); - try { - procedure.exception(parentGraph, t); - } catch (Throwable t2) { - t2.printStackTrace(); - } -// parentBarrier.dec(query); - - } - - return null; - - } +// public Object performQuery(ReadGraphImpl parentGraph, final AsyncRead query, final CacheEntryBase entry_, AsyncProcedure procedure_) throws DatabaseException { +// +// AsyncReadEntry entry = (AsyncReadEntry)entry_; +// AsyncProcedure procedure = (AsyncProcedure)procedure_; +// +// ReadGraphImpl queryGraph = parentGraph.withParent(entry_); +// +// try { +// +// query.perform(queryGraph, new AsyncProcedure() { +// +// @Override +// public void execute(AsyncReadGraph returnGraph, T result) { +// ReadGraphImpl impl = (ReadGraphImpl)returnGraph; +// entry.addOrSet(parentGraph, result); +// try { +// procedure.execute(parentGraph, result); +// } catch (Throwable t) { +// t.printStackTrace(); +// } +//// parentBarrier.dec(query); +// } +// +// @Override +// public void exception(AsyncReadGraph returnGraph, Throwable t) { +// ReadGraphImpl impl = (ReadGraphImpl)returnGraph; +//// AsyncReadGraph resumeGraph = finalParentGraph.newAsync(); +// entry.except(parentGraph, t); +// try { +// procedure.exception(parentGraph, t); +// } catch (Throwable t2) { +// t2.printStackTrace(); +// } +//// parentBarrier.dec(query); +// } +// +// @Override +// public String toString() { +// return procedure.toString(); +// } +// +// }); +// +// } catch (Throwable t) { +// +// entry.except(t); +// try { +// procedure.exception(parentGraph, t); +// } catch (Throwable t2) { +// t2.printStackTrace(); +// } +//// parentBarrier.dec(query); +// +// } +// +// return null; +// +// } // public Object performQuery(ReadGraphImpl parentGraph, final Read query, final CacheEntryBase entry_, AsyncProcedure procedure_) throws DatabaseException { // diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryProcessor.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryProcessor.java index a2fff0515..a6c987a9d 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryProcessor.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryProcessor.java @@ -524,18 +524,18 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap } // Fall back to using the fixed builtins. - result = querySupport.getBuiltin(id); - if (result != 0) { - procedure.execute(graph, result); - return; - } +// result = querySupport.getBuiltin(id); +// if (result != 0) { +// procedure.execute(graph, result); +// return; +// } - try { - result = querySupport.getRandomAccessReference(id); - } catch (ResourceNotFoundException e) { - procedure.exception(graph, e); - return; - } +// try { +// result = querySupport.getRandomAccessReference(id); +// } catch (ResourceNotFoundException e) { +// procedure.exception(graph, e); +// return; +// } if (result != 0) { procedure.execute(graph, result); @@ -593,12 +593,12 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap QueryCache.runnerExternalReadEntry(graph, query, parent, listener, procedure); } - @Override - public T query(final ReadGraphImpl graph, final Read query, final CacheEntry parent, final AsyncProcedure procedure, final ListenerBase listener) throws DatabaseException { - - return QueryCache.resultReadEntry(graph, query, parent, listener, procedure); - - } +// @Override +// public T query(final ReadGraphImpl graph, final Read query, final CacheEntry parent, final AsyncProcedure procedure, final ListenerBase listener) throws DatabaseException { +// +// return QueryCache.resultReadEntry(graph, query, parent, listener, procedure); +// +// } public void queryMultiRead(final ReadGraphImpl graph, final MultiRead query, final CacheEntry parent, final ListenerBase listener, final AsyncMultiProcedure procedure) throws DatabaseException { @@ -1340,7 +1340,7 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap CacheEntry entry = e.entry; -// System.err.println("updateQuery " + entry); + System.err.println("updateQuery " + entry); /* * If the dependency graph forms a DAG, some entries are inserted in the @@ -3393,37 +3393,18 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap assert(procedure != null); final ListenerBase listener = getListenerBase(procedure); + assert(listener == null); InternalProcedure ip = new InternalProcedure() { - AtomicBoolean first = new AtomicBoolean(true); - @Override public void execute(final ReadGraphImpl graph, IntSet set) { - try { - if(first.compareAndSet(true, false)) { - procedure.execute(graph, set); -// impl.state.barrier.dec(this); - } else { - procedure.execute(impl.newRestart(graph), set); - } - } catch (Throwable t2) { - Logger.defaultLogError(t2); - } + procedure.execute(graph, set); } @Override public void exception(ReadGraphImpl graph, Throwable t) { - try { - if(first.compareAndSet(true, false)) { - procedure.exception(graph, t); -// impl.state.barrier.dec(this); - } else { - procedure.exception(impl.newRestart(graph), t); - } - } catch (Throwable t2) { - Logger.defaultLogError(t2); - } + procedure.exception(graph, t); } }; @@ -3449,44 +3430,25 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap @Override final public void forRelationInfo(final ReadGraphImpl impl, final Resource subject, final AsyncProcedure procedure) { - + assert(subject != null); assert(procedure != null); final ListenerBase listener = getListenerBase(procedure); + assert(listener == null); try { QueryCache.runnerRelationInfoQuery(impl, querySupport.getId(subject), impl.parent, listener, new InternalProcedure() { - AtomicBoolean first = new AtomicBoolean(true); - @Override public void execute(final ReadGraphImpl graph, RelationInfo set) { - try { - if(first.compareAndSet(true, false)) { - procedure.execute(graph, set); -// impl.state.barrier.dec(); - } else { - procedure.execute(impl.newRestart(graph), set); - } - } catch (Throwable t2) { - Logger.defaultLogError(t2); - } + procedure.execute(graph, set); } @Override public void exception(ReadGraphImpl graph, Throwable t) { - try { - if(first.compareAndSet(true, false)) { - procedure.exception(graph, t); -// impl.state.barrier.dec("ReadGraphSupportImpl.1353"); - } else { - procedure.exception(impl.newRestart(graph), t); - } - } catch (Throwable t2) { - Logger.defaultLogError(t2); - } + procedure.exception(graph, t); } }); @@ -4195,15 +4157,15 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap } - @Override - final public void query(final ReadGraphImpl impl, final AsyncRead request, final CacheEntry parent, final AsyncProcedure procedure, ListenerBase listener) throws DatabaseException { - - assert(request != null); - assert(procedure != null); - - QueryCache.runnerAsyncReadEntry(impl, request, parent, listener, procedure); - - } +// @Override +// final public void query(final ReadGraphImpl impl, final AsyncRead request, final CacheEntry parent, final AsyncProcedure procedure, ListenerBase listener) throws DatabaseException { +// +// assert(request != null); +// assert(procedure != null); +// +// QueryCache.runnerAsyncReadEntry(impl, request, parent, listener, procedure); +// +// } // @Override // final public T tryQuery(final ReadGraphImpl graph, final Read request) throws DatabaseException { diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/ExternalRequest.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/ExternalRequest.java index b090c4a76..d7fa8b935 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/ExternalRequest.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/ExternalRequest.java @@ -25,13 +25,15 @@ class ExternalRequest extends ParametrizedPrimitiveRead() { + + AsyncProcedure ap = new AsyncProcedure() { @Override public void exception(AsyncReadGraph graph, Throwable t) { @@ -1530,7 +1532,10 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule procedure.execute(graph, t); } - }, listener); + }; + + QueryCache.runnerReadEntry(newGraph, request, null, listener, ap); + } catch (Throwable t) { // This is handled by the AsyncProcedure //Logger.defaultLogError("Internal error", t); @@ -1624,7 +1629,8 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule if (listener != null) { try { - newGraph.processor.query(newGraph, request, null, procedure, listener); + QueryCache.runnerAsyncReadEntry(newGraph, request, null, listener, procedure); + //newGraph.processor.query(newGraph, request, null, procedure, listener); } catch (DatabaseException e) { Logger.defaultLogError(e); }