From: Tuukka Lehtonen Date: Fri, 13 Apr 2018 21:31:15 +0000 (+0300) Subject: Better fix for ClusterTable maps going out of sync X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=980d21d8a26dddd2e57dbffdc8f320a76aa0973e;p=simantics%2Fplatform.git Better fix for ClusterTable maps going out of sync 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 --- diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java index d70d53405..ceedece7d 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java @@ -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; diff --git a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterBig.java b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterBig.java index 2d5e462d6..29f34b45f 100644 --- a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterBig.java +++ b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterBig.java @@ -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() { diff --git a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterSmall.java b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterSmall.java index 1a8af5143..ead009984 100644 --- a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterSmall.java +++ b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterSmall.java @@ -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);