]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Better fix for ClusterTable maps going out of sync 18/1718/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 13 Apr 2018 21:31:15 +0000 (00:31 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 13 Apr 2018 21:31:15 +0000 (00:31 +0300)
ClusterSmall.toBig was not copying importance over to the constructed
ClusterBig causing importanceMap to go out of sync on the first call to
ClusterSmall.toBig.

refs #7724

Change-Id: I6e56b7f94962de3ec243a9d50775e649f930d0d2

bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java
bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterBig.java
bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterSmall.java

index d70d53405fa5ab8df042bbbf69e7b53af77b22c2..ceedece7d89c6fb925a57546e4e1a1f83fc55a48 100644 (file)
@@ -297,9 +297,7 @@ public final class ClusterTable implements IClusterTable {
         if (existing.hasVirtual())
             cluster.markVirtual();
 
-        long existingImportance = existing.getImportance();
-        if (existingImportance != 0)
-            importanceMap.remove(existingImportance);
+        importanceMap.remove(existing.getImportance());
         if (collectorPolicy != null)
             collectorPolicy.removed((ClusterImpl)existing);
 
@@ -1206,8 +1204,8 @@ public final class ClusterTable implements IClusterTable {
         int ims = importanceMap.size();
         int ihms = countImportantClusters();
 
-//        System.out.format("[%s] Validating ClusterTable: byteSize=%d, hashMap=%d/%d, importanceMap=%d%n",
-//                place, sizeInBytes, ihms, clusters.hashMap.size(), ims);
+//        System.out.format("[ClusterTable.%s] Validating: byteSize=%d (%d MB), hashMap=%d/%d, importanceMap=%d%n",
+//                place, sizeInBytes, sizeInBytes / (1024*1024), ihms, clusters.hashMap.size(), ims);
 
         int i = clusterArray.length;
         long size = 0;
index 2d5e462d6d7c692bf2b37cd313fd1d14bb41fd22..29f34b45f9904527412db0817c0dfeb6702b2c0e 100644 (file)
@@ -98,7 +98,7 @@ final public class ClusterBig extends ClusterImpl {
         this.clusterMap = new ClusterMap(foreignTable, flatTable);
         this.clusterSupport = support;
         this.clusterBits = ClusterTraitsBase.getClusterBits(clusterKey);
-        this.importance = clusterTable.timeCounter();
+        this.importance = -clusterTable.timeCounter();
         clusterTable.markImmutable(this, getImmutable());
     }
     void analyse() {
index 1a8af51433610146897dcfd1d99225bcbd60921d..ead0099847e70aacf5914535b74600c4d84dbb06 100644 (file)
@@ -40,7 +40,6 @@ import fi.vtt.simantics.procore.internal.ClusterStream;
 import fi.vtt.simantics.procore.internal.ClusterTable;
 import fi.vtt.simantics.procore.internal.SessionImplSocket;
 import gnu.trove.map.hash.TIntShortHashMap;
-import gnu.trove.procedure.TIntProcedure;
 import gnu.trove.set.hash.TIntHashSet;
 
 final public class ClusterSmall extends ClusterImpl {
@@ -1009,6 +1008,7 @@ final public class ClusterSmall extends ClusterImpl {
         }
         if (deleted) return null; // Can't convert deleted cluster to big.
         ClusterBig big = new ClusterBig(getClusterUID(), clusterKey, support);
+        big.setImportance(importance);
         big.cc = this.cc;
         big.cc.clusterImpl = this;
         resourceTable.toBig(big, support, this);