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

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

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

Block.getPositionsSizeInBytes介绍

[英]Returns the size of of all positions marked true in the positions array. This is equivalent to multiple calls of block.getRegionSizeInBytes(position, length)where you mark all positions for the regions first.
[中]返回positions数组中标记为true的所有位置的大小。这相当于块的多个调用。getRegionSizeInBytes(位置,长度),首先标记区域的所有位置。

代码示例

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

@Override
public long getPositionsSizeInBytes(boolean[] positions)
{
  return block.getPositionsSizeInBytes(positions);
}

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

@Override
public long getPositionsSizeInBytes(boolean[] positions)
{
  assureLoaded();
  return block.getPositionsSizeInBytes(positions);
}

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

private void calculateCompactSize()
{
  int uniqueIds = 0;
  boolean[] used = new boolean[dictionary.getPositionCount()];
  for (int i = 0; i < positionCount; i++) {
    int position = getId(i);
    if (!used[position]) {
      uniqueIds++;
      used[position] = true;
    }
  }
  this.sizeInBytes = dictionary.getPositionsSizeInBytes(used) + (Integer.BYTES * (long) positionCount);
  this.uniqueIds = uniqueIds;
}

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

@Override
public long getPositionsSizeInBytes(boolean[] positions)
{
  checkValidPositions(positions, positionCount);
  boolean[] used = new boolean[dictionary.getPositionCount()];
  for (int i = 0; i < positions.length; i++) {
    if (positions[i]) {
      used[getId(i)] = true;
    }
  }
  return dictionary.getPositionsSizeInBytes(used) + (Integer.BYTES * (long) countUsedPositions(positions));
}

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

@Override
public long getRegionSizeInBytes(int positionOffset, int length)
{
  if (positionOffset == 0 && length == getPositionCount()) {
    // Calculation of getRegionSizeInBytes is expensive in this class.
    // On the other hand, getSizeInBytes result is cached.
    return getSizeInBytes();
  }
  boolean[] used = new boolean[dictionary.getPositionCount()];
  for (int i = positionOffset; i < positionOffset + length; i++) {
    used[getId(i)] = true;
  }
  return dictionary.getPositionsSizeInBytes(used) + Integer.BYTES * (long) length;
}

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

@Override
public long getPositionsSizeInBytes(boolean[] positions)
{
  // We can use either the getRegionSizeInBytes or getPositionsSizeInBytes
  // from the underlying raw blocks to implement this function. We chose
  // getPositionsSizeInBytes with the assumption that constructing a
  // positions array is cheaper than calling getRegionSizeInBytes for each
  // used position.
  int positionCount = getPositionCount();
  checkValidPositions(positions, positionCount);
  boolean[] entryPositions = new boolean[getRawKeyBlock().getPositionCount()];
  int usedEntryCount = 0;
  int usedPositionCount = 0;
  for (int i = 0; i < positions.length; ++i) {
    if (positions[i]) {
      usedPositionCount++;
      int entriesStart = getOffsets()[getOffsetBase() + i];
      int entriesEnd = getOffsets()[getOffsetBase() + i + 1];
      for (int j = entriesStart; j < entriesEnd; j++) {
        entryPositions[j] = true;
      }
      usedEntryCount += (entriesEnd - entriesStart);
    }
  }
  return getRawKeyBlock().getPositionsSizeInBytes(entryPositions) +
      getRawValueBlock().getPositionsSizeInBytes(entryPositions) +
      (Integer.BYTES + Byte.BYTES) * (long) usedPositionCount +
      Integer.BYTES * HASH_MULTIPLIER * (long) usedEntryCount;
}
@Override

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

private void assertBlockSize(Block block)
{
  // Asserting on `block` is not very effective because most blocks passed to this method is compact.
  // Therefore, we split the `block` into two and assert again.
  long expectedBlockSize = copyBlockViaBlockSerde(block).getSizeInBytes();
  assertEquals(block.getSizeInBytes(), expectedBlockSize);
  assertEquals(block.getRegionSizeInBytes(0, block.getPositionCount()), expectedBlockSize);
  List<Block> splitBlock = splitBlock(block, 2);
  Block firstHalf = splitBlock.get(0);
  long expectedFirstHalfSize = copyBlockViaBlockSerde(firstHalf).getSizeInBytes();
  assertEquals(firstHalf.getSizeInBytes(), expectedFirstHalfSize);
  assertEquals(block.getRegionSizeInBytes(0, firstHalf.getPositionCount()), expectedFirstHalfSize);
  Block secondHalf = splitBlock.get(1);
  long expectedSecondHalfSize = copyBlockViaBlockSerde(secondHalf).getSizeInBytes();
  assertEquals(secondHalf.getSizeInBytes(), expectedSecondHalfSize);
  assertEquals(block.getRegionSizeInBytes(firstHalf.getPositionCount(), secondHalf.getPositionCount()), expectedSecondHalfSize);
  boolean[] positions = new boolean[block.getPositionCount()];
  fill(positions, 0, firstHalf.getPositionCount(), true);
  assertEquals(block.getPositionsSizeInBytes(positions), expectedFirstHalfSize);
  fill(positions, true);
  assertEquals(block.getPositionsSizeInBytes(positions), expectedBlockSize);
  fill(positions, 0, firstHalf.getPositionCount(), false);
  assertEquals(block.getPositionsSizeInBytes(positions), expectedSecondHalfSize);
}

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

@Override
public long getPositionsSizeInBytes(boolean[] positions)
{
  checkValidPositions(positions, getPositionCount());
  int usedPositionCount = 0;
  boolean[] fieldPositions = new boolean[getRawFieldBlocks()[0].getPositionCount()];
  for (int i = 0; i < positions.length; i++) {
    if (positions[i]) {
      usedPositionCount++;
      int startFieldBlockOffset = getFieldBlockOffset(i);
      int endFieldBlockOffset = getFieldBlockOffset(i + 1);
      for (int j = startFieldBlockOffset; j < endFieldBlockOffset; j++) {
        fieldPositions[j] = true;
      }
    }
  }
  long sizeInBytes = 0;
  for (int j = 0; j < numFields; j++) {
    sizeInBytes += getRawFieldBlocks()[j].getPositionsSizeInBytes(fieldPositions);
  }
  return sizeInBytes + (Integer.BYTES + Byte.BYTES) * (long) usedPositionCount;
}

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

@Override
public long getPositionsSizeInBytes(boolean[] positions)
{
  checkValidPositions(positions, getPositionCount());
  boolean[] used = new boolean[getRawElementBlock().getPositionCount()];
  int usedPositionCount = 0;
  for (int i = 0; i < positions.length; ++i) {
    if (positions[i]) {
      usedPositionCount++;
      int valueStart = getOffsets()[getOffsetBase() + i];
      int valueEnd = getOffsets()[getOffsetBase() + i + 1];
      for (int j = valueStart; j < valueEnd; ++j) {
        used[j] = true;
      }
    }
  }
  return getRawElementBlock().getPositionsSizeInBytes(used) + ((Integer.BYTES + Byte.BYTES) * (long) usedPositionCount);
}

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

@Override
public long getPositionsSizeInBytes(boolean[] positions)
{
  assureLoaded();
  return block.getPositionsSizeInBytes(positions);
}

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

private void calculateCompactSize()
{
  int uniqueIds = 0;
  boolean[] used = new boolean[dictionary.getPositionCount()];
  for (int i = 0; i < positionCount; i++) {
    int position = getId(i);
    if (!used[position]) {
      uniqueIds++;
      used[position] = true;
    }
  }
  this.sizeInBytes = dictionary.getPositionsSizeInBytes(used) + (Integer.BYTES * (long) positionCount);
  this.uniqueIds = uniqueIds;
}

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

@Override
public long getPositionsSizeInBytes(boolean[] positions)
{
  checkValidPositions(positions, positionCount);
  boolean[] used = new boolean[dictionary.getPositionCount()];
  for (int i = 0; i < positions.length; i++) {
    if (positions[i]) {
      used[getId(i)] = true;
    }
  }
  return dictionary.getPositionsSizeInBytes(used) + (Integer.BYTES * (long) countUsedPositions(positions));
}

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

@Override
public long getRegionSizeInBytes(int positionOffset, int length)
{
  if (positionOffset == 0 && length == getPositionCount()) {
    // Calculation of getRegionSizeInBytes is expensive in this class.
    // On the other hand, getSizeInBytes result is cached.
    return getSizeInBytes();
  }
  boolean[] used = new boolean[dictionary.getPositionCount()];
  for (int i = positionOffset; i < positionOffset + length; i++) {
    used[getId(i)] = true;
  }
  return dictionary.getPositionsSizeInBytes(used) + Integer.BYTES * (long) length;
}

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

@Override
public long getPositionsSizeInBytes(boolean[] positions)
{
  // We can use either the getRegionSizeInBytes or getPositionsSizeInBytes
  // from the underlying raw blocks to implement this function. We chose
  // getPositionsSizeInBytes with the assumption that constructing a
  // positions array is cheaper than calling getRegionSizeInBytes for each
  // used position.
  int positionCount = getPositionCount();
  checkValidPositions(positions, positionCount);
  boolean[] entryPositions = new boolean[getRawKeyBlock().getPositionCount()];
  int usedEntryCount = 0;
  int usedPositionCount = 0;
  for (int i = 0; i < positions.length; ++i) {
    if (positions[i]) {
      usedPositionCount++;
      int entriesStart = getOffsets()[getOffsetBase() + i];
      int entriesEnd = getOffsets()[getOffsetBase() + i + 1];
      for (int j = entriesStart; j < entriesEnd; j++) {
        entryPositions[j] = true;
      }
      usedEntryCount += (entriesEnd - entriesStart);
    }
  }
  return getRawKeyBlock().getPositionsSizeInBytes(entryPositions) +
      getRawValueBlock().getPositionsSizeInBytes(entryPositions) +
      (Integer.BYTES + Byte.BYTES) * (long) usedPositionCount +
      Integer.BYTES * HASH_MULTIPLIER * (long) usedEntryCount;
}
@Override

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

@Override
public long getPositionsSizeInBytes(boolean[] positions)
{
  checkValidPositions(positions, getPositionCount());
  int usedPositionCount = 0;
  boolean[] fieldPositions = new boolean[getRawFieldBlocks()[0].getPositionCount()];
  for (int i = 0; i < positions.length; i++) {
    if (positions[i]) {
      usedPositionCount++;
      int startFieldBlockOffset = getFieldBlockOffset(i);
      int endFieldBlockOffset = getFieldBlockOffset(i + 1);
      for (int j = startFieldBlockOffset; j < endFieldBlockOffset; j++) {
        fieldPositions[j] = true;
      }
    }
  }
  long sizeInBytes = 0;
  for (int j = 0; j < numFields; j++) {
    sizeInBytes += getRawFieldBlocks()[j].getPositionsSizeInBytes(fieldPositions);
  }
  return sizeInBytes + (Integer.BYTES + Byte.BYTES) * (long) usedPositionCount;
}

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

@Override
public long getPositionsSizeInBytes(boolean[] positions)
{
  checkValidPositions(positions, getPositionCount());
  boolean[] used = new boolean[getRawElementBlock().getPositionCount()];
  int usedPositionCount = 0;
  for (int i = 0; i < positions.length; ++i) {
    if (positions[i]) {
      usedPositionCount++;
      int valueStart = getOffsets()[getOffsetBase() + i];
      int valueEnd = getOffsets()[getOffsetBase() + i + 1];
      for (int j = valueStart; j < valueEnd; ++j) {
        used[j] = true;
      }
    }
  }
  return getRawElementBlock().getPositionsSizeInBytes(used) + ((Integer.BYTES + Byte.BYTES) * (long) usedPositionCount);
}

相关文章