public class QueryCache extends QueryCacheBase {
+ private static final boolean SINGLE = true;
public QueryCache(QuerySupport querySupport, int threads) {
super(querySupport, threads);
}
public static void runnerObjects(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, final IntProcedure procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r1,r2)) {
+ if (SINGLE) {
+ Objects e = cache.peekObjects(r1,r2);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
Objects.computeForEach(graph, r1,r2, null, procedure);
return;
}
}
}
+ private Objects peekObjects(int r1, int r2) {
+ synchronized(objectsMap) {
+ return (Objects) objectsMap.get(r1,r2);
+ }
+ }
+
Statements getOrCreateStatements(ReadGraphImpl graph, int r1, int r2) throws DatabaseException {
Statements existing = null;
synchronized(statementsMap) {
public static void runnerStatements(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, final TripleIntProcedure procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r1,r2)) {
+ if (SINGLE) {
+ Statements e = cache.peekStatements(r1,r2);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
Statements.computeForEach(graph, r1,r2, null, procedure);
return;
}
}
}
+ private Statements peekStatements(int r1, int r2) {
+ synchronized(statementsMap) {
+ return (Statements) statementsMap.get(r1,r2);
+ }
+ }
+
DirectObjects getOrCreateDirectObjects(ReadGraphImpl graph, int r1, int r2) throws DatabaseException {
DirectObjects existing = null;
synchronized(directObjectsMap) {
public static void runnerDirectObjects(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener, final IntProcedure procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r1,r2)) {
+ if (SINGLE) {
+ DirectObjects e = cache.peekDirectObjects(r1,r2);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
DirectObjects.computeForEach(graph, r1,r2, null, procedure);
return;
}
}
}
+ private DirectObjects peekDirectObjects(int r1, int r2) {
+ synchronized(directObjectsMap) {
+ return (DirectObjects) directObjectsMap.get(r1,r2);
+ }
+ }
+
RelationInfoQuery getOrCreateRelationInfoQuery(ReadGraphImpl graph, int r) throws DatabaseException {
RelationInfoQuery existing = null;
synchronized(relationInfoQueryMap) {
public static void runnerRelationInfoQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure<RelationInfo> procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ RelationInfoQuery e = cache.peekRelationInfoQuery(r);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
RelationInfoQuery.computeForEach(graph, r, null, procedure);
return;
}
}
}
+ private RelationInfoQuery peekRelationInfoQuery(int r) {
+ synchronized(relationInfoQueryMap) {
+ return (RelationInfoQuery) relationInfoQueryMap.get(r);
+ }
+ }
+
URIToResource getOrCreateURIToResource(ReadGraphImpl graph, String id) throws DatabaseException {
URIToResource existing = null;
synchronized(uRIToResourceMap) {
public static void runnerURIToResource(ReadGraphImpl graph, String id, CacheEntry parent, ListenerBase listener, final InternalProcedure<Integer> procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, id)) {
+ if (SINGLE) {
+ URIToResource e = cache.peekURIToResource(id);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
URIToResource.computeForEach(graph, id, null, procedure);
return;
}
}
}
+ private URIToResource peekURIToResource(String id) {
+ synchronized(uRIToResourceMap) {
+ return (URIToResource) uRIToResourceMap.get(id);
+ }
+ }
+
ValueQuery getOrCreateValueQuery(ReadGraphImpl graph, int r) throws DatabaseException {
ValueQuery existing = null;
synchronized(valueQueryMap) {
public static void runnerValueQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure<byte[]> procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ ValueQuery e = cache.peekValueQuery(r);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
ValueQuery.computeForEach(graph, r, null, procedure);
return;
}
}
}
+ private ValueQuery peekValueQuery(int r) {
+ synchronized(valueQueryMap) {
+ return (ValueQuery) valueQueryMap.get(r);
+ }
+ }
+
OrderedSet getOrCreateOrderedSet(ReadGraphImpl graph, int r) throws DatabaseException {
OrderedSet existing = null;
synchronized(orderedSetMap) {
public static void runnerOrderedSet(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final IntProcedure procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ OrderedSet e = cache.peekOrderedSet(r);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
OrderedSet.computeForEach(graph, r, null, procedure);
return;
}
}
}
+ private OrderedSet peekOrderedSet(int r) {
+ synchronized(orderedSetMap) {
+ return (OrderedSet) orderedSetMap.get(r);
+ }
+ }
+
PrincipalTypes getOrCreatePrincipalTypes(ReadGraphImpl graph, int r) throws DatabaseException {
PrincipalTypes existing = null;
synchronized(principalTypesMap) {
public static void runnerPrincipalTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final IntProcedure procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ PrincipalTypes e = cache.peekPrincipalTypes(r);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
PrincipalTypes.computeForEach(graph, r, null, procedure);
return;
}
}
}
+ private PrincipalTypes peekPrincipalTypes(int r) {
+ synchronized(principalTypesMap) {
+ return (PrincipalTypes) principalTypesMap.get(r);
+ }
+ }
+
DirectPredicates getOrCreateDirectPredicates(ReadGraphImpl graph, int r) throws DatabaseException {
DirectPredicates existing = null;
synchronized(directPredicatesMap) {
public static void runnerDirectPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure<IntSet> procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ DirectPredicates e = cache.peekDirectPredicates(r);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
DirectPredicates.computeForEach(graph, r, null, procedure);
return;
}
}
}
+ private DirectPredicates peekDirectPredicates(int r) {
+ synchronized(directPredicatesMap) {
+ return (DirectPredicates) directPredicatesMap.get(r);
+ }
+ }
+
Predicates getOrCreatePredicates(ReadGraphImpl graph, int r) throws DatabaseException {
Predicates existing = null;
synchronized(predicatesMap) {
public static void runnerPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure<IntSet> procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ Predicates e = cache.peekPredicates(r);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
Predicates.computeForEach(graph, r, null, procedure);
return;
}
}
}
+ private Predicates peekPredicates(int r) {
+ synchronized(predicatesMap) {
+ return (Predicates) predicatesMap.get(r);
+ }
+ }
+
ReadEntry getOrCreateReadEntry(ReadGraphImpl graph, Read<?> r, boolean needsToBlock) throws DatabaseException {
ReadEntry existing = null;
synchronized(readEntryMap) {
}
return existing;
}
+
void remove(ReadEntry entry) {
synchronized(readEntryMap) {
public static Object runnerReadEntry(ReadGraphImpl graph, Read<?> r, CacheEntry parent, ListenerBase listener, final AsyncProcedure procedure, final boolean needsToBlock) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ ReadEntry e = cache.peekReadEntry(r);
+ if (e != null && e.isReady()) {
+ return e.performFromCache(graph, procedure);
+ }
+ }
return ReadEntry.computeForEach(graph, r, null, procedure);
}
ReadEntry entry = (ReadEntry)cache.getOrCreateReadEntry(graph, r, needsToBlock);
return result;
}
}
+
+
+ private ReadEntry peekReadEntry(Read<?> r) {
+ synchronized(readEntryMap) {
+ return (ReadEntry) readEntryMap.get(r);
+ }
+ }
AsyncReadEntry getOrCreateAsyncReadEntry(ReadGraphImpl graph, AsyncRead<?> r, boolean needsToBlock) throws DatabaseException {
AsyncReadEntry existing = null;
}
return existing;
}
+
void remove(AsyncReadEntry entry) {
synchronized(asyncReadEntryMap) {
public static Object runnerAsyncReadEntry(ReadGraphImpl graph, AsyncRead<?> r, CacheEntry parent, ListenerBase listener, final AsyncProcedure procedure, final boolean needsToBlock) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ AsyncReadEntry e = cache.peekAsyncReadEntry(r);
+ if (e != null && e.isReady()) {
+ return e.performFromCache(graph, procedure);
+ }
+ }
return AsyncReadEntry.computeForEach(graph, r, null, procedure, needsToBlock);
}
AsyncReadEntry entry = (AsyncReadEntry)cache.getOrCreateAsyncReadEntry(graph, r, needsToBlock);
return result;
}
}
+
+
+ private AsyncReadEntry peekAsyncReadEntry(AsyncRead<?> r) {
+ synchronized(asyncReadEntryMap) {
+ return (AsyncReadEntry) asyncReadEntryMap.get(r);
+ }
+ }
Types getOrCreateTypes(ReadGraphImpl graph, int r) throws DatabaseException {
Types existing = null;
public static void runnerTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure<IntSet> procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ Types e = cache.peekTypes(r);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
Types.computeForEach(graph, r, null, procedure);
return;
}
}
}
+ private Types peekTypes(int r) {
+ synchronized(typesMap) {
+ return (Types) typesMap.get(r);
+ }
+ }
+
ChildMap getOrCreateChildMap(ReadGraphImpl graph, int r) throws DatabaseException {
ChildMap existing = null;
synchronized(childMapMap) {
public static void runnerChildMap(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure<ObjectResourceIdMap<String>> procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ ChildMap e = cache.peekChildMap(r);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
ChildMap.computeForEach(graph, r, null, procedure);
return;
}
}
}
+ private ChildMap peekChildMap(int r) {
+ synchronized(childMapMap) {
+ return (ChildMap) childMapMap.get(r);
+ }
+ }
+
TypeHierarchy getOrCreateTypeHierarchy(ReadGraphImpl graph, int r) throws DatabaseException {
TypeHierarchy existing = null;
synchronized(typeHierarchyMap) {
public static void runnerTypeHierarchy(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure<IntSet> procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ TypeHierarchy e = cache.peekTypeHierarchy(r);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
TypeHierarchy.computeForEach(graph, r, null, procedure);
return;
}
}
}
+ private TypeHierarchy peekTypeHierarchy(int r) {
+ synchronized(typeHierarchyMap) {
+ return (TypeHierarchy) typeHierarchyMap.get(r);
+ }
+ }
+
SuperTypes getOrCreateSuperTypes(ReadGraphImpl graph, int r) throws DatabaseException {
SuperTypes existing = null;
synchronized(superTypesMap) {
public static void runnerSuperTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure<IntSet> procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ SuperTypes e = cache.peekSuperTypes(r);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
SuperTypes.computeForEach(graph, r, null, procedure);
return;
}
}
}
+ private SuperTypes peekSuperTypes(int r) {
+ synchronized(superTypesMap) {
+ return (SuperTypes) superTypesMap.get(r);
+ }
+ }
+
SuperRelations getOrCreateSuperRelations(ReadGraphImpl graph, int r) throws DatabaseException {
SuperRelations existing = null;
synchronized(superRelationsMap) {
public static void runnerSuperRelations(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener, final InternalProcedure<IntSet> procedure) throws DatabaseException {
QueryCache cache = graph.processor.cache;
if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
+ if (SINGLE) {
+ SuperRelations e = cache.peekSuperRelations(r);
+ if (e != null && e.isReady()) {
+ e.performFromCache(graph, procedure);
+ return;
+ }
+ }
SuperRelations.computeForEach(graph, r, null, procedure);
return;
}
}
}
+ private SuperRelations peekSuperRelations(int r) {
+ synchronized(superRelationsMap) {
+ return (SuperRelations) superRelationsMap.get(r);
+ }
+ }
+
AssertedPredicates getOrCreateAssertedPredicates(ReadGraphImpl graph, int r) throws DatabaseException {
AssertedPredicates existing = null;
synchronized(assertedPredicatesMap) {
}
}
+ private AssertedPredicates peekAssertedPredicates(int r) {
+ synchronized(assertedPredicatesMap) {
+ return (AssertedPredicates) assertedPredicatesMap.get(r);
+ }
+ }
+
AssertedStatements getOrCreateAssertedStatements(ReadGraphImpl graph, int r1, int r2) throws DatabaseException {
AssertedStatements existing = null;
synchronized(assertedStatementsMap) {
}
}
+ private AssertedStatements peekAssertedStatements(int r1, int r2) {
+ synchronized(assertedStatementsMap) {
+ return (AssertedStatements) assertedStatementsMap.get(r1,r2);
+ }
+ }
+
DirectSuperRelations getOrCreateDirectSuperRelations(ReadGraphImpl graph, int r) throws DatabaseException {
DirectSuperRelations existing = null;
synchronized(directSuperRelationsMap) {
}
}
+ private DirectSuperRelations peekDirectSuperRelations(int r) {
+ synchronized(directSuperRelationsMap) {
+ return (DirectSuperRelations) directSuperRelationsMap.get(r);
+ }
+ }
+
MultiReadEntry getOrCreateMultiReadEntry(ReadGraphImpl graph, MultiRead<?> r) throws DatabaseException {
MultiReadEntry existing = null;
synchronized(multiReadEntryMap) {
}
}
+ private MultiReadEntry peekMultiReadEntry(MultiRead<?> r) {
+ synchronized(multiReadEntryMap) {
+ return (MultiReadEntry) multiReadEntryMap.get(r);
+ }
+ }
+
AsyncMultiReadEntry getOrCreateAsyncMultiReadEntry(ReadGraphImpl graph, AsyncMultiRead<?> r) throws DatabaseException {
AsyncMultiReadEntry existing = null;
synchronized(asyncMultiReadEntryMap) {
}
}
+ private AsyncMultiReadEntry peekAsyncMultiReadEntry(AsyncMultiRead<?> r) {
+ synchronized(asyncMultiReadEntryMap) {
+ return (AsyncMultiReadEntry) asyncMultiReadEntryMap.get(r);
+ }
+ }
+
ExternalReadEntry getOrCreateExternalReadEntry(ReadGraphImpl graph, ExternalRead<?> r) throws DatabaseException {
ExternalReadEntry existing = null;
synchronized(externalReadEntryMap) {
if(existing.isPending()) waitPending(graph, existing);
return existing;
}
+
void remove(ExternalReadEntry entry) {
synchronized(externalReadEntryMap) {
}
}
+ private ExternalReadEntry peekExternalReadEntry(ExternalRead<?> r) {
+ synchronized(externalReadEntryMap) {
+ return (ExternalReadEntry) externalReadEntryMap.get(r);
+ }
+ }
+
}