]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.acorn/src/org/simantics/acorn/cluster/ClusterSmall.java
Removed contact application support prints
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / cluster / ClusterSmall.java
index b84d4d51fe84fef82e1dc1f8a63fdb817cf3c82b..d20ddae6cf53d765314cad11250a0a460c7731c5 100644 (file)
@@ -15,6 +15,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
+import java.util.function.Consumer;
 
 import org.simantics.acorn.exception.IllegalAcornStateException;
 import org.simantics.acorn.internal.ClusterChange;
@@ -37,8 +38,8 @@ import org.simantics.db.impl.IClusterTable;
 import org.simantics.db.impl.Table;
 import org.simantics.db.impl.TableHeader;
 import org.simantics.db.impl.graph.ReadGraphImpl;
-import org.simantics.db.procedure.AsyncContextMultiProcedure;
-import org.simantics.db.procedure.AsyncMultiProcedure;
+import org.simantics.db.procedure.SyncContextMultiProcedure;
+import org.simantics.db.procedure.SyncMultiProcedure;
 import org.simantics.db.procore.cluster.ClusterMapSmall;
 import org.simantics.db.procore.cluster.ClusterTraits;
 import org.simantics.db.procore.cluster.ClusterTraitsSmall;
@@ -52,8 +53,8 @@ import org.simantics.db.procore.cluster.ValueTableSmall;
 import org.simantics.db.service.Bytes;
 import org.simantics.db.service.ClusterUID;
 import org.simantics.db.service.ResourceUID;
-import org.simantics.utils.datastructures.Callback;
 
+import fi.vtt.simantics.procore.internal.SessionImplSocket;
 import gnu.trove.map.hash.TIntShortHashMap;
 import gnu.trove.procedure.TIntProcedure;
 import gnu.trove.set.hash.TIntHashSet;
@@ -300,7 +301,7 @@ final public class ClusterSmall extends ClusterImpl {
         return objectTable.getSingleObject(objectIndex, support, this);
     }
 
-    public void forObjects(ReadGraphImpl graph, int resourceKey, int predicateKey, int objectIndex, AsyncMultiProcedure<Resource> procedure,
+    public void forObjects(ReadGraphImpl graph, int resourceKey, int predicateKey, int objectIndex, SyncMultiProcedure<Resource> procedure,
             ClusterSupport support) throws DatabaseException {
         if (DEBUG)
             System.out.println("ClusterSmall.forObjects1: rk=" + resourceKey + " pk=" + predicateKey);
@@ -314,7 +315,7 @@ final public class ClusterSmall extends ClusterImpl {
         objectTable.foreachObject(graph, objectIndex, procedure, this);
     }
 
-    public <C> void forObjects(ReadGraphImpl graph, int resourceKey, int predicateKey, int objectIndex, C context, AsyncContextMultiProcedure<C, Resource> procedure,
+    public <C> void forObjects(ReadGraphImpl graph, int resourceKey, int predicateKey, int objectIndex, C context, SyncContextMultiProcedure<C, Resource> procedure,
             ClusterSupport support) throws DatabaseException {
         if (DEBUG)
             System.out.println("ClusterSmall.forObjects1: rk=" + resourceKey + " pk=" + predicateKey);
@@ -408,29 +409,28 @@ final public class ClusterSmall extends ClusterImpl {
 
     @Override
     public void forObjects(ReadGraphImpl graph, int resourceKey,
-            int predicateKey, AsyncMultiProcedure<Resource> procedure) throws DatabaseException {
+            int predicateKey, SyncMultiProcedure<Resource> procedure) throws DatabaseException {
        
-       throw new UnsupportedOperationException();
-       
-//        SessionImplSocket session = (SessionImplSocket)graph.getSession();
-//        ClusterSupport support = session.clusterTranslator;
-//        if (DEBUG)
-//            System.out.println("ClusterSmall.forObjects3: rk=" + resourceKey + " pk=" + predicateKey);
-//        final int resourceIndex = ClusterTraitsBase.getResourceIndexFromResourceKey(resourceKey);
-//        final int pRef = getInternalReferenceOrZero2(predicateKey, support);
-//        final int completeType = ClusterTraitsBase.getCompleteTypeIntFromResourceKey(predicateKey);
-//        final ClusterI.CompleteTypeEnum pCompleteType = CompleteTypeEnum.make(completeType);
-//        if (completeType > 0) {
-//            resourceTable.foreachObject(resourceIndex, graph, procedure, support, pRef, pCompleteType, completeTable, this);
-//            return;
-//        }
-//        final int predicateIndex = (int)resourceTable.table[(resourceIndex<<1) - 1 + resourceTable.offset] & 0xFFFFFF;
-//        if (0 == predicateIndex) {
-//            resourceTable.foreachObject(resourceIndex, graph, procedure, support, pRef, pCompleteType, completeTable, this);
-//            return;
-//        }
-//        int objectIndex = predicateTable.getObjectIndex(predicateIndex, pRef & 0xFFFF);
-//        forObjects(graph, resourceKey, predicateKey, objectIndex, procedure, support);
+        SessionImplSocket session = (SessionImplSocket)graph.getSession();
+        ClusterSupport support = session.clusterTranslator;
+        if (DEBUG)
+            System.out.println("ClusterSmall.forObjects3: rk=" + resourceKey + " pk=" + predicateKey);
+        final int resourceIndex = ClusterTraitsBase.getResourceIndexFromResourceKey(resourceKey);
+        final int pRef = getInternalReferenceOrZero2(predicateKey, support);
+        final int completeType = ClusterTraitsBase.getCompleteTypeIntFromResourceKey(predicateKey);
+        final ClusterI.CompleteTypeEnum pCompleteType = CompleteTypeEnum.make(completeType);
+        if (completeType > 0) {
+            resourceTable.foreachObject(resourceIndex, graph, procedure, support, pRef, pCompleteType, completeTable, this);
+            return;
+        }
+        final int predicateIndex = (int)resourceTable.table[(resourceIndex<<1) - 1 + resourceTable.offset] & 0xFFFFFF;
+        if (0 == predicateIndex) {
+            resourceTable.foreachObject(resourceIndex, graph, procedure, support, pRef, pCompleteType, completeTable, this);
+            return;
+        }
+        int objectIndex = predicateTable.getObjectIndex(predicateIndex, pRef & 0xFFFF);
+        forObjects(graph, resourceKey, predicateKey, objectIndex, procedure, support);
+        
     }
 
     public void forObjects(ReadGraphImpl graph, int resourceKey, ForEachObjectProcedure procedure) throws DatabaseException {
@@ -596,7 +596,7 @@ final public class ClusterSmall extends ClusterImpl {
                 support.setStreamOff(false);
             ClusterI cluster2 = cluster.addRelation(sResourceKey, pResourceKey, oResourceKey, support);
             if (cluster != cluster2)
-                throw new DatabaseException("Internal error. Contact application support.");
+                throw new DatabaseException("Internal error, cluster mismatch.");
             return cluster;
         }
 //        check();
@@ -642,7 +642,7 @@ final public class ClusterSmall extends ClusterImpl {
                 support.setStreamOff(false);
             ClusterI cluster2 = cluster.addRelation(sResourceKey, pResourceKey, oResourceKey, support);
             if (cluster != cluster2)
-                throw new DatabaseException("Internal error. Contact application support.");
+                throw new DatabaseException("Internal error, cluster mismatch.");
             return cluster;
         }
 //        check();
@@ -1018,7 +1018,7 @@ final public class ClusterSmall extends ClusterImpl {
     }
 
     @Override
-    public void load(Callback<DatabaseException> r) {
+    public void load(Consumer<DatabaseException> r) {
         throw new Error("Not supported.");
     }
 
@@ -1275,7 +1275,7 @@ final public class ClusterSmall extends ClusterImpl {
     }
 
     @Override
-    public Table getForeignTable() {
+    public Table<?> getForeignTable() {
         return foreignTable;
     }