Java Code Examples for io.prestosql.spi.block.BlockBuilder#writeLong()
The following examples show how to use
io.prestosql.spi.block.BlockBuilder#writeLong() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestScalarFunctionAdapter.java From presto with Apache License 2.0 | 6 votes |
private static Object getTestValue(Type argumentType) { if (argumentType.getJavaType() == boolean.class) { return true; } if (argumentType.getJavaType() == double.class) { return 33.33; } if (argumentType.getJavaType() == long.class) { return 42L; } if (argumentType.getJavaType() == Slice.class) { return Slices.utf8Slice("test"); } if (argumentType.getJavaType() == Block.class) { BlockBuilder blockBuilder = BIGINT.createBlockBuilder(null, 4); blockBuilder.appendNull(); blockBuilder.writeLong(99); blockBuilder.appendNull(); blockBuilder.writeLong(100); return blockBuilder.build(); } throw new IllegalArgumentException("Unsupported argument type: " + argumentType); }
Example 2
Source File: UuidType.java From presto with Apache License 2.0 | 5 votes |
@Override public void appendTo(Block block, int position, BlockBuilder blockBuilder) { if (block.isNull(position)) { blockBuilder.appendNull(); } else { blockBuilder.writeLong(block.getLong(position, 0)); blockBuilder.writeLong(block.getLong(position, SIZE_OF_LONG)); blockBuilder.closeEntry(); } }
Example 3
Source File: TestReaderProjectionsAdapter.java From presto with Apache License 2.0 | 5 votes |
private static Block createLongArrayBlock(List<Object> data) { BlockBuilder builder = BIGINT.createBlockBuilder(null, data.size()); for (int i = 0; i < data.size(); i++) { Long value = (Long) data.get(i); if (value == null) { builder.appendNull(); } else { builder.writeLong(value); } } return builder.build(); }
Example 4
Source File: TestOrcDeletedRows.java From presto with Apache License 2.0 | 5 votes |
private Page createTestPage(int originalTransactionStart, int originalTransactionEnd) { int size = originalTransactionEnd - originalTransactionStart; BlockBuilder originalTransaction = BIGINT.createFixedSizeBlockBuilder(size); for (long i = originalTransactionStart; i < originalTransactionEnd; i++) { originalTransaction.writeLong(i); } return new Page( size, originalTransaction.build(), new RunLengthEncodedBlock(bucketBlock, size), new RunLengthEncodedBlock(rowIdBlock, size)); }
Example 5
Source File: LongTimestampWithTimeZoneType.java From presto with Apache License 2.0 | 5 votes |
@Override public void writeObject(BlockBuilder blockBuilder, Object value) { LongTimestampWithTimeZone timestamp = (LongTimestampWithTimeZone) value; blockBuilder.writeLong(packDateTimeWithZone(timestamp.getEpochMillis(), timestamp.getTimeZoneKey())); blockBuilder.writeInt(timestamp.getPicosOfMilli()); blockBuilder.closeEntry(); }
Example 6
Source File: LongTimestampWithTimeZoneType.java From presto with Apache License 2.0 | 5 votes |
@Override public void appendTo(Block block, int position, BlockBuilder blockBuilder) { if (block.isNull(position)) { blockBuilder.appendNull(); } else { blockBuilder.writeLong(getPackedEpochMillis(block, position)); blockBuilder.writeInt(getFraction(block, position)); blockBuilder.closeEntry(); } }
Example 7
Source File: LongDecimalType.java From presto with Apache License 2.0 | 5 votes |
@Override public void writeSlice(BlockBuilder blockBuilder, Slice value, int offset, int length) { if (length != INT128_BYTES) { throw new IllegalStateException("Expected entry size to be exactly " + INT128_BYTES + " but was " + length); } blockBuilder.writeLong(value.getLong(offset)); blockBuilder.writeLong(value.getLong(offset + SIZE_OF_LONG)); blockBuilder.closeEntry(); }
Example 8
Source File: LongDecimalType.java From presto with Apache License 2.0 | 5 votes |
@Override public void appendTo(Block block, int position, BlockBuilder blockBuilder) { if (block.isNull(position)) { blockBuilder.appendNull(); } else { blockBuilder.writeLong(block.getLong(position, 0)); blockBuilder.writeLong(block.getLong(position, SIZE_OF_LONG)); blockBuilder.closeEntry(); } }
Example 9
Source File: LongTimestampType.java From presto with Apache License 2.0 | 5 votes |
@Override public void appendTo(Block block, int position, BlockBuilder blockBuilder) { if (block.isNull(position)) { blockBuilder.appendNull(); } else { blockBuilder.writeLong(getEpochMicros(block, position)); blockBuilder.writeInt(getFraction(block, position)); blockBuilder.closeEntry(); } }
Example 10
Source File: TestDoubleType.java From presto with Apache License 2.0 | 5 votes |
@Test public void testNaNHash() { BlockBuilder blockBuilder = new LongArrayBlockBuilder(null, 4); blockBuilder.writeLong(doubleToLongBits(Double.NaN)); blockBuilder.writeLong(doubleToRawLongBits(Double.NaN)); // the following two are the long values of a double NaN blockBuilder.writeLong(-0x000fffffffffffffL); blockBuilder.writeLong(0x7ff8000000000000L); assertEquals(DOUBLE.hash(blockBuilder, 0), DOUBLE.hash(blockBuilder, 1)); assertEquals(DOUBLE.hash(blockBuilder, 0), DOUBLE.hash(blockBuilder, 2)); assertEquals(DOUBLE.hash(blockBuilder, 0), DOUBLE.hash(blockBuilder, 3)); }
Example 11
Source File: TestInt96ArrayBlock.java From presto with Apache License 2.0 | 5 votes |
private static void writeValues(Slice[] expectedValues, BlockBuilder blockBuilder) { for (Slice expectedValue : expectedValues) { if (expectedValue == null) { blockBuilder.appendNull(); } else { blockBuilder.writeLong(expectedValue.getLong(0)); blockBuilder.writeInt(expectedValue.getInt(8)); blockBuilder.closeEntry(); } } }
Example 12
Source File: TestInt128ArrayBlock.java From presto with Apache License 2.0 | 5 votes |
private static void writeValues(Slice[] expectedValues, BlockBuilder blockBuilder) { for (Slice expectedValue : expectedValues) { if (expectedValue == null) { blockBuilder.appendNull(); } else { blockBuilder.writeLong(expectedValue.getLong(0)); blockBuilder.writeLong(expectedValue.getLong(8)); blockBuilder.closeEntry(); } } }
Example 13
Source File: BenchmarkWindowOperator.java From presto with Apache License 2.0 | 5 votes |
private RowPagesBuilder buildPages(int currentPartitionIdentifier, List<Type> typesArray) { int groupIdentifier = 100; RowPagesBuilder rowPagesBuilder = RowPagesBuilder.rowPagesBuilder(false, ImmutableList.of(0), typesArray); for (int i = 0; i < TOTAL_PAGES; i++) { BlockBuilder firstColumnBlockBuilder = BIGINT.createBlockBuilder(null, ROWS_PER_PAGE); BlockBuilder secondColumnBlockBuilder = BIGINT.createBlockBuilder(null, ROWS_PER_PAGE); int currentNumberOfRowsInPartition = 0; int numberOfPartitionsInCurrentGroup = 0; int currentGroupIdentifier = groupIdentifier++; for (int j = 0; j < ROWS_PER_PAGE; j++) { if (currentNumberOfRowsInPartition == rowsPerPartition) { ++currentPartitionIdentifier; ++numberOfPartitionsInCurrentGroup; currentNumberOfRowsInPartition = 0; } if (numberOfPartitionsInCurrentGroup == partitionsPerGroup) { numberOfPartitionsInCurrentGroup = 0; currentGroupIdentifier = groupIdentifier++; } firstColumnBlockBuilder.writeLong(currentGroupIdentifier); secondColumnBlockBuilder.writeLong(currentPartitionIdentifier); ++currentNumberOfRowsInPartition; } rowPagesBuilder.addBlocksPage( firstColumnBlockBuilder.build(), secondColumnBlockBuilder.build(), createLongSequenceBlock(0, ROWS_PER_PAGE), createLongSequenceBlock(0, ROWS_PER_PAGE)); } return rowPagesBuilder; }
Example 14
Source File: IpAddressType.java From presto with Apache License 2.0 | 5 votes |
@Override public void writeSlice(BlockBuilder blockBuilder, Slice value, int offset, int length) { if (length != INT128_BYTES) { throw new IllegalStateException("Expected entry size to be exactly " + INT128_BYTES + " but was " + length); } blockBuilder.writeLong(value.getLong(offset)); blockBuilder.writeLong(value.getLong(offset + SIZE_OF_LONG)); blockBuilder.closeEntry(); }
Example 15
Source File: IpAddressType.java From presto with Apache License 2.0 | 5 votes |
@Override public void appendTo(Block block, int position, BlockBuilder blockBuilder) { if (block.isNull(position)) { blockBuilder.appendNull(); } else { blockBuilder.writeLong(block.getLong(position, 0)); blockBuilder.writeLong(block.getLong(position, SIZE_OF_LONG)); blockBuilder.closeEntry(); } }
Example 16
Source File: UuidType.java From presto with Apache License 2.0 | 5 votes |
@Override public void writeSlice(BlockBuilder blockBuilder, Slice value, int offset, int length) { if (length != INT128_BYTES) { throw new IllegalStateException("Expected entry size to be exactly " + INT128_BYTES + " but was " + length); } blockBuilder.writeLong(value.getLong(offset)); blockBuilder.writeLong(value.getLong(offset + SIZE_OF_LONG)); blockBuilder.closeEntry(); }
Example 17
Source File: TestReadWrite.java From presto with Apache License 2.0 | 5 votes |
private static void generateBigintArray(Random random, BlockBuilder parentBuilder) { int numberOfElements = random.nextInt(MAX_ARRAY_GENERATED_LENGTH); BlockBuilder builder = parentBuilder.beginBlockEntry(); for (int i = 0; i < numberOfElements; i++) { if (random.nextDouble() < NULL_FRACTION) { builder.appendNull(); } else { builder.writeLong(random.nextLong()); } } parentBuilder.closeEntry(); }
Example 18
Source File: LongTimestampType.java From presto with Apache License 2.0 | 4 votes |
public void write(BlockBuilder blockBuilder, long epochMicros, int fraction) { blockBuilder.writeLong(epochMicros); blockBuilder.writeInt(fraction); blockBuilder.closeEntry(); }
Example 19
Source File: TimestampTypes.java From presto with Apache License 2.0 | 4 votes |
public static void writeLongTimestamp(BlockBuilder blockBuilder, long epochMicros, int fraction) { blockBuilder.writeLong(epochMicros); blockBuilder.writeInt(fraction); blockBuilder.closeEntry(); }
Example 20
Source File: TestReaderProjectionsAdapter.java From presto with Apache License 2.0 | 4 votes |
private static Block createProjectedColumnBlock(Block data, Type finalType, Type blockType, List<Integer> dereferences) { if (dereferences.size() == 0) { return data; } BlockBuilder builder = finalType.createBlockBuilder(null, data.getPositionCount()); for (int i = 0; i < data.getPositionCount(); i++) { Type sourceType = blockType; Block currentData = null; boolean isNull = data.isNull(i); if (!isNull) { // Get SingleRowBlock corresponding to element at position i currentData = data.getObject(i, Block.class); } // Apply all dereferences except for the last one, because the type can be different for (int j = 0; j < dereferences.size() - 1; j++) { if (isNull) { // If null element is discovered at any dereferencing step, break break; } checkArgument(sourceType instanceof RowType); if (currentData.isNull(dereferences.get(j))) { currentData = null; } else { sourceType = ((RowType) sourceType).getFields().get(dereferences.get(j)).getType(); currentData = currentData.getObject(dereferences.get(j), Block.class); } isNull = isNull || (currentData == null); } if (isNull) { // Append null if any of the elements in the dereference chain were null builder.appendNull(); } else { int lastDereference = dereferences.get(dereferences.size() - 1); if (currentData.isNull(lastDereference)) { // Append null if the last dereference is null builder.appendNull(); } else { // Append actual values otherwise if (finalType.equals(BIGINT)) { Long value = currentData.getLong(lastDereference, 0); builder.writeLong(value); } else if (finalType instanceof RowType) { Block block = currentData.getObject(lastDereference, Block.class); builder.appendStructure(block); } else { throw new UnsupportedOperationException(); } } } } return builder.build(); }