]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AssertedPredicates.java
Trying to remove synchronization problems
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / query / AssertedPredicates.java
index 8013c1a47d2c0684e0a5a2cf1a3084ab079fcde6..b4104e965fbc0b56be90fc40a8f0cd07eef5ab3a 100644 (file)
@@ -15,11 +15,9 @@ import org.simantics.db.RelationInfo;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.impl.graph.ReadGraphImpl;
 import org.simantics.db.impl.procedure.IntProcedureAdapter;
-import org.simantics.db.impl.procedure.InternalProcedure;
-import org.simantics.db.procedure.ListenerBase;
 
 
-final public class AssertedPredicates extends CollectionUnaryQuery<IntProcedure> {
+final public class AssertedPredicates extends UnaryQuery<IntProcedure> {
        
     AssertedPredicates(final int r) {
         super(r);
@@ -28,11 +26,21 @@ final public class AssertedPredicates extends CollectionUnaryQuery<IntProcedure>
     public static AssertedPredicates newInstance(final int r) {
         return new AssertedPredicates(r);
     }
-    
-//    final public static void queryEach(ReadGraphImpl graph, final int r, final QueryProcessor provider, final CacheEntry parent, final ListenerBase listener, final IntProcedure procedure) throws DatabaseException {
-//        QueryCache.runnerAssertedPredicates(graph, r, parent, listener, procedure);
-//    }
 
+    @Override
+    final public void clearResult(QuerySupport support) {
+        setResult(new IntArray());
+    }
+    
+    @Override
+    final public void setReady() {
+        super.setReady();
+        IntArray v = (IntArray)getResult();
+        int size = v.size();
+        if(size == 0) setResult(IntArray.EMPTY);
+        else v.trim();
+    }
+    
        @Override
        final public void removeEntry(QueryProcessor provider) {
            provider.cache.remove(this);
@@ -82,7 +90,7 @@ final public class AssertedPredicates extends CollectionUnaryQuery<IntProcedure>
 
        }
 
-    @Override
+    //@Override
     public Object compute(ReadGraphImpl graph, final IntProcedure proc) throws DatabaseException {
 
        QueryProcessor processor = graph.processor;
@@ -160,40 +168,16 @@ final public class AssertedPredicates extends CollectionUnaryQuery<IntProcedure>
         
     }
 
-       final static InternalProcedure<RelationInfo> ip = new InternalProcedure<RelationInfo>() {
-
-               @Override
-               public void execute(ReadGraphImpl graph, RelationInfo result) {
-               }
-
-               @Override
-               public void exception(ReadGraphImpl graph, Throwable throwable) {
-               }
-
-       };
-
-       final static InternalProcedure<IntSet> ip2 = new InternalProcedure<IntSet>() {
-
-               @Override
-               public void execute(ReadGraphImpl graph, IntSet result) {
-               }
-
-               @Override
-               public void exception(ReadGraphImpl graph, Throwable throwable) {
-               }
-
-       };
-
        synchronized private void addOrSetHiding(ReadGraphImpl graph, int add, CacheEntry parent) throws DatabaseException {
 
        assert(isPending());
        
         IntArray value = (IntArray)getResult(); 
-               RelationInfo ri = QueryCacheBase.resultRelationInfoQuery(graph, add, parent, null, ip);
+               RelationInfo ri = QueryCacheBase.resultRelationInfoQuery(graph, add, parent, null);
                if(ri.isFunctional) {
                        // Replace existing functional predicate if found
                        try {
-                               IntSet supers = QueryCache.resultSuperRelations(graph, add, parent, null, ip2); 
+                               IntSet supers = QueryCache.resultSuperRelations(graph, add, parent, null); 
                        if(value.data == null) {
                            if(value.sizeOrData != IntArray.NO_DATA) {
                                if(supers.contains(value.sizeOrData)) {