io.prestosql.spi.block.Block类的使用及代码示例

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

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

Block介绍

暂无

代码示例

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

@Override
  public void setField(Block block, int position)
  {
    Block arrayBlock = block.getObject(position, Block.class);
    List<Object> list = new ArrayList<>(arrayBlock.getPositionCount());
    for (int i = 0; i < arrayBlock.getPositionCount(); i++) {
      Object element = getField(elementType, arrayBlock, i);
      list.add(element);
    }
    rowInspector.setStructFieldData(row, field, list);
  }
}

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

@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
  if (block.isNull(position)) {
    blockBuilder.appendNull();
  }
  else {
    block.writeBytesTo(position, 0, block.getSliceLength(position), blockBuilder);
    blockBuilder.closeEntry();
  }
}

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

@Override
public Object getObjectValue(ConnectorSession session, Block block, int position)
{
  if (block.isNull(position)) {
    return null;
  }
  return block.getSlice(position, 0, block.getSliceLength(position)).toStringUtf8();
}

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

@Override
public Slice getSlice(Block block, int position)
{
  return block.getSlice(position, 0, block.getSliceLength(position));
}

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

@Override
public Object getObjectValue(ConnectorSession session, Block block, int position)
{
  if (block.isNull(position)) {
    return null;
  }
  return new SqlIntervalYearMonth(block.getInt(position, 0));
}

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

@Override
public void writeBlock(BlockEncodingSerde blockEncodingSerde, SliceOutput sliceOutput, Block block)
{
  int positionCount = block.getPositionCount();
  sliceOutput.appendInt(positionCount);
  encodeNullsAsBits(sliceOutput, block);
  for (int position = 0; position < positionCount; position++) {
    if (!block.isNull(position)) {
      sliceOutput.writeLong(block.getLong(position, 0));
    }
  }
}

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

@Override
public Object getObjectValue(ConnectorSession session, Block block, int position)
{
  if (block.isNull(position)) {
    return null;
  }
  return new SqlTimestampWithTimeZone(block.getLong(position, 0));
}

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

@Override
public boolean isNull(int position)
{
  return block.isNull(position);
}

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

protected List<Block> splitBlock(Block block, int count)
{
  double sizePerSplit = block.getPositionCount() * 1.0 / count;
  ImmutableList.Builder<Block> result = ImmutableList.builder();
  for (int i = 0; i < count; i++) {
    int startPosition = toIntExact(Math.round(sizePerSplit * i));
    int endPosition = toIntExact(Math.round(sizePerSplit * (i + 1)));
    result.add(block.getRegion(startPosition, endPosition - startPosition));
  }
  return result.build();
}

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

@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
  if (block.isNull(position)) {
    blockBuilder.appendNull();
  }
  else {
    block.writeBytesTo(position, 0, getFixedSize(), blockBuilder);
    blockBuilder.closeEntry();
  }
}

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

@Override
public Slice getSlice(int position, int offset, int length)
{
  return block.getSlice(position, offset, length);
}

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

@Override
public long getLong(int position, int offset)
{
  return block.getLong(position, offset);
}

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

@Override
public Block getRegion(int positionOffset, int length)
{
  return block.getRegion(positionOffset, length);
}

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

@Override
public void writeBytesTo(int position, int offset, int length, BlockBuilder blockBuilder)
{
  block.writeBytesTo(position, offset, length, blockBuilder);
}

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

@Override
public <T> T getObject(int position, Class<T> clazz)
{
  return block.getObject(position, clazz);
}

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

private static Double mapL2Norm(Block map)
  {
    double norm = 0.0;

    for (int i = 1; i < map.getPositionCount(); i += 2) {
      if (map.isNull(i)) {
        return null;
      }
      norm += DOUBLE.getDouble(map, i) * DOUBLE.getDouble(map, i);
    }

    return Math.sqrt(norm);
  }
}

代码示例来源: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());
    }
  }
}

相关文章