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

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

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

Block.getSingleValueBlock介绍

[英]Gets the value at the specified position as a single element block. The method must copy the data into a new block.

This method is useful for operators that hold on to a single value without holding on to the entire block.
[中]获取指定位置处作为单个元素块的值。该方法必须将数据复制到新块中。
此方法对于保留单个值而不保留整个块的运算符非常有用。

代码示例

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

@Override
public Block getSingleValueBlock(int position)
{
  return block.getSingleValueBlock(position);
}

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

@Override
public Block getSingleValueBlock(int position)
{
  return dictionary.getSingleValueBlock(getId(position));
}

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

/**
 * Gets the values at the specified position as a single element page.  The method creates independent
 * copy of the data.
 */
public Page getSingleValuePage(int position)
{
  Block[] singleValueBlocks = new Block[this.blocks.length];
  for (int i = 0; i < this.blocks.length; i++) {
    singleValueBlocks[i] = this.blocks[i].getSingleValueBlock(position);
  }
  return new Page(1, singleValueBlocks);
}

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

@Override
public Block getSingleValueBlock(int position)
{
  assureLoaded();
  return block.getSingleValueBlock(position);
}

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

@Override
public Block getSingleValueBlock(int position)
{
  position = getAbsolutePosition(position);
  if (position % 2 == 0) {
    return getRawKeyBlock().getSingleValueBlock(position / 2);
  }
  else {
    return getRawValueBlock().getSingleValueBlock(position / 2);
  }
}

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

@Override
public Block getSingleValueBlock(int position)
{
  checkFieldIndex(position);
  return getRawFieldBlock(position).getSingleValueBlock(rowIndex);
}

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

@Override
public Block getSingleValueBlock(int position)
{
  checkReadablePosition(position);
  return getBlock().getSingleValueBlock(position + start);
}

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

private ComputedStatistics getComputedStatistics(Page page, int position)
{
  ImmutableList.Builder<String> groupingColumns = ImmutableList.builder();
  ImmutableList.Builder<Block> groupingValues = ImmutableList.builder();
  descriptor.getGrouping().forEach((column, channel) -> {
    groupingColumns.add(column);
    groupingValues.add(page.getBlock(channel).getSingleValueBlock(position));
  });
  ComputedStatistics.Builder statistics = ComputedStatistics.builder(groupingColumns.build(), groupingValues.build());
  descriptor.getTableStatistics().forEach((type, channel) ->
      statistics.addTableStatistic(type, page.getBlock(channel).getSingleValueBlock(position)));
  descriptor.getColumnStatistics().forEach((metadata, channel) -> statistics.addColumnStatistic(metadata, page.getBlock(channel).getSingleValueBlock(position)));
  return statistics.build();
}

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

public Block getSingleValueBlock(int channel, int position)
{
  long pageAddress = valueAddresses.getLong(position);
  Block block = channels[channel].get(decodeSliceIndex(pageAddress));
  int blockPosition = decodePosition(pageAddress);
  return block.getSingleValueBlock(blockPosition);
}

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

public static <T> void assertBlockPosition(Block block, int position, T expectedValue)
{
  assertPositionValue(block, position, expectedValue);
  assertPositionValue(block.getSingleValueBlock(position), 0, expectedValue);
}

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

@Override
  public Page next()
  {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    if (noColumnShortcutResult >= 0) {
      rowIndex = maxRowIndex;
      return new Page(noColumnShortcutResult);
    }
    rowIndex++;
    // Create an array of blocks for all columns in both pages.
    Block[] blocks = new Block[numberOfProbeColumns + numberOfBuildColumns];
    // Make sure we always put the probe data on the left and build data on the right.
    int indexForRleBlocks = buildPageLarger ? 0 : numberOfProbeColumns;
    int indexForPageBlocks = buildPageLarger ? numberOfProbeColumns : 0;
    // For the page with less rows, create RLE blocks and add them to the blocks array
    for (int i = 0; i < smallPage.getChannelCount(); i++) {
      Block block = smallPage.getBlock(i).getSingleValueBlock(rowIndex);
      blocks[indexForRleBlocks] = new RunLengthEncodedBlock(block, largePage.getPositionCount());
      indexForRleBlocks++;
    }
    // Put the page with more rows in the blocks array
    for (int i = 0; i < largePage.getChannelCount(); i++) {
      blocks[indexForPageBlocks + i] = largePage.getBlock(i);
    }
    return new Page(largePage.getPositionCount(), blocks);
  }
}

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

@Override
  protected Object getGreaterValue(Object value)
  {
    RowBlockBuilder blockBuilder = (RowBlockBuilder) TYPE.createBlockBuilder(null, 1);
    SingleRowBlockWriter singleRowBlockWriter;

    Block block = (Block) value;
    singleRowBlockWriter = blockBuilder.beginBlockEntry();
    BIGINT.writeLong(singleRowBlockWriter, block.getSingleValueBlock(0).getLong(0, 0) + 1);
    VARCHAR.writeSlice(singleRowBlockWriter, block.getSingleValueBlock(1).getSlice(0, 0, 1));
    blockBuilder.closeEntry();

    return TYPE.getObject(blockBuilder.build(), 0);
  }
}

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

return array.getSingleValueBlock(0);

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

protected void assertPositionEquals(Block block, int position, Object expectedStackValue, Object expectedObjectValue)
{
  long hash = 0;
  if (type.isComparable()) {
    hash = hashPosition(type, block, position);
  }
  assertPositionValue(block, position, expectedStackValue, hash, expectedObjectValue);
  assertPositionValue(block.getSingleValueBlock(position), 0, expectedStackValue, hash, expectedObjectValue);
  assertPositionValue(block.getRegion(position, 1), 0, expectedStackValue, hash, expectedObjectValue);
  assertPositionValue(block.getRegion(0, position + 1), position, expectedStackValue, hash, expectedObjectValue);
  assertPositionValue(block.getRegion(position, block.getPositionCount() - position), 0, expectedStackValue, hash, expectedObjectValue);
  BlockBuilder blockBuilder = type.createBlockBuilder(null, 1);
  type.appendTo(block, position, blockBuilder);
  assertPositionValue(blockBuilder.build(), 0, expectedStackValue, hash, expectedObjectValue);
}

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

protected <T> void assertBlockPosition(Block block, Supplier<BlockBuilder> newBlockBuilder, int position, T expectedValue, Class<?> expectedValueType)
{
  assertPositionValue(block, position, expectedValue);
  assertPositionValue(block.getSingleValueBlock(position), 0, expectedValue);
  assertPositionValue(block.getRegion(position, 1), 0, expectedValue);
  assertPositionValue(block.getRegion(0, position + 1), position, expectedValue);
  assertPositionValue(block.getRegion(position, block.getPositionCount() - position), 0, expectedValue);
  assertPositionValue(copyBlockViaBlockSerde(block.getRegion(position, 1)), 0, expectedValue);
  assertPositionValue(copyBlockViaBlockSerde(block.getRegion(0, position + 1)), position, expectedValue);
  assertPositionValue(copyBlockViaBlockSerde(block.getRegion(position, block.getPositionCount() - position)), 0, expectedValue);
  assertPositionValue(copyBlockViaWritePositionTo(block.getRegion(position, 1), newBlockBuilder), 0, expectedValue);
  assertPositionValue(copyBlockViaWritePositionTo(block.getRegion(0, position + 1), newBlockBuilder), position, expectedValue);
  assertPositionValue(copyBlockViaWritePositionTo(block.getRegion(position, block.getPositionCount() - position), newBlockBuilder), 0, expectedValue);
  if (expectedValueType.isArray() || expectedValueType == List.class || expectedValueType == Map.class) {
    assertPositionValue(copyBlockViaWriteStructure(block.getRegion(position, 1), newBlockBuilder), 0, expectedValue);
    assertPositionValue(copyBlockViaWriteStructure(block.getRegion(0, position + 1), newBlockBuilder), position, expectedValue);
    assertPositionValue(copyBlockViaWriteStructure(block.getRegion(position, block.getPositionCount() - position), newBlockBuilder), 0, expectedValue);
  }
  assertPositionValue(block.copyRegion(position, 1), 0, expectedValue);
  assertPositionValue(block.copyRegion(0, position + 1), position, expectedValue);
  assertPositionValue(block.copyRegion(position, block.getPositionCount() - position), 0, expectedValue);
  assertPositionValue(block.copyPositions(new int[] {position}, 0, 1), 0, expectedValue);
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

private static Block[] getValues(int position, Block[] blocks)
{
  Block[] row = new Block[blocks.length];
  for (int i = 0; i < blocks.length; i++) {
    row[i] = blocks[i].getSingleValueBlock(position);
  }
  return row;
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

private static Block[] getSingleValueBlocks(Page page, int position)
{
  Block[] blocks = page.getBlocks();
  Block[] row = new Block[blocks.length];
  for (int i = 0; i < blocks.length; i++) {
    row[i] = blocks[i].getSingleValueBlock(position);
  }
  return row;
}

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

@Override
public Block getSingleValueBlock(int position)
{
  return dictionary.getSingleValueBlock(getId(position));
}

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

@Override
public Block getSingleValueBlock(int position)
{
  position = getAbsolutePosition(position);
  if (position % 2 == 0) {
    return getRawKeyBlock().getSingleValueBlock(position / 2);
  }
  else {
    return getRawValueBlock().getSingleValueBlock(position / 2);
  }
}

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

@Override
public Block getSingleValueBlock(int position)
{
  checkReadablePosition(position);
  return getBlock().getSingleValueBlock(position + start);
}

相关文章