fix longSize() implementation for closed map

This commit is contained in:
Dmitry Pisklov
2020-05-28 16:54:28 +01:00
parent 21b2676a3c
commit d7c318986b
@@ -131,7 +131,7 @@ public class VanillaChronicleMap<K, V, R>
alignment = wireIn.read(() -> "alignment").int32();
worstAlignment = wireIn.read(() -> "worstAlignment").int32();
maxBloatFactor = wireIn.read(() -> "maxBloatFactor").float64();
maxBloatFactor = wireIn.read(() -> "maxBloatFactor").float64();
}
@Override
@@ -203,12 +203,13 @@ public class VanillaChronicleMap<K, V, R>
@Override
public final long longSize() {
long result = 0L;
try (IterationContext<K, V, ?> c = iterationContext()) {
for (int segmentIndex = 0; segmentIndex < segments(); segmentIndex++) {
c.initSegmentIndex(segmentIndex);
result += c.size();
if (!isClosed())
try (IterationContext<K, V, ?> c = iterationContext()) {
for (int segmentIndex = 0; segmentIndex < segments(); segmentIndex++) {
c.initSegmentIndex(segmentIndex);
result += c.size();
}
}
}
return result;
}