use of it.unimi.dsi.fastutil.objects.Object2LongOpenCustomHashMap in project presto by prestodb.
the class TestBlockRetainedSizeBreakdown method checkRetainedSize.
private static void checkRetainedSize(Block block, boolean getRegionCreateNewObjects) {
AtomicLong objectSize = new AtomicLong();
Object2LongOpenCustomHashMap<Object> trackedObjects = new Object2LongOpenCustomHashMap<>(new ObjectStrategy());
BiConsumer<Object, Long> consumer = (object, size) -> {
objectSize.addAndGet(size);
trackedObjects.addTo(object, 1);
};
block.retainedBytesForEachPart(consumer);
assertEquals(objectSize.get(), block.getRetainedSizeInBytes());
Block copyBlock = block.getRegion(0, block.getPositionCount() / 2);
copyBlock.retainedBytesForEachPart(consumer);
assertEquals(objectSize.get(), block.getRetainedSizeInBytes() + copyBlock.getRetainedSizeInBytes());
assertEquals(trackedObjects.getLong(block), 1);
assertEquals(trackedObjects.getLong(copyBlock), 1);
trackedObjects.remove(block);
trackedObjects.remove(copyBlock);
for (long value : trackedObjects.values()) {
assertEquals(value, getRegionCreateNewObjects ? 1 : 2);
}
}
Aggregations