public long getGroupId(int position) { return BIGINT.getLong(block, position); }
@Override public long hashPosition(int position, Page page) { return BigintType.BIGINT.getLong(page.getBlock(hashChannel), position); }
@Override Object extractValue(Block block, int position) { return BIGINT.getLong(block, position); }
@Override public long hashPosition(int blockIndex, int position) { if (precomputedHashChannel != null) { return BIGINT.getLong(precomputedHashChannel.get(blockIndex), position); } long result = 0; for (int hashChannel : hashChannels) { Type type = types.get(hashChannel); Block block = channels.get(hashChannel).get(blockIndex); result = result * 31 + TypeUtils.hashPosition(type, block, position); } return result; }
public SingleTypedHistogram(Block block, Type type, int expectedSize) { this(type, expectedSize); requireNonNull(block, "block is null"); for (int i = 0; i < block.getPositionCount(); i += 2) { add(i, block, BIGINT.getLong(block, i + 1)); } }
@Override public void setField(Block block, int position) { value.set(BigintType.BIGINT.getLong(block, position)); rowInspector.setStructFieldData(row, field, value); } }
/** * TODO: use RowBlock in the future * * @param block of the form [key1, count1, key2, count2, ...] */ public GroupedTypedHistogram(long groupId, Block block, Type type, int bucketId) { this(type, bucketId); currentGroupId = (int) groupId; requireNonNull(block, "block is null"); for (int i = 0; i < block.getPositionCount(); i += 2) { add(groupId, block, i, BIGINT.getLong(block, i + 1)); } }
public static FeatureVector toFeatures(Block map) { Map<Integer, Double> features = new HashMap<>(); if (map != null) { for (int position = 0; position < map.getPositionCount(); position += 2) { features.put((int) BIGINT.getLong(map, position), DOUBLE.getDouble(map, position + 1)); } } return new FeatureVector(features); } }
public long getCurrentJoinPosition(LookupSource lookupSource) { if (currentRowContainsNull()) { return -1; } if (probeHashBlock.isPresent()) { long rawHash = BIGINT.getLong(probeHashBlock.get(), position); return lookupSource.getJoinPosition(position, probePage, page, rawHash); } return lookupSource.getJoinPosition(position, probePage, page); }
@Override public void deserialize(Block block, int index, NullableLongState state) { state.setNull(false); state.setLong(BIGINT.getLong(block, index)); } }
private static void assertCurrentBatch(OrcRecordReader reader, int stripe) throws IOException { Block block = reader.readBlock(BIGINT, 0); for (int i = 0; i < 20; i++) { assertEquals(BIGINT.getLong(block, i), ((stripe * 20L) + i) * 3); } }
private static void assertCurrentBatch(OrcRecordReader reader, int rowIndex, int batchSize) throws IOException { Block block = reader.readBlock(BIGINT, 0); for (int i = 0; i < batchSize; i++) { assertEquals(BIGINT.getLong(block, i), (rowIndex + i) * 3); } }
@Override public void deserialize(Block block, int index, MinMaxNState state) { Block currentBlock = (Block) serializedType.getObject(block, index); int capacity = toIntExact(BIGINT.getLong(currentBlock, 0)); Block heapBlock = arrayType.getObject(currentBlock, 1); TypedHeap heap = new TypedHeap(blockComparator, elementType, capacity); heap.addAll(heapBlock); state.setTypedHeap(heap); } }
public static TypedKeyValueHeap deserialize(Block block, Type keyType, Type valueType, BlockComparator blockComparator) { int capacity = toIntExact(BIGINT.getLong(block, 0)); Block keysBlock = new ArrayType(keyType).getObject(block, 1); Block valuesBlock = new ArrayType(valueType).getObject(block, 2); TypedKeyValueHeap heap = new TypedKeyValueHeap(blockComparator, keyType, valueType, capacity); heap.addAll(keysBlock, valuesBlock); return heap; }
private static void testBigintFor(TypedSet typedSet, Block longBlock) { Set<Long> set = new HashSet<>(); for (int blockPosition = 0; blockPosition < longBlock.getPositionCount(); blockPosition++) { long number = BIGINT.getLong(longBlock, blockPosition); assertEquals(typedSet.contains(longBlock, blockPosition), set.contains(number)); assertEquals(typedSet.size(), set.size()); set.add(number); typedSet.add(longBlock, blockPosition); assertEquals(typedSet.contains(longBlock, blockPosition), set.contains(number)); assertEquals(typedSet.size(), set.size()); } } }
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]); } }
private static void checkArrayValue(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++) { assertFalse(actualBlock.isNull(i)); assertEquals(BIGINT.getLong(actualBlock, i), expected[i]); } }
@Test public void testMultipleValuesWithNull() { BlockBuilder blockBuilder = BIGINT.createBlockBuilder(null, 10); blockBuilder.appendNull(); BIGINT.writeLong(blockBuilder, 42); blockBuilder.appendNull(); BIGINT.writeLong(blockBuilder, 42); Block block = blockBuilder.build(); assertTrue(block.isNull(0)); assertEquals(BIGINT.getLong(block, 1), 42L); assertTrue(block.isNull(2)); assertEquals(BIGINT.getLong(block, 3), 42L); }
@SqlType(StandardTypes.BIGINT) public static long getBlockPosition(@BlockPosition @SqlType(value = StandardTypes.BIGINT, nativeContainerType = long.class) Block block, @BlockIndex int position) { hitBlockPositionBigint.set(true); return BIGINT.getLong(block, position); }
private static boolean filter(Page page, int position) { Block discountBlock = page.getBlock(0); Block shipDateBlock = page.getBlock(1); Block quantityBlock = page.getBlock(2); return !shipDateBlock.isNull(position) && DATE.getLong(shipDateBlock, position) >= MIN_SHIP_DATE && !shipDateBlock.isNull(position) && DATE.getLong(shipDateBlock, position) < MAX_SHIP_DATE && !discountBlock.isNull(position) && DOUBLE.getDouble(discountBlock, position) >= 0.05 && !discountBlock.isNull(position) && DOUBLE.getDouble(discountBlock, position) <= 0.07 && !quantityBlock.isNull(position) && BIGINT.getLong(quantityBlock, position) < 24; } }