+ public void adjustCachedSize(long l, ClusterI cluster) {
+ if (l != 0) {
+ //System.out.println("ClusterTable: adjusting cluster table cached size by " + l + ": " + sizeInBytes + " -> "
+ // + (sizeInBytes + l) + ", for cluster " + cluster.getClusterId() + " (" + cluster + ")");
+ sizeInBytes += l;
+ }
+ }
+
+ private void validateSize() {
+ if (!VALIDATE_SIZE)
+ return;
+
+// System.out.println("validating cached cluster sizes: " + sizeInBytes + ", hashMap.size="
+// + clusters.hashMap.size() + ", importanceMap.size=" + importanceMap.size());
+
+ int i = clusterArray.length;
+ long size = 0;
+ for (int j = 0; j < i; ++j) {
+ ClusterI c = clusterArray[j];
+ if (c == null)
+ continue;
+ size += c.getCachedSize();
+ }
+ if (sizeInBytes != size) {
+ if (!dirtySizeInBytes)
+ System.out.println("BUG: CACHED CLUSTER SIZE DIFFERS FROM CALCULATED: " + sizeInBytes + " != " + size + ", delta = " + (sizeInBytes - size));
+ //else System.out.println("\"BUG?\": SIZES DIFFER: " + sizeInBytes + " != " + size + ", delta = " + (sizeInBytes - size));
+ }
+
+ int ims = importanceMap.size();
+ int[] hms = {0};
+ clusters.hashMap.forEachEntry((cid, c) -> {
+ if (c != null && !c.isWriteOnly() && !c.isEmpty() && c.isLoaded()) {
+ //System.out.println(cid + ": " + c);
+ hms[0]++;
+ }
+ return true;
+ });
+ if (Math.abs(ims-hms[0]) > 0) {
+ System.out.println("BUG2: hashmap and importanceMap sizes differ: " + hms[0] + " != " + ims + ", delta=" + (hms[0] - ims));
+ }
+ }
+