com.facebook.presto.spi.block.Block.retainedBytesForEachPart()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中com.facebook.presto.spi.block.Block.retainedBytesForEachPart()方法的一些代码示例,展示了Block.retainedBytesForEachPart()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.retainedBytesForEachPart()方法的具体详情如下:
包路径:com.facebook.presto.spi.block.Block
类名称:Block
方法名:retainedBytesForEachPart

Block.retainedBytesForEachPart介绍

[英]consumer visits each of the internal data container and accepts the size for it. This method can be helpful in cases such as memory counting for internal data structure. Also, the method should be non-recursive, only visit the elements at the top level, and specifically should not call retainedBytesForEachPart on nested blocks consumer should be called at least once with the current block and must include the instance size of the current block
[中]

代码示例

代码示例来源:origin: prestodb/presto

@Override
public void retainedBytesForEachPart(BiConsumer<Object, Long> consumer)
{
  assureLoaded();
  block.retainedBytesForEachPart(consumer);
  consumer.accept(this, (long) INSTANCE_SIZE);
}

代码示例来源:origin: prestodb/presto

currentValue.retainedBytesForEachPart((object, size) -> {
  if (currentValue == object) {
value.retainedBytesForEachPart((object, size) -> {
  if (value == object) {

代码示例来源:origin: prestodb/presto

private void updateRetainedSize()
{
  // increment the size only when it is the first reference
  retainedSizeInBytes = Page.INSTANCE_SIZE + SizeOf.sizeOfObjectArray(page.getChannelCount());
  ReferenceCountMap referenceCountMap = new ReferenceCountMap();
  for (int channel = 0; channel < page.getChannelCount(); channel++) {
    Block block = page.getBlock(channel);
    if (!isNotLoadedLazyBlock(block)) {
      block.retainedBytesForEachPart((object, size) -> {
        if (referenceCountMap.incrementAndGet(object) == 1) {
          retainedSizeInBytes += size;
        }
      });
    }
  }
  for (Block previouslyComputedResult : previouslyComputedResults) {
    if (previouslyComputedResult != null) {
      previouslyComputedResult.retainedBytesForEachPart((object, size) -> {
        if (referenceCountMap.incrementAndGet(object) == 1) {
          retainedSizeInBytes += size;
        }
      });
    }
  }
  memoryContext.setBytes(retainedSizeInBytes);
}

代码示例来源:origin: prestodb/presto

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);
  }
}

代码示例来源:origin: prestodb/presto

block.getPositions(positions, 0, positions.length - 1).retainedBytesForEachPart((part, size) -> {
  if (part == positions) {
    isIdentical.set(true);

代码示例来源:origin: com.facebook.presto/presto-spi

@Override
public void retainedBytesForEachPart(BiConsumer<Object, Long> consumer)
{
  assureLoaded();
  block.retainedBytesForEachPart(consumer);
  consumer.accept(this, (long) INSTANCE_SIZE);
}

相关文章