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

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

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

Block.isNull介绍

[英]Is the specified position null?
[中]指定的位置是否为空?

代码示例

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

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

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

@Override
public Object getObjectValue(ConnectorSession session, Block block, int position)
{
  // call is null in case position is out of bounds
  checkArgument(block.isNull(position), "Expected NULL value for UnknownType");
  return null;
}

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

@Override
public boolean getBoolean(Block block, int position)
{
  // Ideally, this function should never be invoked for unknown type.
  // However, some logic rely on having a default value before the null check.
  checkArgument(block.isNull(position));
  return false;
}

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

private boolean isChannelPositionNull(int channelIndex, int blockIndex, int blockPosition)
{
  List<Block> channel = channels.get(channelIndex);
  Block block = channel.get(blockIndex);
  return block.isNull(blockPosition);
}

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

public boolean contains(Block block, int position)
{
  requireNonNull(block, "block must not be null");
  checkArgument(position >= 0, "position must be >= 0");
  if (block.isNull(position)) {
    return containsNullElement;
  }
  else {
    return blockPositionByHash.get(getHashPositionOfElement(block, position)) != EMPTY_SLOT;
  }
}

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

public static boolean isDistinctFrom(Type rowType, List<MethodHandle> argumentMethods, Block leftRow, int leftPosition, Block rightRow, int rightPosition)
  {
    return isDistinctFrom(
        rowType,
        argumentMethods,
        (Block) rowType.getObject(leftRow, leftPosition),
        leftRow.isNull(leftPosition),
        (Block) rowType.getObject(rightRow, rightPosition),
        rightRow.isNull(rightPosition));
  }
}

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

@Override
public boolean isNull(int field)
{
  checkState(position >= 0, "Not yet advanced");
  checkState(position < page.getPositionCount(), "Already finished");
  return page.getBlock(field).isNull(position);
}

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

public boolean contains(Block block, int position)
{
  requireNonNull(block, "block must not be null");
  checkArgument(position >= 0, "position must be >= 0");
  if (block.isNull(position)) {
    return containsNullElement;
  }
  else {
    return blockPositionByHash.get(getHashPositionOfElement(block, position)) != EMPTY_SLOT;
  }
}

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

private static boolean containsNullValue(int position, Page page)
{
  for (int channel = 0; channel < page.getChannelCount(); channel++) {
    Block block = page.getBlock(channel);
    if (block.isNull(position)) {
      return true;
    }
  }
  return false;
}

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

@UsedByGeneratedCode
public static Object objectSubscript(Type elementType, Block array, long index)
{
  checkIndex(array, index);
  int position = toIntExact(index - 1);
  if (array.isNull(position)) {
    return null;
  }
  return elementType.getObject(array, position);
}

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

private static Object decodeObject(Type type, Block block, int position)
  {
    if (block.isNull(position)) {
      return null;
    }

    return type.getObjectValue(SESSION, block, position);
  }
}

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

public static void input(Type type, NullableLongState state, Block block, int position)
{
  state.setNull(false);
  if (block.isNull(position)) {
    state.setLong(state.getLong() + PRIME64);
  }
  else {
    state.setLong(state.getLong() + type.hash(block, position) * PRIME64);
  }
}

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

private static void project(int position, PageBuilder pageBuilder, Block extendedPriceBlock, Block discountBlock)
{
  pageBuilder.declarePosition();
  if (discountBlock.isNull(position) || extendedPriceBlock.isNull(position)) {
    pageBuilder.getBlockBuilder(0).appendNull();
  }
  else {
    DOUBLE.writeDouble(pageBuilder.getBlockBuilder(0), DOUBLE.getDouble(extendedPriceBlock, position) * DOUBLE.getDouble(discountBlock, position));
  }
}

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

@Override
  public void deserialize(Block block, int index, LongDecimalWithOverflowAndLongState state)
  {
    if (!block.isNull(index)) {
      SliceInput slice = VARBINARY.getSlice(block, index).getInput();

      state.setLong(slice.readLong());
      state.setOverflow(slice.readLong());
      state.setLongDecimal(Slices.copyOf(slice.readSlice(slice.available())));
    }
  }
}

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

@InputFunction
public static void input(@AggregationState NullableLongState state, @BlockPosition @NullablePosition @SqlType(StandardTypes.BIGINT) Block block, @BlockIndex int position)
{
  if (block.isNull(position)) {
    state.setLong(state.getLong() + 1);
  }
  state.setNull(false);
}

相关文章