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

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

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

Block.getRetainedSizeInBytes介绍

[英]Returns the retained size of this block in memory, including over-allocations. This method is called from the inner most execution loop and must be fast.
[中]返回此块在内存中的保留大小,包括过度分配。此方法是从最内部的执行循环调用的,必须是快速的。

代码示例

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

@Override
public long getRetainedSizeInBytes()
{
  return INSTANCE_SIZE + value.getRetainedSizeInBytes();
}

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

@Override
public long getRetainedSizeInBytes()
{
  return INSTANCE_SIZE + block.getRetainedSizeInBytes();
}

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

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

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

@Override
public long getRetainedSizeInBytes()
{
  return INSTANCE_SIZE + keyBlock.getRetainedSizeInBytes() + valueBlock.getRetainedSizeInBytes() + sizeOf(hashTable);
}

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

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

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

@Override
public void retainedBytesForEachPart(BiConsumer<Object, Long> consumer)
{
  for (Block fieldBlock : fieldBlocks) {
    consumer.accept(fieldBlock, fieldBlock.getRetainedSizeInBytes());
  }
  consumer.accept(this, (long) INSTANCE_SIZE);
}

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

@Override
public void retainedBytesForEachPart(BiConsumer<Object, Long> consumer)
{
  consumer.accept(keyBlock, keyBlock.getRetainedSizeInBytes());
  consumer.accept(valueBlock, valueBlock.getRetainedSizeInBytes());
  consumer.accept(hashTable, sizeOf(hashTable));
  consumer.accept(this, (long) INSTANCE_SIZE);
}

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

@Override
public long getRetainedSizeInBytes()
{
  assureLoaded();
  return INSTANCE_SIZE + block.getRetainedSizeInBytes();
}

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

@Override
public void retainedBytesForEachPart(BiConsumer<Object, Long> consumer)
{
  consumer.accept(dictionary, dictionary.getRetainedSizeInBytes());
  consumer.accept(ids, sizeOf(ids));
  consumer.accept(this, (long) INSTANCE_SIZE);
}

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

@Override
public long getRetainedSizeInBytes()
{
  long retainedSizeInBytes = INSTANCE_SIZE;
  for (int i = 0; i < fieldBlocks.length; i++) {
    retainedSizeInBytes += getRawFieldBlock(i).getRetainedSizeInBytes();
  }
  return retainedSizeInBytes;
}

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

private void updateRetainedSize()
{
  long retainedSizeInBytes = INSTANCE_SIZE + sizeOf(blocks);
  for (Block block : blocks) {
    retainedSizeInBytes += block.getRetainedSizeInBytes();
  }
  this.retainedSizeInBytes.set(retainedSizeInBytes);
}

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

@Override
public void retainedBytesForEachPart(BiConsumer<Object, Long> consumer)
{
  consumer.accept(keyBlock, keyBlock.getRetainedSizeInBytes());
  consumer.accept(valueBlock, valueBlock.getRetainedSizeInBytes());
  consumer.accept(offsets, sizeOf(offsets));
  consumer.accept(mapIsNull, sizeOf(mapIsNull));
  consumer.accept(hashTables, sizeOf(hashTables));
  consumer.accept(this, (long) INSTANCE_SIZE);
}

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

@Override
public void retainedBytesForEachPart(BiConsumer<Object, Long> consumer)
{
  for (int i = 0; i < numFields; i++) {
    consumer.accept(fieldBlocks[i], fieldBlocks[i].getRetainedSizeInBytes());
  }
  consumer.accept(fieldBlockOffsets, sizeOf(fieldBlockOffsets));
  consumer.accept(rowIsNull, sizeOf(rowIsNull));
  consumer.accept(this, (long) INSTANCE_SIZE);
}

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

@Override
public void retainedBytesForEachPart(BiConsumer<Object, Long> consumer)
{
  consumer.accept(values, values.getRetainedSizeInBytes());
  consumer.accept(offsets, sizeOf(offsets));
  consumer.accept(valueIsNull, sizeOf(valueIsNull));
  consumer.accept(this, (long) INSTANCE_SIZE);
}

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

/**
 * Use createArrayBlockInternal or fromElementBlock instead of this method.  The caller of this method is assumed to have
 * validated the arguments with validateConstructorArguments.
 */
private ArrayBlock(int arrayOffset, int positionCount, @Nullable boolean[] valueIsNull, int[] offsets, Block values)
{
  // caller must check arguments with validateConstructorArguments
  this.arrayOffset = arrayOffset;
  this.positionCount = positionCount;
  this.valueIsNull = valueIsNull;
  this.offsets = offsets;
  this.values = requireNonNull(values);
  sizeInBytes = -1;
  retainedSizeInBytes = INSTANCE_SIZE + values.getRetainedSizeInBytes() + sizeOf(offsets) + sizeOf(valueIsNull);
}

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

public DictionaryBlock(int idsOffset, int positionCount, Block dictionary, int[] ids, boolean dictionaryIsCompacted, DictionaryId dictionarySourceId)
{
  requireNonNull(dictionary, "dictionary is null");
  requireNonNull(ids, "ids is null");
  if (positionCount < 0) {
    throw new IllegalArgumentException("positionCount is negative");
  }
  this.idsOffset = idsOffset;
  if (ids.length - idsOffset < positionCount) {
    throw new IllegalArgumentException("ids length is less than positionCount");
  }
  this.positionCount = positionCount;
  this.dictionary = dictionary;
  this.ids = ids;
  this.dictionarySourceId = requireNonNull(dictionarySourceId, "dictionarySourceId is null");
  this.retainedSizeInBytes = INSTANCE_SIZE + dictionary.getRetainedSizeInBytes() + sizeOf(ids);
  if (dictionaryIsCompacted) {
    this.sizeInBytes = this.retainedSizeInBytes;
    this.uniqueIds = dictionary.getPositionCount();
  }
}

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

/**
 * Use createRowBlockInternal or fromFieldBlocks instead of this method.  The caller of this method is assumed to have
 * validated the arguments with validateConstructorArguments.
 */
private RowBlock(int startOffset, int positionCount, @Nullable boolean[] rowIsNull, int[] fieldBlockOffsets, Block[] fieldBlocks)
{
  super(fieldBlocks.length);
  this.startOffset = startOffset;
  this.positionCount = positionCount;
  this.rowIsNull = rowIsNull;
  this.fieldBlockOffsets = fieldBlockOffsets;
  this.fieldBlocks = fieldBlocks;
  this.sizeInBytes = -1;
  long retainedSizeInBytes = INSTANCE_SIZE + sizeOf(fieldBlockOffsets) + sizeOf(rowIsNull);
  for (Block fieldBlock : fieldBlocks) {
    retainedSizeInBytes += fieldBlock.getRetainedSizeInBytes();
  }
  this.retainedSizeInBytes = retainedSizeInBytes;
}

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

public void compact()
{
  if (eagerCompact) {
    return;
  }
  for (int channel = 0; channel < types.size(); channel++) {
    ObjectArrayList<Block> blocks = channels[channel];
    for (int i = nextBlockToCompact; i < blocks.size(); i++) {
      Block block = blocks.get(i);
      // Copy the block to compact its size
      Block compactedBlock = block.copyRegion(0, block.getPositionCount());
      blocks.set(i, compactedBlock);
      pagesMemorySize -= block.getRetainedSizeInBytes();
      pagesMemorySize += compactedBlock.getRetainedSizeInBytes();
    }
  }
  nextBlockToCompact = channels[0].size();
  estimatedSize = calculateEstimatedSize();
}

代码示例来源: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

public void addPage(Page page)
{
  // ignore empty pages
  if (page.getPositionCount() == 0) {
    return;
  }
  positionCount += page.getPositionCount();
  int pageIndex = (channels.length > 0) ? channels[0].size() : 0;
  for (int i = 0; i < channels.length; i++) {
    Block block = page.getBlock(i);
    if (eagerCompact) {
      block = block.copyRegion(0, block.getPositionCount());
    }
    channels[i].add(block);
    pagesMemorySize += block.getRetainedSizeInBytes();
  }
  for (int position = 0; position < page.getPositionCount(); position++) {
    long sliceAddress = encodeSyntheticAddress(pageIndex, position);
    valueAddresses.add(sliceAddress);
  }
  estimatedSize = calculateEstimatedSize();
}

相关文章