io.prestosql.spi.block.Block.getPositionCount()方法的使用及代码示例

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

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

Block.getPositionCount介绍

[英]Returns the number of positions in this block.
[中]返回此块中的位置数。

代码示例

代码示例来源:origin: io.prestosql/presto-main

private void deserialize(Block block)
{
  for (int i = 0; i < block.getPositionCount(); i += 2) {
    add(block, block, i, i + 1);
  }
}

代码示例来源:origin: io.prestosql/presto-orc

@Override
public void writeBlock(Block block)
{
  checkState(!closed);
  checkArgument(block.getPositionCount() > 0, "Block is empty");
  ColumnarMap columnarMap = toColumnarMap(block);
  writeColumnarMap(columnarMap);
}

代码示例来源:origin: io.prestosql/presto-main

private static <T> void assertBlockPositions(Block block, T[] expectedValues)
{
  assertEquals(block.getPositionCount(), expectedValues.length);
  for (int position = 0; position < block.getPositionCount(); position++) {
    assertBlockPosition(block, position, expectedValues[position]);
  }
}

代码示例来源:origin: io.prestosql/presto-main

@UsedByGeneratedCode
public static Block prependElement(Type elementType, long value, Block block)
{
  BlockBuilder blockBuilder = elementType.createBlockBuilder(null, block.getPositionCount() + 1);
  elementType.writeLong(blockBuilder, value);
  for (int i = 0; i < block.getPositionCount(); i++) {
    elementType.appendTo(block, i, blockBuilder);
  }
  return blockBuilder.build();
}

代码示例来源:origin: io.prestosql/presto-hive

private static List toRowValue(Block rowBlock, List<Type> fieldTypes)
{
  List<Object> values = new ArrayList<>(rowBlock.getPositionCount());
  for (int i = 0; i < rowBlock.getPositionCount(); i++) {
    values.add(fieldTypes.get(i).getObjectValue(SESSION, rowBlock, i));
  }
  return Collections.unmodifiableList(values);
}

代码示例来源:origin: io.prestosql/presto-main

@UsedByGeneratedCode
public static Block prependElement(Type elementType, Slice value, Block block)
{
  BlockBuilder blockBuilder = elementType.createBlockBuilder(null, block.getPositionCount() + 1);
  elementType.writeSlice(blockBuilder, value);
  for (int i = 0; i < block.getPositionCount(); i++) {
    elementType.appendTo(block, i, blockBuilder);
  }
  return blockBuilder.build();
}

代码示例来源:origin: io.prestosql/presto-main

@UsedByGeneratedCode
  public static Block prependElement(Type elementType, double value, Block block)
  {
    BlockBuilder blockBuilder = elementType.createBlockBuilder(null, block.getPositionCount() + 1);

    elementType.writeDouble(blockBuilder, value);
    for (int i = 0; i < block.getPositionCount(); i++) {
      elementType.appendTo(block, i, blockBuilder);
    }

    return blockBuilder.build();
  }
}

代码示例来源:origin: io.prestosql/presto-main

public static Object getOnlyValue(Type type, Block block)
{
  assertEquals(block.getPositionCount(), 1, "Block positions");
  return type.getObjectValue(SESSION, block, 0);
}

代码示例来源:origin: io.prestosql/presto-main

public static List<Object> toValues(Type type, Iterable<Block> blocks)
{
  List<Object> values = new ArrayList<>();
  for (Block block : blocks) {
    for (int position = 0; position < block.getPositionCount(); position++) {
      values.add(type.getObjectValue(SESSION, block, position));
    }
  }
  return Collections.unmodifiableList(values);
}

代码示例来源:origin: io.prestosql/presto-main

@UsedByGeneratedCode
  public static long hash(MethodHandle keyHashCodeFunction, MethodHandle valueHashCodeFunction, Type keyType, Type valueType, Block block)
  {
    long result = 0;
    for (int position = 0; position < block.getPositionCount(); position += 2) {
      result += hashPosition(keyHashCodeFunction, keyType, block, position) ^ hashPosition(valueHashCodeFunction, valueType, block, position + 1);
    }
    return result;
  }
}

代码示例来源:origin: io.prestosql/presto-main

private static Block createMapBlock(MapType mapType, int positionCount, Block keyBlock, Block valueBlock)
{
  int[] offsets = new int[positionCount + 1];
  int mapSize = keyBlock.getPositionCount() / positionCount;
  for (int i = 0; i < offsets.length; i++) {
    offsets[i] = mapSize * i;
  }
  return mapType.createBlockFromKeyValue(Optional.empty(), offsets, keyBlock, valueBlock);
}

代码示例来源:origin: io.prestosql/presto-main

private static Block createMapBlock(MapType mapType, int positionCount, Block keyBlock, Block valueBlock)
{
  int[] offsets = new int[positionCount + 1];
  int mapSize = keyBlock.getPositionCount() / positionCount;
  for (int i = 0; i < offsets.length; i++) {
    offsets[i] = mapSize * i;
  }
  return mapType.createBlockFromKeyValue(Optional.empty(), offsets, keyBlock, valueBlock);
}

代码示例来源:origin: io.prestosql/presto-orc

@Override
default void addBlock(Type type, Block block)
{
  for (int position = 0; position < block.getPositionCount(); position++) {
    if (!block.isNull(position)) {
      addValue(type.getSlice(block, position));
    }
  }
}

代码示例来源:origin: io.prestosql/presto-main

@TypeParameter("E")
  @SqlType(StandardTypes.BIGINT)
  public static long arrayCardinality(@SqlType("array(E)") Block block)
  {
    return block.getPositionCount();
  }
}

代码示例来源:origin: io.prestosql/presto-thrift-api

private void assertBlockEquals(Block block, List<Long> expected)
{
  assertEquals(block.getPositionCount(), expected.size());
  for (int i = 0; i < expected.size(); i++) {
    if (expected.get(i) == null) {
      assertTrue(block.isNull(i));
    }
    else {
      assertEquals(block.getLong(i, 0), expected.get(i).longValue());
    }
  }
}

代码示例来源:origin: io.prestosql/presto-record-decoder

private static void checkArrayItemIsNull(Map<DecoderColumnHandle, FieldValueProvider> decodedRow, DecoderColumnHandle handle, long[] expected)
{
  Block actualBlock = getBlock(decodedRow, handle);
  assertEquals(actualBlock.getPositionCount(), expected.length);
  for (int i = 0; i < actualBlock.getPositionCount(); i++) {
    assertTrue(actualBlock.isNull(i));
    assertEquals(BIGINT.getLong(actualBlock, i), expected[i]);
  }
}

代码示例来源:origin: io.prestosql/presto-spi

private static void assertBlockEquals(Type type, Block actual, Block expected)
  {
    for (int position = 0; position < actual.getPositionCount(); position++) {
      assertEquals(type.getObjectValue(SESSION, actual, position), type.getObjectValue(SESSION, expected, position));
    }
  }
}

代码示例来源:origin: io.prestosql/presto-main

@Test
public void testNull()
{
  Accumulator accumulator = factory.createAccumulator();
  Block result = getFinalBlock(accumulator);
  assertTrue(result.getPositionCount() == 1);
  assertTrue(result.isNull(0));
}

代码示例来源:origin: io.prestosql/presto-main

private static void testFilter(DictionaryAwarePageFilter filter, Block block, boolean filterRange)
{
  IntSet actualSelectedPositions = toSet(filter.filter(null, new Page(block)));
  block = block.getLoadedBlock();
  IntSet expectedSelectedPositions = new IntArraySet(block.getPositionCount());
  for (int position = 0; position < block.getPositionCount(); position++) {
    if (isSelected(filterRange, block.getLong(position, 0))) {
      expectedSelectedPositions.add(position);
    }
  }
  assertEquals(actualSelectedPositions, expectedSelectedPositions);
}

代码示例来源:origin: io.prestosql/presto-main

private static <T> void assertRunLengthEncodedBlock(Block block, T[] expectedValues)
{
  for (int position = 0; position < block.getPositionCount(); position++) {
    RunLengthEncodedBlock runLengthEncodedBlock = createTestRleBlock(block, position);
    T[] expectedDictionaryValues = createTestRleExpectedValues(expectedValues, position);
    assertBlock(runLengthEncodedBlock, expectedDictionaryValues);
    assertColumnarArray(runLengthEncodedBlock, expectedDictionaryValues);
  }
}

相关文章