Java Code Examples for io.prestosql.spi.block.BlockBuilder#writeInt()

The following examples show how to use io.prestosql.spi.block.BlockBuilder#writeInt() . 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: TestInt96ArrayBlock.java    From presto with Apache License 2.0 5 votes vote down vote up
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 2
Source File: TestRealType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testNaNHash()
{
    BlockBuilder blockBuilder = new IntArrayBlockBuilder(null, 4);
    blockBuilder.writeInt(floatToIntBits(Float.NaN));
    blockBuilder.writeInt(floatToRawIntBits(Float.NaN));
    // the following two are the integer values of a float NaN
    blockBuilder.writeInt(-0x400000);
    blockBuilder.writeInt(0x7fc00000);

    assertEquals(REAL.hash(blockBuilder, 0), REAL.hash(blockBuilder, 1));
    assertEquals(REAL.hash(blockBuilder, 0), REAL.hash(blockBuilder, 2));
    assertEquals(REAL.hash(blockBuilder, 0), REAL.hash(blockBuilder, 3));
}
 
Example 3
Source File: LongTimestampType.java    From presto with Apache License 2.0 5 votes vote down vote up
@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 4
Source File: LongTimestampWithTimeZoneType.java    From presto with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: LongTimestampWithTimeZoneType.java    From presto with Apache License 2.0 5 votes vote down vote up
@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: TestBlockBigArray.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testRetainedSizeWithOverlappingBlocks()
{
    int entries = 123;
    BlockBuilder blockBuilder = new IntArrayBlockBuilder(null, entries);
    for (int i = 0; i < entries; i++) {
        blockBuilder.writeInt(i);
    }
    Block block = blockBuilder.build();

    // Verify we do not over count
    int arraySize = 456;
    int blocks = 7890;
    BlockBigArray blockBigArray = new BlockBigArray();
    blockBigArray.ensureCapacity(arraySize);
    for (int i = 0; i < blocks; i++) {
        blockBigArray.set(i % arraySize, block.getRegion(0, entries));
    }

    ReferenceCountMap referenceCountMap = new ReferenceCountMap();
    referenceCountMap.incrementAndGet(block);
    long expectedSize = ClassLayout.parseClass(BlockBigArray.class).instanceSize()
            + referenceCountMap.sizeOf()
            + (new ObjectBigArray<>()).sizeOf()
            + block.getRetainedSizeInBytes() + (arraySize - 1) * ClassLayout.parseClass(block.getClass()).instanceSize();
    assertEquals(blockBigArray.sizeOf(), expectedSize);
}
 
Example 7
Source File: LongTimestampType.java    From presto with Apache License 2.0 4 votes vote down vote up
public void write(BlockBuilder blockBuilder, long epochMicros, int fraction)
{
    blockBuilder.writeLong(epochMicros);
    blockBuilder.writeInt(fraction);
    blockBuilder.closeEntry();
}
 
Example 8
Source File: TimestampTypes.java    From presto with Apache License 2.0 4 votes vote down vote up
public static void writeLongTimestamp(BlockBuilder blockBuilder, long epochMicros, int fraction)
{
    blockBuilder.writeLong(epochMicros);
    blockBuilder.writeInt(fraction);
    blockBuilder.closeEntry();
}
 
Example 9
Source File: IntegerDecoder.java    From presto with Apache License 2.0 4 votes vote down vote up
@Override
public void decode(Supplier<Object> getter, BlockBuilder output)
{
    output.writeInt(((Number) getter.get()).intValue());
}
 
Example 10
Source File: PrestoFloat.java    From transport with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void writeToBlock(BlockBuilder blockBuilder) {
  blockBuilder.writeInt(floatToIntBits(_float));
}