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=1467015512e38f81e6639fa8077f1808ec37865d;hb=de8b6e194da6d56c410101d9c72763078b0e8717;hp=5a6f5d0ba67bb120e9bfe4f4cb08e06d80e8b50c;hpb=1f8b50d81a1aa1bbd67a77f7cbc1060f2eb805d4;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 5a6f5d0ba..146701551 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 @@ -16,15 +16,13 @@ import org.simantics.db.request.ExternalRead; import org.simantics.db.request.MultiRead; import org.simantics.db.request.Read; -import gnu.trove.map.hash.TObjectIntHashMap; - public class QueryCache extends QueryCacheBase { public QueryCache(QuerySupport querySupport, int threads) { super(querySupport, threads); } - Objects getOrCreateObjects(ReadGraphImpl graph, int r1, int r2) throws DatabaseException { + Objects getOrCreateObjects(QueryProcessor processor, int r1, int r2) throws DatabaseException { Objects existing = null; synchronized(objectsMap) { existing = (Objects)objectsMap.get(r1,r2); @@ -41,7 +39,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -57,7 +55,7 @@ public class QueryCache extends QueryCacheBase { Objects.computeForEach(graph, r1,r2, null, procedure); return; } - Objects entry = (Objects)cache.getOrCreateObjects(graph, r1,r2); + Objects entry = (Objects)cache.getOrCreateObjects(graph.processor, r1,r2); IntProcedure procedure_ = procedure != null ? procedure : emptyProcedureObjects; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -68,7 +66,7 @@ public class QueryCache extends QueryCacheBase { } } - Statements getOrCreateStatements(ReadGraphImpl graph, int r1, int r2) throws DatabaseException { + Statements getOrCreateStatements(QueryProcessor processor, int r1, int r2) throws DatabaseException { Statements existing = null; synchronized(statementsMap) { existing = (Statements)statementsMap.get(r1,r2); @@ -85,7 +83,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -101,7 +99,7 @@ public class QueryCache extends QueryCacheBase { Statements.computeForEach(graph, r1,r2, null, procedure); return; } - Statements entry = (Statements)cache.getOrCreateStatements(graph, r1,r2); + Statements entry = (Statements)cache.getOrCreateStatements(graph.processor, r1,r2); TripleIntProcedure procedure_ = procedure != null ? procedure : emptyProcedureStatements; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -112,7 +110,7 @@ public class QueryCache extends QueryCacheBase { } } - DirectObjects getOrCreateDirectObjects(ReadGraphImpl graph, int r1, int r2) throws DatabaseException { + DirectObjects getOrCreateDirectObjects(QueryProcessor processor, int r1, int r2) throws DatabaseException { DirectObjects existing = null; synchronized(directObjectsMap) { existing = (DirectObjects)directObjectsMap.get(r1,r2); @@ -129,7 +127,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -145,7 +143,7 @@ public class QueryCache extends QueryCacheBase { DirectObjects.computeForEach(graph, r1,r2, null, procedure); return; } - DirectObjects entry = (DirectObjects)cache.getOrCreateDirectObjects(graph, r1,r2); + DirectObjects entry = (DirectObjects)cache.getOrCreateDirectObjects(graph.processor, r1,r2); IntProcedure procedure_ = procedure != null ? procedure : emptyProcedureDirectObjects; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -156,7 +154,7 @@ public class QueryCache extends QueryCacheBase { } } - RelationInfoQuery getOrCreateRelationInfoQuery(ReadGraphImpl graph, int r) throws DatabaseException { + RelationInfoQuery getOrCreateRelationInfoQuery(QueryProcessor processor, int r) throws DatabaseException { RelationInfoQuery existing = null; synchronized(relationInfoQueryMap) { existing = (RelationInfoQuery)relationInfoQueryMap.get(r); @@ -173,7 +171,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -189,7 +187,7 @@ public class QueryCache extends QueryCacheBase { RelationInfoQuery.computeForEach(graph, r, null, procedure); return; } - RelationInfoQuery entry = (RelationInfoQuery)cache.getOrCreateRelationInfoQuery(graph, r); + RelationInfoQuery entry = (RelationInfoQuery)cache.getOrCreateRelationInfoQuery(graph.processor, r); InternalProcedure procedure_ = procedure != null ? procedure : emptyProcedureRelationInfoQuery; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -200,7 +198,7 @@ public class QueryCache extends QueryCacheBase { } } - URIToResource getOrCreateURIToResource(ReadGraphImpl graph, String id) throws DatabaseException { + URIToResource getOrCreateURIToResource(QueryProcessor processor, String id) throws DatabaseException { URIToResource existing = null; synchronized(uRIToResourceMap) { existing = (URIToResource)uRIToResourceMap.get(id); @@ -217,7 +215,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -233,7 +231,7 @@ public class QueryCache extends QueryCacheBase { URIToResource.computeForEach(graph, id, null, procedure); return; } - URIToResource entry = (URIToResource)cache.getOrCreateURIToResource(graph, id); + URIToResource entry = (URIToResource)cache.getOrCreateURIToResource(graph.processor, id); InternalProcedure procedure_ = procedure != null ? procedure : emptyProcedureURIToResource; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -244,7 +242,7 @@ public class QueryCache extends QueryCacheBase { } } - ValueQuery getOrCreateValueQuery(ReadGraphImpl graph, int r) throws DatabaseException { + ValueQuery getOrCreateValueQuery(QueryProcessor processor, int r) throws DatabaseException { ValueQuery existing = null; synchronized(valueQueryMap) { existing = (ValueQuery)valueQueryMap.get(r); @@ -261,7 +259,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -277,7 +275,7 @@ public class QueryCache extends QueryCacheBase { ValueQuery.computeForEach(graph, r, null, procedure); return; } - ValueQuery entry = (ValueQuery)cache.getOrCreateValueQuery(graph, r); + ValueQuery entry = (ValueQuery)cache.getOrCreateValueQuery(graph.processor, r); InternalProcedure procedure_ = procedure != null ? procedure : emptyProcedureValueQuery; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -288,7 +286,7 @@ public class QueryCache extends QueryCacheBase { } } - OrderedSet getOrCreateOrderedSet(ReadGraphImpl graph, int r) throws DatabaseException { + OrderedSet getOrCreateOrderedSet(QueryProcessor processor, int r) throws DatabaseException { OrderedSet existing = null; synchronized(orderedSetMap) { existing = (OrderedSet)orderedSetMap.get(r); @@ -305,7 +303,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -321,7 +319,7 @@ public class QueryCache extends QueryCacheBase { OrderedSet.computeForEach(graph, r, null, procedure); return; } - OrderedSet entry = (OrderedSet)cache.getOrCreateOrderedSet(graph, r); + OrderedSet entry = (OrderedSet)cache.getOrCreateOrderedSet(graph.processor, r); IntProcedure procedure_ = procedure != null ? procedure : emptyProcedureOrderedSet; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -332,7 +330,7 @@ public class QueryCache extends QueryCacheBase { } } - PrincipalTypes getOrCreatePrincipalTypes(ReadGraphImpl graph, int r) throws DatabaseException { + PrincipalTypes getOrCreatePrincipalTypes(QueryProcessor processor, int r) throws DatabaseException { PrincipalTypes existing = null; synchronized(principalTypesMap) { existing = (PrincipalTypes)principalTypesMap.get(r); @@ -349,7 +347,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -365,7 +363,7 @@ public class QueryCache extends QueryCacheBase { PrincipalTypes.computeForEach(graph, r, null, procedure); return; } - PrincipalTypes entry = (PrincipalTypes)cache.getOrCreatePrincipalTypes(graph, r); + PrincipalTypes entry = (PrincipalTypes)cache.getOrCreatePrincipalTypes(graph.processor, r); IntProcedure procedure_ = procedure != null ? procedure : emptyProcedurePrincipalTypes; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -376,7 +374,7 @@ public class QueryCache extends QueryCacheBase { } } - DirectPredicates getOrCreateDirectPredicates(ReadGraphImpl graph, int r) throws DatabaseException { + DirectPredicates getOrCreateDirectPredicates(QueryProcessor processor, int r) throws DatabaseException { DirectPredicates existing = null; synchronized(directPredicatesMap) { existing = (DirectPredicates)directPredicatesMap.get(r); @@ -393,7 +391,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -409,7 +407,7 @@ public class QueryCache extends QueryCacheBase { DirectPredicates.computeForEach(graph, r, null, procedure); return; } - DirectPredicates entry = (DirectPredicates)cache.getOrCreateDirectPredicates(graph, r); + DirectPredicates entry = (DirectPredicates)cache.getOrCreateDirectPredicates(graph.processor, r); InternalProcedure procedure_ = procedure != null ? procedure : emptyProcedureDirectPredicates; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -420,7 +418,7 @@ public class QueryCache extends QueryCacheBase { } } - Predicates getOrCreatePredicates(ReadGraphImpl graph, int r) throws DatabaseException { + Predicates getOrCreatePredicates(QueryProcessor processor, int r) throws DatabaseException { Predicates existing = null; synchronized(predicatesMap) { existing = (Predicates)predicatesMap.get(r); @@ -437,7 +435,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -453,7 +451,7 @@ public class QueryCache extends QueryCacheBase { Predicates.computeForEach(graph, r, null, procedure); return; } - Predicates entry = (Predicates)cache.getOrCreatePredicates(graph, r); + Predicates entry = (Predicates)cache.getOrCreatePredicates(graph.processor, r); InternalProcedure procedure_ = procedure != null ? procedure : emptyProcedurePredicates; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -464,7 +462,7 @@ public class QueryCache extends QueryCacheBase { } } - ReadEntry getOrCreateReadEntry(ReadGraphImpl graph, Read r, boolean isSync) throws DatabaseException { + ReadEntry getOrCreateReadEntry(QueryProcessor processor, Read r, boolean isSync) throws DatabaseException { ReadEntry existing = null; synchronized(readEntryMap) { existing = (ReadEntry)readEntryMap.get(r); @@ -482,7 +480,7 @@ public class QueryCache extends QueryCacheBase { } } if(existing.isPending()) { - if(isSync) waitPending(graph, existing); + if(isSync) waitPending(processor, existing); else return null; } return existing; @@ -500,7 +498,7 @@ public class QueryCache extends QueryCacheBase { ReadEntry.computeForEach(graph, r, null, procedure); return; } - ReadEntry entry = (ReadEntry)cache.getOrCreateReadEntry(graph, r, isSync); + ReadEntry entry = (ReadEntry)cache.getOrCreateReadEntry(graph.processor, r, isSync); if(entry == null) { graph.processor.schedule(new SessionTask(false) { @Override @@ -525,7 +523,7 @@ public class QueryCache extends QueryCacheBase { } } - AsyncReadEntry getOrCreateAsyncReadEntry(ReadGraphImpl graph, AsyncRead r, boolean isSync) throws DatabaseException { + AsyncReadEntry getOrCreateAsyncReadEntry(QueryProcessor processor, AsyncRead r, boolean isSync) throws DatabaseException { AsyncReadEntry existing = null; synchronized(asyncReadEntryMap) { existing = (AsyncReadEntry)asyncReadEntryMap.get(r); @@ -543,7 +541,7 @@ public class QueryCache extends QueryCacheBase { } } if(existing.isPending()) { - if(isSync) waitPending(graph, existing); + if(isSync) waitPending(processor, existing); else return null; } return existing; @@ -561,7 +559,7 @@ public class QueryCache extends QueryCacheBase { AsyncReadEntry.computeForEach(graph, r, null, procedure); return; } - AsyncReadEntry entry = (AsyncReadEntry)cache.getOrCreateAsyncReadEntry(graph, r, isSync); + AsyncReadEntry entry = (AsyncReadEntry)cache.getOrCreateAsyncReadEntry(graph.processor, r, isSync); if(entry == null) { graph.processor.schedule(new SessionTask(false) { @Override @@ -586,7 +584,7 @@ public class QueryCache extends QueryCacheBase { } } - Types getOrCreateTypes(ReadGraphImpl graph, int r) throws DatabaseException { + Types getOrCreateTypes(QueryProcessor processor, int r) throws DatabaseException { Types existing = null; synchronized(typesMap) { existing = (Types)typesMap.get(r); @@ -603,7 +601,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -619,7 +617,7 @@ public class QueryCache extends QueryCacheBase { Types.computeForEach(graph, r, null, procedure); return; } - Types entry = (Types)cache.getOrCreateTypes(graph, r); + Types entry = (Types)cache.getOrCreateTypes(graph.processor, r); InternalProcedure procedure_ = procedure != null ? procedure : emptyProcedureTypes; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -630,7 +628,7 @@ public class QueryCache extends QueryCacheBase { } } - ChildMap getOrCreateChildMap(ReadGraphImpl graph, int r) throws DatabaseException { + ChildMap getOrCreateChildMap(QueryProcessor processor, int r) throws DatabaseException { ChildMap existing = null; synchronized(childMapMap) { existing = (ChildMap)childMapMap.get(r); @@ -647,7 +645,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -663,7 +661,7 @@ public class QueryCache extends QueryCacheBase { ChildMap.computeForEach(graph, r, null, procedure); return; } - ChildMap entry = (ChildMap)cache.getOrCreateChildMap(graph, r); + ChildMap entry = (ChildMap)cache.getOrCreateChildMap(graph.processor, r); InternalProcedure> procedure_ = procedure != null ? procedure : emptyProcedureChildMap; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -674,15 +672,15 @@ public class QueryCache extends QueryCacheBase { } } - AssertedStatements getOrCreateAssertedStatements(ReadGraphImpl graph, int r1, int r2) throws DatabaseException { - AssertedStatements existing = null; - synchronized(assertedStatementsMap) { - existing = (AssertedStatements)assertedStatementsMap.get(r1,r2); + TypeHierarchy getOrCreateTypeHierarchy(QueryProcessor processor, int r) throws DatabaseException { + TypeHierarchy existing = null; + synchronized(typeHierarchyMap) { + existing = (TypeHierarchy)typeHierarchyMap.get(r); if(existing == null) { - existing = new AssertedStatements(r1,r2); + existing = new TypeHierarchy(r); existing.clearResult(querySupport); existing.setPending(); - assertedStatementsMap.put(keyR2(r1,r2), existing); + typeHierarchyMap.put(keyR(r), existing); size++; return existing; } @@ -691,38 +689,42 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } - void remove(AssertedStatements entry) { - synchronized(assertedStatementsMap) { - assertedStatementsMap.remove(entry.id); + void remove(TypeHierarchy entry) { + synchronized(typeHierarchyMap) { + typeHierarchyMap.remove(entry.id); } } - public static void runnerAssertedStatements(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, final TripleIntProcedure procedure) throws DatabaseException { + public static void runnerTypeHierarchy(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; - AssertedStatements entry = (AssertedStatements)cache.getOrCreateAssertedStatements(graph, r1,r2); - TripleIntProcedure procedure_ = procedure != null ? procedure : emptyProcedureAssertedStatements; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { + TypeHierarchy.computeForEach(graph, r, null, procedure); + return; + } + TypeHierarchy entry = (TypeHierarchy)cache.getOrCreateTypeHierarchy(graph.processor, r); + InternalProcedure procedure_ = procedure != null ? procedure : emptyProcedureTypeHierarchy; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); else { assert(entry.isPending()); - entry.compute(graph, procedure_); + TypeHierarchy.computeForEach(graph, r, entry, procedure_); if(listenerEntry != null) cache.primeListenerEntry(listenerEntry, entry.getResult()); } } - AssertedPredicates getOrCreateAssertedPredicates(ReadGraphImpl graph, int r) throws DatabaseException { - AssertedPredicates existing = null; - synchronized(assertedPredicatesMap) { - existing = (AssertedPredicates)assertedPredicatesMap.get(r); + SuperTypes getOrCreateSuperTypes(QueryProcessor processor, int r) throws DatabaseException { + SuperTypes existing = null; + synchronized(superTypesMap) { + existing = (SuperTypes)superTypesMap.get(r); if(existing == null) { - existing = new AssertedPredicates(r); + existing = new SuperTypes(r); existing.clearResult(querySupport); existing.setPending(); - assertedPredicatesMap.put(keyR(r), existing); + superTypesMap.put(keyR(r), existing); size++; return existing; } @@ -731,38 +733,42 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } - void remove(AssertedPredicates entry) { - synchronized(assertedPredicatesMap) { - assertedPredicatesMap.remove(entry.id); + void remove(SuperTypes entry) { + synchronized(superTypesMap) { + superTypesMap.remove(entry.id); } } - public static void runnerAssertedPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final IntProcedure procedure) throws DatabaseException { + public static void runnerSuperTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; - AssertedPredicates entry = (AssertedPredicates)cache.getOrCreateAssertedPredicates(graph, r); - IntProcedure procedure_ = procedure != null ? procedure : emptyProcedureAssertedPredicates; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { + SuperTypes.computeForEach(graph, r, null, procedure); + return; + } + SuperTypes entry = (SuperTypes)cache.getOrCreateSuperTypes(graph.processor, r); + InternalProcedure procedure_ = procedure != null ? procedure : emptyProcedureSuperTypes; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); else { assert(entry.isPending()); - entry.compute(graph, procedure_); + SuperTypes.computeForEach(graph, r, entry, procedure_); if(listenerEntry != null) cache.primeListenerEntry(listenerEntry, entry.getResult()); } } - DirectSuperRelations getOrCreateDirectSuperRelations(ReadGraphImpl graph, int r) throws DatabaseException { - DirectSuperRelations existing = null; - synchronized(directSuperRelationsMap) { - existing = (DirectSuperRelations)directSuperRelationsMap.get(r); + SuperRelations getOrCreateSuperRelations(QueryProcessor processor, int r) throws DatabaseException { + SuperRelations existing = null; + synchronized(superRelationsMap) { + existing = (SuperRelations)superRelationsMap.get(r); if(existing == null) { - existing = new DirectSuperRelations(r); + existing = new SuperRelations(r); existing.clearResult(querySupport); existing.setPending(); - directSuperRelationsMap.put(keyR(r), existing); + superRelationsMap.put(keyR(r), existing); size++; return existing; } @@ -771,38 +777,42 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } - void remove(DirectSuperRelations entry) { - synchronized(directSuperRelationsMap) { - directSuperRelationsMap.remove(entry.id); + void remove(SuperRelations entry) { + synchronized(superRelationsMap) { + superRelationsMap.remove(entry.id); } } - public static void runnerDirectSuperRelations(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final IntProcedure procedure) throws DatabaseException { + public static void runnerSuperRelations(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; - DirectSuperRelations entry = (DirectSuperRelations)cache.getOrCreateDirectSuperRelations(graph, r); - IntProcedure procedure_ = procedure != null ? procedure : emptyProcedureDirectSuperRelations; + if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) { + SuperRelations.computeForEach(graph, r, null, procedure); + return; + } + SuperRelations entry = (SuperRelations)cache.getOrCreateSuperRelations(graph.processor, r); + InternalProcedure procedure_ = procedure != null ? procedure : emptyProcedureSuperRelations; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); else { assert(entry.isPending()); - entry.compute(graph, procedure_); + SuperRelations.computeForEach(graph, r, entry, procedure_); if(listenerEntry != null) cache.primeListenerEntry(listenerEntry, entry.getResult()); } } - SuperTypes getOrCreateSuperTypes(ReadGraphImpl graph, int r) throws DatabaseException { - SuperTypes existing = null; - synchronized(superTypesMap) { - existing = (SuperTypes)superTypesMap.get(r); + AssertedPredicates getOrCreateAssertedPredicates(QueryProcessor processor, int r) throws DatabaseException { + AssertedPredicates existing = null; + synchronized(assertedPredicatesMap) { + existing = (AssertedPredicates)assertedPredicatesMap.get(r); if(existing == null) { - existing = new SuperTypes(r); + existing = new AssertedPredicates(r); existing.clearResult(querySupport); existing.setPending(); - superTypesMap.put(keyR(r), existing); + assertedPredicatesMap.put(keyR(r), existing); size++; return existing; } @@ -811,20 +821,20 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } - void remove(SuperTypes entry) { - synchronized(superTypesMap) { - superTypesMap.remove(entry.id); + void remove(AssertedPredicates entry) { + synchronized(assertedPredicatesMap) { + assertedPredicatesMap.remove(entry.id); } } - public static void runnerSuperTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure procedure) throws DatabaseException { + public static void runnerAssertedPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final IntProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; - SuperTypes entry = (SuperTypes)cache.getOrCreateSuperTypes(graph, r); - InternalProcedure procedure_ = procedure != null ? procedure : emptyProcedureSuperTypes; + AssertedPredicates entry = (AssertedPredicates)cache.getOrCreateAssertedPredicates(graph.processor, r); + IntProcedure procedure_ = procedure != null ? procedure : emptyProcedureAssertedPredicates; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); else { @@ -834,15 +844,15 @@ public class QueryCache extends QueryCacheBase { } } - TypeHierarchy getOrCreateTypeHierarchy(ReadGraphImpl graph, int r) throws DatabaseException { - TypeHierarchy existing = null; - synchronized(typeHierarchyMap) { - existing = (TypeHierarchy)typeHierarchyMap.get(r); + AssertedStatements getOrCreateAssertedStatements(QueryProcessor processor, int r1, int r2) throws DatabaseException { + AssertedStatements existing = null; + synchronized(assertedStatementsMap) { + existing = (AssertedStatements)assertedStatementsMap.get(r1,r2); if(existing == null) { - existing = new TypeHierarchy(r); + existing = new AssertedStatements(r1,r2); existing.clearResult(querySupport); existing.setPending(); - typeHierarchyMap.put(keyR(r), existing); + assertedStatementsMap.put(keyR2(r1,r2), existing); size++; return existing; } @@ -851,20 +861,20 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } - void remove(TypeHierarchy entry) { - synchronized(typeHierarchyMap) { - typeHierarchyMap.remove(entry.id); + void remove(AssertedStatements entry) { + synchronized(assertedStatementsMap) { + assertedStatementsMap.remove(entry.id); } } - public static void runnerTypeHierarchy(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure procedure) throws DatabaseException { + public static void runnerAssertedStatements(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, final TripleIntProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; - TypeHierarchy entry = (TypeHierarchy)cache.getOrCreateTypeHierarchy(graph, r); - InternalProcedure procedure_ = procedure != null ? procedure : emptyProcedureTypeHierarchy; + AssertedStatements entry = (AssertedStatements)cache.getOrCreateAssertedStatements(graph.processor, r1,r2); + TripleIntProcedure procedure_ = procedure != null ? procedure : emptyProcedureAssertedStatements; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); else { @@ -874,15 +884,15 @@ public class QueryCache extends QueryCacheBase { } } - SuperRelations getOrCreateSuperRelations(ReadGraphImpl graph, int r) throws DatabaseException { - SuperRelations existing = null; - synchronized(superRelationsMap) { - existing = (SuperRelations)superRelationsMap.get(r); + DirectSuperRelations getOrCreateDirectSuperRelations(QueryProcessor processor, int r) throws DatabaseException { + DirectSuperRelations existing = null; + synchronized(directSuperRelationsMap) { + existing = (DirectSuperRelations)directSuperRelationsMap.get(r); if(existing == null) { - existing = new SuperRelations(r); + existing = new DirectSuperRelations(r); existing.clearResult(querySupport); existing.setPending(); - superRelationsMap.put(keyR(r), existing); + directSuperRelationsMap.put(keyR(r), existing); size++; return existing; } @@ -891,20 +901,20 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } - void remove(SuperRelations entry) { - synchronized(superRelationsMap) { - superRelationsMap.remove(entry.id); + void remove(DirectSuperRelations entry) { + synchronized(directSuperRelationsMap) { + directSuperRelationsMap.remove(entry.id); } } - public static void runnerSuperRelations(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure procedure) throws DatabaseException { + public static void runnerDirectSuperRelations(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final IntProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; - SuperRelations entry = (SuperRelations)cache.getOrCreateSuperRelations(graph, r); - InternalProcedure procedure_ = procedure != null ? procedure : emptyProcedureSuperRelations; + DirectSuperRelations entry = (DirectSuperRelations)cache.getOrCreateDirectSuperRelations(graph.processor, r); + IntProcedure procedure_ = procedure != null ? procedure : emptyProcedureDirectSuperRelations; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); else { @@ -914,7 +924,7 @@ public class QueryCache extends QueryCacheBase { } } - MultiReadEntry getOrCreateMultiReadEntry(ReadGraphImpl graph, MultiRead r) throws DatabaseException { + MultiReadEntry getOrCreateMultiReadEntry(QueryProcessor processor, MultiRead r) throws DatabaseException { MultiReadEntry existing = null; synchronized(multiReadEntryMap) { existing = (MultiReadEntry)multiReadEntryMap.get(r); @@ -931,7 +941,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -943,7 +953,7 @@ public class QueryCache extends QueryCacheBase { public static void runnerMultiReadEntry(ReadGraphImpl graph, MultiRead r, CacheEntry parent, ListenerBase listener, final AsyncMultiProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; - MultiReadEntry entry = (MultiReadEntry)cache.getOrCreateMultiReadEntry(graph, r); + MultiReadEntry entry = (MultiReadEntry)cache.getOrCreateMultiReadEntry(graph.processor, r); AsyncMultiProcedure procedure_ = procedure != null ? procedure : emptyProcedureMultiReadEntry; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -954,7 +964,7 @@ public class QueryCache extends QueryCacheBase { } } - AsyncMultiReadEntry getOrCreateAsyncMultiReadEntry(ReadGraphImpl graph, AsyncMultiRead r) throws DatabaseException { + AsyncMultiReadEntry getOrCreateAsyncMultiReadEntry(QueryProcessor processor, AsyncMultiRead r) throws DatabaseException { AsyncMultiReadEntry existing = null; synchronized(asyncMultiReadEntryMap) { existing = (AsyncMultiReadEntry)asyncMultiReadEntryMap.get(r); @@ -971,7 +981,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -983,7 +993,7 @@ public class QueryCache extends QueryCacheBase { public static void runnerAsyncMultiReadEntry(ReadGraphImpl graph, AsyncMultiRead r, CacheEntry parent, ListenerBase listener, final AsyncMultiProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; - AsyncMultiReadEntry entry = (AsyncMultiReadEntry)cache.getOrCreateAsyncMultiReadEntry(graph, r); + AsyncMultiReadEntry entry = (AsyncMultiReadEntry)cache.getOrCreateAsyncMultiReadEntry(graph.processor, r); AsyncMultiProcedure procedure_ = procedure != null ? procedure : emptyProcedureAsyncMultiReadEntry; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_); @@ -994,7 +1004,7 @@ public class QueryCache extends QueryCacheBase { } } - ExternalReadEntry getOrCreateExternalReadEntry(ReadGraphImpl graph, ExternalRead r) throws DatabaseException { + ExternalReadEntry getOrCreateExternalReadEntry(QueryProcessor processor, ExternalRead r) throws DatabaseException { ExternalReadEntry existing = null; synchronized(externalReadEntryMap) { existing = (ExternalReadEntry)externalReadEntryMap.get(r); @@ -1011,7 +1021,7 @@ public class QueryCache extends QueryCacheBase { return existing; } } - if(existing.isPending()) waitPending(graph, existing); + if(existing.isPending()) waitPending(processor, existing); return existing; } @@ -1023,7 +1033,7 @@ public class QueryCache extends QueryCacheBase { public static void runnerExternalReadEntry(ReadGraphImpl graph, ExternalRead r, CacheEntry parent, ListenerBase listener, final AsyncProcedure procedure) throws DatabaseException { QueryCache cache = graph.processor.cache; - ExternalReadEntry entry = (ExternalReadEntry)cache.getOrCreateExternalReadEntry(graph, r); + ExternalReadEntry entry = (ExternalReadEntry)cache.getOrCreateExternalReadEntry(graph.processor, r); AsyncProcedure procedure_ = procedure != null ? procedure : emptyProcedureExternalReadEntry; ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false); if(entry.isReady()) entry.performFromCache(graph, procedure_);