package org.simantics.db.impl.query; import java.util.ArrayList; import java.util.Collection; import java.util.concurrent.Semaphore; import org.simantics.databoard.Bindings; import org.simantics.db.AsyncReadGraph; import org.simantics.db.DevelopmentKeys; import org.simantics.db.ObjectResourceIdMap; import org.simantics.db.ReadGraph; import org.simantics.db.RelationInfo; import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; import org.simantics.db.impl.graph.ReadGraphImpl; import org.simantics.db.impl.procedure.InternalProcedure; import org.simantics.db.procedure.AsyncMultiProcedure; import org.simantics.db.procedure.AsyncProcedure; import org.simantics.db.procedure.ListenerBase; import org.simantics.db.procedure.Procedure; import org.simantics.db.procedure.SyncMultiProcedure; import org.simantics.db.request.AsyncMultiRead; import org.simantics.db.request.AsyncRead; import org.simantics.db.request.ExternalRead; import org.simantics.db.request.MultiRead; import org.simantics.db.request.Read; import org.simantics.utils.Development; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TObjectIntHashMap; public class QueryCacheBase { // Statistics final int THREADS; public final int THREAD_MASK; int hits = 0; int misses = 0; int updates = 0; public int size = 0; public volatile boolean dirty = false; public boolean collecting = false; protected final THashMap uRIToResourceMap; //protected final THashMap namespaceIndexMap; protected final UnaryQueryHashMap>> childMapMap; protected final DoubleKeyQueryHashMap objectsMap; protected final DoubleKeyQueryHashMap assertedStatementsMap; protected final DoubleKeyQueryHashMap directObjectsMap; protected final DoubleKeyQueryHashMap statementsMap; protected final UnaryQueryHashMap> typesMap; protected final UnaryQueryHashMap principalTypesMap; protected final UnaryQueryHashMap> predicatesMap; protected final UnaryQueryHashMap> superTypesMap; protected final UnaryQueryHashMap> typeHierarchyMap; protected final UnaryQueryHashMap> superRelationsMap; protected final UnaryQueryHashMap orderedSetMap; protected final UnaryQueryHashMap assertedPredicatesMap; protected final UnaryQueryHashMap> directPredicatesMap; protected final UnaryQueryHashMap directSuperRelationsMap; protected final UnaryQueryHashMap> relationInfoQueryMap; protected final UnaryQueryHashMap> valueQueryMap; protected final StableHashMap asyncReadEntryMap; protected final StableHashMap readEntryMap; protected final StableHashMap multiReadEntryMap; protected final StableHashMap asyncMultiReadEntryMap; protected final StableHashMap externalReadEntryMap; public final QuerySupport querySupport; public QueryCacheBase(QuerySupport querySupport, int threads) { THREADS = threads; THREAD_MASK = threads - 1; this.querySupport = querySupport; directPredicatesMap = new UnaryQueryHashMap(); directSuperRelationsMap = new UnaryQueryHashMap(); valueQueryMap = new UnaryQueryHashMap(); principalTypesMap = new UnaryQueryHashMap(); uRIToResourceMap = new THashMap(); //namespaceIndexMap = new THashMap(); childMapMap = new UnaryQueryHashMap>>(); relationInfoQueryMap = new UnaryQueryHashMap(); typeHierarchyMap = new UnaryQueryHashMap(); superTypesMap = new UnaryQueryHashMap(); superRelationsMap = new UnaryQueryHashMap(); typesMap = new UnaryQueryHashMap(); objectsMap = new DoubleKeyQueryHashMap(); orderedSetMap = new UnaryQueryHashMap(); predicatesMap = new UnaryQueryHashMap(); statementsMap = new DoubleKeyQueryHashMap(); directObjectsMap = new DoubleKeyQueryHashMap(); assertedPredicatesMap = new UnaryQueryHashMap(); assertedStatementsMap = new DoubleKeyQueryHashMap(); asyncReadEntryMap = new StableHashMap(); readEntryMap = new StableHashMap(); asyncMultiReadEntryMap = new StableHashMap(); multiReadEntryMap = new StableHashMap(); externalReadEntryMap = new StableHashMap(); } public Object performQuery(ReadGraphImpl parentGraph, final AsyncMultiRead query, final CacheEntryBase entry_, Object procedure_) throws DatabaseException { ReadGraphImpl queryGraph = parentGraph.withParent(entry_, null, false); AsyncMultiReadEntry entry = (AsyncMultiReadEntry)entry_; AsyncMultiProcedure procedure = (AsyncMultiProcedure)procedure_; try { query.perform(queryGraph, new AsyncMultiProcedure() { @Override public void execute(AsyncReadGraph graph, T result) { ReadGraphImpl impl = (ReadGraphImpl)graph; entry.addOrSet(result); try { procedure.execute(parentGraph, result); } catch (Throwable t) { t.printStackTrace(); } } @Override public void finished(AsyncReadGraph graph) { ReadGraphImpl impl = (ReadGraphImpl)graph; entry.finish(parentGraph); try { procedure.finished(parentGraph); } catch (Throwable t) { t.printStackTrace(); } } @Override public void exception(AsyncReadGraph graph, Throwable t) { ReadGraphImpl impl = (ReadGraphImpl)graph; entry.except(parentGraph, t); try { procedure.exception(parentGraph, t); } catch (Throwable t2) { t2.printStackTrace(); } } }); return entry.getResult(); } catch (Throwable t) { entry.except(t); try { procedure.exception(parentGraph, t); } catch (Throwable t2) { t2.printStackTrace(); } return entry.getResult(); } } public Object performQuery(ReadGraphImpl parentGraph, final MultiRead query, final CacheEntryBase entry_, Object procedure_) throws DatabaseException { ReadGraphImpl queryGraph = parentGraph.withParent(entry_, null, true); MultiReadEntry entry = (MultiReadEntry)entry_; SyncMultiProcedure procedure = (SyncMultiProcedure)procedure_; try { query.perform(queryGraph, new SyncMultiProcedure() { @Override public void execute(ReadGraph graph, T result) { ReadGraphImpl impl = (ReadGraphImpl)graph; entry.addOrSet(result); try { procedure.execute(parentGraph, result); } catch (Throwable t) { t.printStackTrace(); } } @Override public void finished(ReadGraph graph) { ReadGraphImpl impl = (ReadGraphImpl)graph; entry.finish(parentGraph); try { procedure.finished(parentGraph); } catch (Throwable t) { t.printStackTrace(); } } @Override public void exception(ReadGraph graph, Throwable t) { ReadGraphImpl impl = (ReadGraphImpl)graph; entry.except((DatabaseException)t); try { procedure.exception(parentGraph, t); } catch (Throwable t2) { t2.printStackTrace(); } } }); return entry.getResult(); } catch (Throwable t) { entry.except(t); try { procedure.exception(parentGraph, t); } catch (Throwable t2) { t2.printStackTrace(); } return entry.getResult(); } } public Collection getRootList() { ArrayList result = new ArrayList(); for (Object e : valueQueryMap.values()) { result.add((CacheEntry) e); } for (Object e : directPredicatesMap.values()) { result.add((CacheEntry) e); } for (Object e : directSuperRelationsMap.values()) { result.add((CacheEntry) e); } for (Object e : objectsMap.values()) { result.add((CacheEntry) e); } for (Object e : directObjectsMap.values()) { result.add((CacheEntry) e); } for (Object e : principalTypesMap.values()) { result.add((CacheEntry) e); } for (Object e : superRelationsMap.values()) { result.add((CacheEntry) e); } for (Object e : superTypesMap.values()) { result.add((CacheEntry) e); } for (Object e : typesMap.values()) { result.add((CacheEntry) e); } for (Object e : objectsMap.values()) { result.add((CacheEntry) e); } for (Object e : assertedStatementsMap.values()) { result.add((CacheEntry) e); } for (Object e : readEntryMap.values()) { if(e instanceof CacheEntry) { result.add((CacheEntry) e); } else { System.err.println("e=" + e); } } for (Object e : asyncReadEntryMap.values()) { if(e instanceof CacheEntry) { result.add((CacheEntry) e); } else { System.err.println("e=" + e); } } for (Object e : externalReadEntryMap.values()) { result.add((CacheEntry) e); } for (Object e : orderedSetMap.values()) { result.add((CacheEntry) e); } return result; } public int calculateCurrentSize() { int realSize = 0; realSize += directPredicatesMap.size(); realSize += directSuperRelationsMap.size(); realSize += principalTypesMap.size(); realSize += uRIToResourceMap.size(); //realSize += namespaceIndexMap.size(); realSize += childMapMap.size(); realSize += relationInfoQueryMap.size(); realSize += superTypesMap.size(); realSize += typeHierarchyMap.size(); realSize += superRelationsMap.size(); realSize += typesMap.size(); realSize += valueQueryMap.size(); realSize += directObjectsMap.size(); realSize += objectsMap.size(); realSize += orderedSetMap.size(); realSize += predicatesMap.size(); realSize += statementsMap.size(); realSize += assertedPredicatesMap.size(); realSize += assertedStatementsMap.size(); realSize += externalReadEntryMap.size(); realSize += asyncReadEntryMap.size(); realSize += readEntryMap.size(); realSize += asyncMultiReadEntryMap.size(); realSize += multiReadEntryMap.size(); return realSize; } CacheCollectionResult allCaches(CacheCollectionResult result) { int level = Integer.MAX_VALUE; directPredicatesMap.values(level, result); directSuperRelationsMap.values(level, result); principalTypesMap.values(level, result); for(CacheEntryBase e : uRIToResourceMap.values()) if(e.getLevel() <= level) result.add(e); // for(CacheEntryBase e : namespaceIndexMap.values()) // if(e.getLevel() <= level) // result.add(e); childMapMap.values(level, result); relationInfoQueryMap.values(level, result); superTypesMap.values(level, result); typeHierarchyMap.values(level, result); superRelationsMap.values(level, result); typesMap.values(level, result); valueQueryMap.values(level, result); directObjectsMap.values(level, result); objectsMap.values(level, result); orderedSetMap.values(level, result); predicatesMap.values(level, result); statementsMap.values(level, result); assertedPredicatesMap.values(level, result); assertedStatementsMap.values(level, result); externalReadEntryMap.values(level, result); asyncReadEntryMap.values(level, result); readEntryMap.values(level, result); asyncMultiReadEntryMap.values(level, result); multiReadEntryMap.values(level, result); return result; } public void scanPending() { ArrayList entries = new ArrayList(); entries.addAll(directPredicatesMap.values()); entries.addAll(directSuperRelationsMap.values()); entries.addAll(principalTypesMap.values()); entries.addAll(uRIToResourceMap.values()); //entries.addAll(namespaceIndexMap.values()); entries.addAll(childMapMap.values()); entries.addAll(relationInfoQueryMap.values()); entries.addAll(superTypesMap.values()); entries.addAll(superRelationsMap.values()); entries.addAll(typesMap.values()); entries.addAll(valueQueryMap.values()); entries.addAll(directObjectsMap.values()); entries.addAll(objectsMap.values()); entries.addAll(orderedSetMap.values()); entries.addAll(predicatesMap.values()); entries.addAll(orderedSetMap.values()); entries.addAll(statementsMap.values()); // entries.addAll(assertedObjectsMap.values()); entries.addAll(assertedPredicatesMap.values()); entries.addAll(assertedStatementsMap.values()); entries.addAll(externalReadEntryMap.values()); entries.addAll(asyncReadEntryMap.values()); entries.addAll(externalReadEntryMap.values()); entries.addAll(readEntryMap.values()); entries.addAll(asyncMultiReadEntryMap.values()); entries.addAll(multiReadEntryMap.values()); entries.addAll(readEntryMap.values()); System.out.println(entries.size() + " entries."); for(Object e : entries) { if(e instanceof CacheEntry) { CacheEntry en = (CacheEntry)e; if(en.isPending()) System.out.println("pending " + e); if(en.isExcepted()) System.out.println("excepted " + e); if(en.isDiscarded()) System.out.println("discarded " + e); if(en.isRefuted()) System.out.println("refuted " + e); if(en.isFresh()) System.out.println("fresh " + e); } else { //System.out.println("Unknown object " + e); } } } public static void waitPending(ReadGraphImpl graph, CacheEntry entry) throws DatabaseException { int counter = 0; while(entry.isPending()) { try { boolean performed = false;//graph.performPending(); if(!performed) { Thread.sleep(1); counter++; if(counter > 30000) { CacheEntryBase base = ((CacheEntryBase)entry); // if(base.created != null) { // System.err.println("created:"); // base.created.printStackTrace(); // } // if(base.performed != null) { // System.err.println("performed:"); // base.performed.printStackTrace(); // } // if(base.ready != null) { // System.err.println("ready:"); // base.ready.printStackTrace(); // } new Exception("Timeout waiting for request to complete: " + entry.getOriginalRequest()).printStackTrace(); throw new DatabaseException("Timeout waiting for request to complete." + entry.getOriginalRequest()); //System.err.println("asd"); //base.getQuery().recompute(null, null, entry); } } } catch (InterruptedException e) { } } } ////////////////////////////////////// public static Collection entriesObjects(QueryProcessor processor, int r1) { synchronized(processor.cache.objectsMap) { return processor.cache.objectsMap.values(r1); } } public static Collection entriesObjects(QueryProcessor processor) { synchronized(processor.cache.objectsMap) { return processor.cache.objectsMap.values(); } } public static Collection entriesDirectPredicates(QueryProcessor processor) { synchronized(processor.cache.directPredicatesMap) { return processor.cache.directPredicatesMap.values(); } } static final Collection entriesDirectObjects(final QueryProcessor processor, final int r1) { DoubleKeyQueryHashMap hash = processor.cache.directObjectsMap; return hash.values(r1); } static final Collection entriesStatements(final QueryProcessor processor, final int r1) { return processor.cache.statementsMap.values(r1); } static final Types entryTypes(final QueryProcessor processor, final int r) { return (Types)processor.cache.typesMap.get(r); } static final PrincipalTypes entryPrincipalTypes(final QueryProcessor processor, final int r) { return (PrincipalTypes)processor.cache.principalTypesMap.get(r); } static final OrderedSet entryOrderedSet(final QueryProcessor processor, final int r) { return (OrderedSet)processor.cache.orderedSetMap.get(r); } static final ValueQuery entryValueQuery(final QueryProcessor processor, final int r) { return (ValueQuery)processor.cache.valueQueryMap.get(r); } static final DirectPredicates entryDirectPredicates(final QueryProcessor processor, final int r) { return (DirectPredicates)processor.cache.directPredicatesMap.get(r); } public static final ReadEntry entryRead(final QueryProcessor processor, final Read request) { return (ReadEntry)processor.cache.readEntryMap.get(request); } public static final MultiReadEntry entryMultiRead(final QueryProcessor processor, final MultiRead request) { return (MultiReadEntry)processor.cache.multiReadEntryMap.get(request); } public static final AsyncReadEntry entryAsyncRead(final QueryProcessor processor, final AsyncRead request) { return (AsyncReadEntry)processor.cache.asyncReadEntryMap.get(request); } public static final AsyncMultiReadEntry entryAsyncMultiRead(final QueryProcessor processor, final AsyncMultiRead request) { return (AsyncMultiReadEntry)processor.cache.asyncMultiReadEntryMap.get(request); } protected static final long keyR2(long r1, long r2) { long result = (r1<<32) | (r2 & 0xffffffffL); return result; } protected static final T id(T o) { return o; } protected static final int keyR(int r) { return r; } protected static final String keyID(String id) { return id; } protected static InternalProcedure emptyIntSetProcedure = new InternalProcedure() { @Override public void execute(ReadGraphImpl graph, IntSet result) { } @Override public void exception(ReadGraphImpl graph, Throwable throwable) { } }; protected static InternalProcedure emptyBytesProcedure = new InternalProcedure() { @Override public void execute(ReadGraphImpl graph, byte[] bytes) { } @Override public void exception(ReadGraphImpl graph, Throwable throwable) { } }; protected static InternalProcedure emptyIntegerProcedure = new InternalProcedure() { @Override public void execute(ReadGraphImpl graph, Integer i) { } @Override public void exception(ReadGraphImpl graph, Throwable throwable) { } }; protected static InternalProcedure> emptyNamespaceProcedure = new InternalProcedure>() { @Override public void execute(ReadGraphImpl graph, TObjectIntHashMap i) { } @Override public void exception(ReadGraphImpl graph, Throwable throwable) { } }; protected static InternalProcedure emptyRelationInfoProcedure = new InternalProcedure() { @Override public void execute(ReadGraphImpl graph, RelationInfo i) { } @Override public void exception(ReadGraphImpl graph, Throwable throwable) { } }; protected static InternalProcedure> emptyChildMapProcedure = new InternalProcedure>() { @Override public void execute(ReadGraphImpl graph, ObjectResourceIdMap i) { } @Override public void exception(ReadGraphImpl graph, Throwable throwable) { } }; protected static IntProcedure emptyIntProcedure = new IntProcedure() { @Override public void finished(ReadGraphImpl graph) { } @Override public void execute(ReadGraphImpl graph, int i) { } @Override public void exception(ReadGraphImpl graph, Throwable throwable) { } }; protected static TripleIntProcedure emptyTripleIntProcedure = new TripleIntProcedure() { @Override public void execute(ReadGraphImpl graph, int s, int p, int o) { } @Override public void finished(ReadGraphImpl graph) { } @Override public void exception(ReadGraphImpl graph, Throwable throwable) { } }; protected static AsyncProcedure emptyAsyncProcedure = new AsyncProcedure() { @Override public void execute(AsyncReadGraph graph, Object result) { } @Override public void exception(AsyncReadGraph graph, Throwable throwable) { } }; protected static AsyncMultiProcedure emptyAsyncMultiProcedure = new AsyncMultiProcedure() { @Override public void execute(AsyncReadGraph graph, Object result) { } @Override public void finished(AsyncReadGraph graph) { } @Override public void exception(AsyncReadGraph graph, Throwable throwable) { } }; protected static SyncMultiProcedure emptySyncMultiProcedure = new SyncMultiProcedure() { @Override public void execute(ReadGraph graph, Object result) { } @Override public void finished(ReadGraph graph) { } @Override public void exception(ReadGraph graph, Throwable throwable) { } }; protected static InternalProcedure emptyProcedureTypes = emptyIntSetProcedure; protected static InternalProcedure emptyProcedureSuperTypes = emptyIntSetProcedure; protected static InternalProcedure emptyProcedureTypeHierarchy = emptyIntSetProcedure; protected static InternalProcedure emptyProcedureSuperRelations = emptyIntSetProcedure; protected static InternalProcedure emptyProcedurePredicates = emptyIntSetProcedure; protected static InternalProcedure emptyProcedureDirectPredicates = emptyIntSetProcedure; protected static IntProcedure emptyProcedureObjects = emptyIntProcedure; protected static IntProcedure emptyProcedureDirectObjects = emptyIntProcedure; protected static IntProcedure emptyProcedurePrincipalTypes = emptyIntProcedure; protected static IntProcedure emptyProcedureDirectSuperRelations = emptyIntProcedure; protected static IntProcedure emptyProcedureAssertedPredicates = emptyIntProcedure; protected static IntProcedure emptyProcedureOrderedSet = emptyIntProcedure; protected static TripleIntProcedure emptyProcedureStatements = emptyTripleIntProcedure; protected static TripleIntProcedure emptyProcedureAssertedStatements = emptyTripleIntProcedure; protected static InternalProcedure emptyProcedureValueQuery = emptyBytesProcedure; protected static InternalProcedure emptyProcedureURIToResource = emptyIntegerProcedure; protected static InternalProcedure> emptyProcedureNamespaceIndex = emptyNamespaceProcedure; protected static InternalProcedure> emptyProcedureChildMap = emptyChildMapProcedure; protected static InternalProcedure emptyProcedureRelationInfoQuery = emptyRelationInfoProcedure; protected static AsyncProcedure emptyProcedureReadEntry = emptyAsyncProcedure; protected static AsyncProcedure emptyProcedureAsyncReadEntry = emptyAsyncProcedure; protected static SyncMultiProcedure emptyProcedureMultiReadEntry = emptySyncMultiProcedure; protected static AsyncMultiProcedure emptyProcedureAsyncMultiReadEntry = emptyAsyncMultiProcedure; protected static AsyncProcedure emptyProcedureExternalReadEntry = emptyAsyncProcedure; static class AsyncProcedureWrapper implements AsyncProcedure { private AsyncProcedure procedure; private T result = null; private Throwable throwable = null; private Semaphore s = new Semaphore(0); AsyncProcedureWrapper(AsyncProcedure procedure) { this.procedure = procedure; } @Override public void execute(AsyncReadGraph graph, T result) { if(procedure != null) procedure.execute(graph, result); this.result = result; s.release(); } @Override public void exception(AsyncReadGraph graph, Throwable throwable) { if(procedure != null) procedure.exception(graph, throwable); this.throwable = throwable; s.release(); } public T get() throws DatabaseException { try { s.acquire(); } catch (InterruptedException e) { e.printStackTrace(); } if(throwable != null) { if(throwable instanceof DatabaseException) throw (DatabaseException)throwable; else throw new DatabaseException(throwable); } else { return result; } } } static class ExternalProcedureWrapper implements AsyncProcedure { private Procedure procedure; private T result = null; private Throwable throwable = null; ExternalProcedureWrapper(Procedure procedure) { this.procedure = procedure; } @Override public void execute(AsyncReadGraph graph, T result) { if(procedure != null) procedure.execute(result); this.result = result; } @Override public void exception(AsyncReadGraph graph, Throwable throwable) { if(procedure != null) procedure.exception(throwable); this.throwable = throwable; } public T get() throws DatabaseException { if(throwable != null) { if(throwable instanceof DatabaseException) throw (DatabaseException)throwable; else throw new DatabaseException(throwable); } else { return result; } } } static class InternalProcedureWrapper implements InternalProcedure { private InternalProcedure procedure; private T result = null; private Throwable throwable = null; InternalProcedureWrapper(InternalProcedure procedure) { this.procedure = procedure; } @Override public void execute(ReadGraphImpl graph, T result) throws DatabaseException { if(procedure != null) procedure.execute(graph, result); this.result = result; } @Override public void exception(ReadGraphImpl graph, Throwable throwable) throws DatabaseException { if(procedure != null) procedure.exception(graph, throwable); this.throwable = throwable; } public T get() throws DatabaseException { if(throwable != null) { if(throwable instanceof DatabaseException) throw (DatabaseException)throwable; else throw new DatabaseException(throwable); } else { return result; } } } static class IntSetWrapper implements IntProcedure { private IntProcedure procedure; private final IntSet result; private Throwable throwable = null; IntSetWrapper(ReadGraphImpl graph, IntProcedure procedure) { this.procedure = procedure; result = new IntSet(graph.processor.querySupport); } @Override public void execute(ReadGraphImpl graph, int i) throws DatabaseException { if(procedure != null) procedure.execute(graph, i); result.add(i); } @Override public void exception(ReadGraphImpl graph, Throwable throwable) throws DatabaseException { if(procedure != null) procedure.exception(graph, throwable); this.throwable = throwable; } @Override public void finished(ReadGraphImpl graph) throws DatabaseException { if(procedure != null) procedure.finished(graph); } public IntSet get() throws DatabaseException { if(throwable != null) { if(throwable instanceof DatabaseException) throw (DatabaseException)throwable; else throw new DatabaseException(throwable); } else { return result; } } } static class TripleIntProcedureWrapper implements TripleIntProcedure { private TripleIntProcedure procedure; private IntArray result = new IntArray(); private Throwable throwable = null; TripleIntProcedureWrapper(TripleIntProcedure procedure) { this.procedure = procedure; } @Override public void execute(ReadGraphImpl graph, int i1, int i2, int i3) throws DatabaseException { if(procedure != null) procedure.execute(graph, i1, i2, i3); result.add(i1); result.add(i2); result.add(i3); } @Override public void exception(ReadGraphImpl graph, Throwable throwable) throws DatabaseException { if(procedure != null) procedure.exception(graph, throwable); this.throwable = throwable; } @Override public void finished(ReadGraphImpl graph) throws DatabaseException { if(procedure != null) procedure.finished(graph); } public IntArray get() throws DatabaseException { if(throwable != null) { if(throwable instanceof DatabaseException) throw (DatabaseException)throwable; else throw new DatabaseException(throwable); } else { return result; } } } public static T resultExternalReadEntry(ReadGraphImpl graph, ExternalRead r, CacheEntry parent, ListenerBase listener, Procedure procedure) throws DatabaseException { ExternalProcedureWrapper wrap = new ExternalProcedureWrapper<>(procedure); QueryCache.runnerExternalReadEntry(graph, r, parent, listener, wrap); return wrap.get(); } public static T resultAsyncReadEntry(ReadGraphImpl graph, AsyncRead r, CacheEntry parent, ListenerBase listener, AsyncProcedure procedure) throws DatabaseException { return (T)QueryCache.runnerAsyncReadEntry(graph, r, parent, listener, procedure, true); } public static byte[] resultValueQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener) throws DatabaseException { InternalProcedureWrapper wrap = new InternalProcedureWrapper<>(null); QueryCache.runnerValueQuery(graph, r, parent, listener, wrap); return wrap.get(); } public static RelationInfo resultRelationInfoQuery(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener) throws DatabaseException { InternalProcedureWrapper wrap = new InternalProcedureWrapper<>(null); QueryCache.runnerRelationInfoQuery(graph, r, parent, listener, wrap); return wrap.get(); } public static IntSet resultSuperRelations(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener) throws DatabaseException { InternalProcedureWrapper wrap = new InternalProcedureWrapper<>(null); QueryCache.runnerSuperRelations(graph, r, parent, listener, wrap); return wrap.get(); } public static IntSet resultSuperTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener) throws DatabaseException { InternalProcedureWrapper wrap = new InternalProcedureWrapper<>(null); QueryCache.runnerSuperTypes(graph, r, parent, listener, wrap); return wrap.get(); } public static IntSet resultTypes(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener) throws DatabaseException { InternalProcedureWrapper wrap = new InternalProcedureWrapper<>(null); QueryCache.runnerTypes(graph, r, parent, listener, wrap); return wrap.get(); } public static IntSet resultPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener) throws DatabaseException { InternalProcedureWrapper wrap = new InternalProcedureWrapper<>(null); QueryCache.runnerPredicates(graph, r, parent, listener, wrap); return wrap.get(); } public static IntSet resultDirectPredicates(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener) throws DatabaseException { InternalProcedureWrapper wrap = new InternalProcedureWrapper<>(null); QueryCache.runnerDirectPredicates(graph, r, parent, listener, wrap); return wrap.get(); } public static IntArray resultAssertedStatements(ReadGraphImpl graph, int r1, int r2, CacheEntry parent, ListenerBase listener) throws DatabaseException { TripleIntProcedureWrapper wrap = new TripleIntProcedureWrapper(null); QueryCache.runnerAssertedStatements(graph, r1, r2, parent, listener, wrap); return wrap.get(); } public static Integer resultURIToResource(ReadGraphImpl graph, String id, CacheEntry parent, ListenerBase listener) throws DatabaseException { InternalProcedureWrapper wrap = new InternalProcedureWrapper(null); QueryCache.runnerURIToResource(graph, id, parent, listener, wrap); return wrap.get(); } public static ObjectResourceIdMap resultChildMap(ReadGraphImpl graph, int r, CacheEntry parent, ListenerBase listener) throws DatabaseException { InternalProcedureWrapper> wrap = new InternalProcedureWrapper>(null); QueryCache.runnerChildMap(graph, r, parent, listener, wrap); return wrap.get(); } static boolean shouldCache(QueryProcessor processor, int r) { return processor.isImmutable(r); } static boolean shouldCache(QueryProcessor processor, int r, int r2) { return processor.isImmutable(r); } static boolean shouldCache(QueryProcessor processor, Object o) { return false; } }