@Override public boolean isNull(int position) { return block.isNull(position); }
@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; }
@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; }
private boolean isChannelPositionNull(int channelIndex, int blockIndex, int blockPosition) { List<Block> channel = channels.get(channelIndex); Block block = channel.get(blockIndex); return block.isNull(blockPosition); }
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; } }
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)); } }
@Override public boolean isNull(int field) { checkState(position >= 0, "Not yet advanced"); checkState(position < page.getPositionCount(), "Already finished"); return page.getBlock(field).isNull(position); }
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; } }
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; }
@Override public Object getObjectValue(ConnectorSession session, Block block, int position) { if (block.isNull(position)) { return null; } return new SqlIntervalYearMonth(block.getInt(position, 0)); }
@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); }
@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(); }
private static Object decodeObject(Type type, Block block, int position) { if (block.isNull(position)) { return null; } return type.getObjectValue(SESSION, block, position); } }
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()); } } }
@Test public void testNull() { Accumulator accumulator = factory.createAccumulator(); Block result = getFinalBlock(accumulator); assertTrue(result.getPositionCount() == 1); assertTrue(result.isNull(0)); }
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]); } }
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); } }
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)); } }
@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()))); } } }
@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); }