X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FQueryCacheBase.java;fp=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2Fquery%2FQueryCacheBase.java;h=54efda83976d8255f549ec0cd1cf41df8fc07e6c;hp=446e9c641406464de62e4cb484c66d02df4ca70f;hb=0db1af75cd14f99f16c42c920562708abf37be93;hpb=b000e272429e157638c0384878b07b8dcd758472 diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java index 446e9c641..54efda839 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java @@ -70,8 +70,6 @@ public class QueryCacheBase { protected final StableHashMap asyncMultiReadEntryMap; protected final StableHashMap externalReadEntryMap; - final THashMap> listeners; - public final QuerySupport querySupport; public QueryCacheBase(QuerySupport querySupport, int threads) { @@ -104,91 +102,8 @@ public class QueryCacheBase { asyncMultiReadEntryMap = new StableHashMap(); multiReadEntryMap = new StableHashMap(); externalReadEntryMap = new StableHashMap(); - listeners = new THashMap>(10, 0.75f); } -// public Object performQuery(ReadGraphImpl parentGraph, final AsyncRead query, final CacheEntryBase entry_, AsyncProcedure procedure_) throws DatabaseException { -// -// AsyncReadEntry entry = (AsyncReadEntry)entry_; -// AsyncProcedure procedure = (AsyncProcedure)procedure_; -// -// ReadGraphImpl queryGraph = parentGraph.withParent(entry_); -// -// try { -// -// query.perform(queryGraph, new AsyncProcedure() { -// -// @Override -// public void execute(AsyncReadGraph returnGraph, T result) { -// ReadGraphImpl impl = (ReadGraphImpl)returnGraph; -// entry.addOrSet(parentGraph, result); -// try { -// procedure.execute(parentGraph, result); -// } catch (Throwable t) { -// t.printStackTrace(); -// } -//// parentBarrier.dec(query); -// } -// -// @Override -// public void exception(AsyncReadGraph returnGraph, Throwable t) { -// ReadGraphImpl impl = (ReadGraphImpl)returnGraph; -//// AsyncReadGraph resumeGraph = finalParentGraph.newAsync(); -// entry.except(parentGraph, t); -// try { -// procedure.exception(parentGraph, t); -// } catch (Throwable t2) { -// t2.printStackTrace(); -// } -//// parentBarrier.dec(query); -// } -// -// @Override -// public String toString() { -// return procedure.toString(); -// } -// -// }); -// -// } catch (Throwable t) { -// -// entry.except(t); -// try { -// procedure.exception(parentGraph, t); -// } catch (Throwable t2) { -// t2.printStackTrace(); -// } -//// parentBarrier.dec(query); -// -// } -// -// return null; -// -// } - -// public Object performQuery(ReadGraphImpl parentGraph, final Read query, final CacheEntryBase entry_, AsyncProcedure procedure_) throws DatabaseException { -// -// ReadGraphImpl queryGraph = parentGraph.withParent(entry_); -// -// ReadEntry entry = (ReadEntry)entry_; -// -// try { -// -// T result = (T)query.perform(queryGraph); -// entry.addOrSet(queryGraph, result); -// -// return (T)entry.get(parentGraph, procedure_); -// -// } catch (Throwable t) { -// -// entry.except(t); -// return (T)entry.get(parentGraph, procedure_); -// -// } -// -// } - - public Object performQuery(ReadGraphImpl parentGraph, final AsyncMultiRead query, final CacheEntryBase entry_, Object procedure_) throws DatabaseException { ReadGraphImpl queryGraph = parentGraph.withParent(entry_); @@ -315,82 +230,6 @@ public class QueryCacheBase { } - public ListenerEntry registerDependencies(ReadGraphImpl graph, CacheEntry child, CacheEntry parent, ListenerBase listener, Object procedure, boolean inferred) { - - if (parent != null && !inferred) { - try { - if(!child.isImmutable(graph)) { - synchronized(child) { - child.addParent(parent); - } - } - } catch (DatabaseException e) { - Logger.defaultLogError(e); - } - if (Development.DEVELOPMENT) { - if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_DEPENDENCIES, Bindings.BOOLEAN)) { - System.err.println(child + " -> " + parent); - } - } - } - - if (listener != null) { - return registerListener(child, listener, procedure); - } else { - return null; - } - - } - - public synchronized ListenerEntry registerListener(final CacheEntry entry, final ListenerBase base, final Object procedure) { - - assert (entry != null); - - if (base.isDisposed()) - return null; - - return addListener(entry, base, procedure); - - } - - protected void primeListenerEntry(final ListenerEntry entry, final Object result) { - entry.setLastKnown(result); - } - - private ListenerEntry addListener(CacheEntry entry, ListenerBase base, Object procedure) { - - assert (entry != null); - assert (procedure != null); - - ArrayList list = listeners.get(entry); - if (list == null) { - list = new ArrayList(1); - listeners.put(entry, list); - } - - ListenerEntry result = new ListenerEntry(entry, base, procedure); - int currentIndex = list.indexOf(result); - // There was already a listener - if(currentIndex > -1) { - ListenerEntry current = list.get(currentIndex); - if(!current.base.isDisposed()) return null; - list.set(currentIndex, result); - } else { - list.add(result); - } - - if (Development.DEVELOPMENT) { - if(Development.getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) { - new Exception().printStackTrace(); - System.err.println("addListener -> " + list.size() + " " + entry + " " + base + " " + procedure); - } - } - - return result; - - } - - public Collection getRootList() { ArrayList result = new ArrayList();