X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FQueryCache.java;h=49e02dece32049884f7a3907e85f960f2bf27f64;hb=378f6f82ce88c8ba2ba9f7345cb25679b508bae5;hp=4be12da47d582b08cf0d6dfe16129d42650c7509;hpb=ad18bf76b19bec530bc68c6041ab5fb245b8ee4d;p=simantics%2Fplatform.git 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..49e02dece 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 @@ -1,5 +1,6 @@ package org.simantics.db.impl.query; +import org.simantics.db.ObjectResourceIdMap; import org.simantics.db.RelationInfo; import org.simantics.db.exception.DatabaseException; import org.simantics.db.impl.graph.ReadGraphImpl; @@ -30,6 +31,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); objectsMap.put(keyR2(r1,r2), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -47,12 +49,12 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerObjects(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { - if(parent == null && listener == null) { + public static void runnerObjects(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r1,r2)) { Objects.computeForEach(graph, r1,r2, null, procedure); return; } - QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureObjects; Objects entry = (Objects)cache.getOrCreateObjects(r1,r2); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); @@ -72,6 +74,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); statementsMap.put(keyR2(r1,r2), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -89,12 +92,12 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerStatements(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, TripleIntProcedure procedure) throws DatabaseException { - if(parent == null && listener == null) { + public static void runnerStatements(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, TripleIntProcedure procedure) throws DatabaseException { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r1,r2)) { Statements.computeForEach(graph, r1,r2, null, procedure); return; } - QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureStatements; Statements entry = (Statements)cache.getOrCreateStatements(r1,r2); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); @@ -114,6 +117,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); directObjectsMap.put(keyR2(r1,r2), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -131,12 +135,12 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerDirectObjects(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { - if(parent == null && listener == null) { + public static void runnerDirectObjects(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r1,r2)) { DirectObjects.computeForEach(graph, r1,r2, null, procedure); return; } - QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureDirectObjects; DirectObjects entry = (DirectObjects)cache.getOrCreateDirectObjects(r1,r2); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); @@ -156,6 +160,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); relationInfoQueryMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -173,12 +178,12 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerRelationInfoQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { - if(parent == null && listener == null) { + public static void runnerRelationInfoQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { RelationInfoQuery.computeForEach(graph, r, null, procedure); return; } - QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureRelationInfoQuery; RelationInfoQuery entry = (RelationInfoQuery)cache.getOrCreateRelationInfoQuery(r); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); @@ -198,6 +203,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); uRIToResourceMap.put(keyID(id), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -215,12 +221,12 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerURIToResource(ReadGraphImpl graph, String id, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { - if(parent == null && listener == null) { + public static void runnerURIToResource(ReadGraphImpl graph, String id, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, id)) { URIToResource.computeForEach(graph, id, null, procedure); return; } - QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureURIToResource; URIToResource entry = (URIToResource)cache.getOrCreateURIToResource(id); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); @@ -240,6 +246,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); valueQueryMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -257,12 +264,12 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerValueQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { - if(parent == null && listener == null) { + public static void runnerValueQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { ValueQuery.computeForEach(graph, r, null, procedure); return; } - QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureValueQuery; ValueQuery entry = (ValueQuery)cache.getOrCreateValueQuery(r); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); @@ -282,6 +289,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); orderedSetMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -299,12 +307,12 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerOrderedSet(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { - if(parent == null && listener == null) { + public static void runnerOrderedSet(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { OrderedSet.computeForEach(graph, r, null, procedure); return; } - QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureOrderedSet; OrderedSet entry = (OrderedSet)cache.getOrCreateOrderedSet(r); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); @@ -324,6 +332,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); principalTypesMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -341,12 +350,12 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerPrincipalTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { - if(parent == null && listener == null) { + public static void runnerPrincipalTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, IntProcedure procedure) throws DatabaseException { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { PrincipalTypes.computeForEach(graph, r, null, procedure); return; } - QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedurePrincipalTypes; PrincipalTypes entry = (PrincipalTypes)cache.getOrCreatePrincipalTypes(r); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); @@ -366,6 +375,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); directPredicatesMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -383,12 +393,12 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerDirectPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { - if(parent == null && listener == null) { + public static void runnerDirectPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { DirectPredicates.computeForEach(graph, r, null, procedure); return; } - QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureDirectPredicates; DirectPredicates entry = (DirectPredicates)cache.getOrCreateDirectPredicates(r); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); @@ -408,6 +418,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); predicatesMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -425,12 +436,12 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { - if(parent == null && listener == null) { + public static void runnerPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { Predicates.computeForEach(graph, r, null, procedure); return; } - QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedurePredicates; Predicates entry = (Predicates)cache.getOrCreatePredicates(r); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); @@ -450,6 +461,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); readEntryMap.put(id(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -467,12 +479,12 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerReadEntry(ReadGraphImpl graph, Read r, CacheEntry parent, ListenerBase listener, AsyncProcedure procedure) throws DatabaseException { - if(parent == null && listener == null) { + public static void runnerReadEntry(ReadGraphImpl graph, Read r, CacheEntry parent, ListenerBase listener, AsyncProcedure procedure) throws DatabaseException { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { ReadEntry.computeForEach(graph, r, null, procedure); return; } - QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureReadEntry; ReadEntry entry = (ReadEntry)cache.getOrCreateReadEntry(r); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); @@ -483,6 +495,49 @@ 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); + size++; + 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 { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { + AsyncReadEntry.computeForEach(graph, r, null, procedure); + return; + } + 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) { @@ -492,6 +547,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); typesMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -509,12 +565,12 @@ public class QueryCache extends QueryCacheBase { } } - static void runnerTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { - if(parent == null && listener == null) { + public static void runnerTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure procedure) throws DatabaseException { + QueryCache cache = graph.processor.cache; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { Types.computeForEach(graph, r, null, procedure); return; } - QueryCache cache = graph.processor.cache; if(procedure == null) procedure = emptyProcedureTypes; Types entry = (Types)cache.getOrCreateTypes(r); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); @@ -525,15 +581,16 @@ public class QueryCache extends QueryCacheBase { } } - AssertedStatements getOrCreateAssertedStatements(int r1, int r2) throws DatabaseException { - AssertedStatements existing = null; - synchronized(assertedStatementsMap) { - existing = (AssertedStatements)assertedStatementsMap.get(r1,r2); + ChildMap getOrCreateChildMap(int r) throws DatabaseException { + ChildMap existing = null; + synchronized(childMapMap) { + existing = (ChildMap)childMapMap.get(r); if(existing == null) { - existing = new AssertedStatements(r1,r2); + existing = new ChildMap(r); existing.clearResult(querySupport); existing.setPending(); - assertedStatementsMap.put(keyR2(r1,r2), existing); + childMapMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -545,33 +602,38 @@ public class QueryCache extends QueryCacheBase { return existing; } - void remove(AssertedStatements entry) { - synchronized(assertedStatementsMap) { - assertedStatementsMap.remove(entry.id); + void remove(ChildMap entry) { + synchronized(childMapMap) { + childMapMap.remove(entry.id); } } - static void runnerAssertedStatements(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, TripleIntProcedure procedure) throws DatabaseException { + public static void runnerChildMap(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, InternalProcedure> procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; - if(procedure == null) procedure = emptyProcedureAssertedStatements; - AssertedStatements entry = (AssertedStatements)cache.getOrCreateAssertedStatements(r1,r2); + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { + ChildMap.computeForEach(graph, r, null, procedure); + return; + } + if(procedure == null) procedure = emptyProcedureChildMap; + ChildMap entry = (ChildMap)cache.getOrCreateChildMap(r); ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure, false); if(entry.isReady()) entry.performFromCache(graph, procedure); else { - entry.compute(graph, procedure); + ChildMap.computeForEach(graph, r, 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); + size++; return existing; } if(existing.requiresComputation()) { @@ -583,16 +645,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 { @@ -610,6 +672,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); assertedPredicatesMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -627,7 +690,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); @@ -648,6 +711,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); directSuperRelationsMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -665,7 +729,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); @@ -686,6 +750,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); superTypesMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -703,7 +768,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); @@ -724,6 +789,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); typeHierarchyMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -741,7 +807,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); @@ -762,6 +828,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); superRelationsMap.put(keyR(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -779,7 +846,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 +858,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) { @@ -838,6 +867,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); multiReadEntryMap.put(id(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -855,7 +885,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); @@ -876,6 +906,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); asyncMultiReadEntryMap.put(id(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -893,7 +924,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); @@ -914,6 +945,7 @@ public class QueryCache extends QueryCacheBase { existing.clearResult(querySupport); existing.setPending(); externalReadEntryMap.put(id(r), existing); + size++; return existing; } if(existing.requiresComputation()) { @@ -931,7 +963,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);