Search in sources :

Example 16 with BlockBuilder

use of com.facebook.presto.spi.block.BlockBuilder in project presto by prestodb.

the class TestTimeWithTimeZoneType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = TIME_WITH_TIME_ZONE.createBlockBuilder(new BlockBuilderStatus(), 15);
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(1111, getTimeZoneKeyForOffset(0)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(1111, getTimeZoneKeyForOffset(1)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(1111, getTimeZoneKeyForOffset(2)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(3)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(4)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(5)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(6)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(7)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(3333, getTimeZoneKeyForOffset(8)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(3333, getTimeZoneKeyForOffset(9)));
    TIME_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(4444, getTimeZoneKeyForOffset(10)));
    return blockBuilder.build();
}
Also used : BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Example 17 with BlockBuilder

use of com.facebook.presto.spi.block.BlockBuilder in project presto by prestodb.

the class TestColorArrayType method createTestBlock.

public static Block createTestBlock(Type arrayType) {
    BlockBuilder blockBuilder = arrayType.createBlockBuilder(new BlockBuilderStatus(), 4);
    arrayType.writeObject(blockBuilder, arrayBlockOf(COLOR, 1, 2));
    arrayType.writeObject(blockBuilder, arrayBlockOf(COLOR, 1, 2, 3));
    arrayType.writeObject(blockBuilder, arrayBlockOf(COLOR, 1, 2, 3));
    arrayType.writeObject(blockBuilder, arrayBlockOf(COLOR, 100, 200, 300));
    return blockBuilder.build();
}
Also used : BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Example 18 with BlockBuilder

use of com.facebook.presto.spi.block.BlockBuilder in project presto by prestodb.

the class TestDateType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = DATE.createBlockBuilder(new BlockBuilderStatus(), 15);
    DATE.writeLong(blockBuilder, 1111);
    DATE.writeLong(blockBuilder, 1111);
    DATE.writeLong(blockBuilder, 1111);
    DATE.writeLong(blockBuilder, 2222);
    DATE.writeLong(blockBuilder, 2222);
    DATE.writeLong(blockBuilder, 2222);
    DATE.writeLong(blockBuilder, 2222);
    DATE.writeLong(blockBuilder, 2222);
    DATE.writeLong(blockBuilder, 3333);
    DATE.writeLong(blockBuilder, 3333);
    DATE.writeLong(blockBuilder, 4444);
    return blockBuilder.build();
}
Also used : BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Example 19 with BlockBuilder

use of com.facebook.presto.spi.block.BlockBuilder in project presto by prestodb.

the class TestTimestampWithTimeZoneType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = TIMESTAMP_WITH_TIME_ZONE.createBlockBuilder(new BlockBuilderStatus(), 15);
    TIMESTAMP_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(1111, getTimeZoneKeyForOffset(0)));
    TIMESTAMP_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(1111, getTimeZoneKeyForOffset(1)));
    TIMESTAMP_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(1111, getTimeZoneKeyForOffset(2)));
    TIMESTAMP_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(3)));
    TIMESTAMP_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(4)));
    TIMESTAMP_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(5)));
    TIMESTAMP_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(6)));
    TIMESTAMP_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(2222, getTimeZoneKeyForOffset(7)));
    TIMESTAMP_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(3333, getTimeZoneKeyForOffset(8)));
    TIMESTAMP_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(3333, getTimeZoneKeyForOffset(9)));
    TIMESTAMP_WITH_TIME_ZONE.writeLong(blockBuilder, packDateTimeWithZone(4444, getTimeZoneKeyForOffset(10)));
    return blockBuilder.build();
}
Also used : BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Example 20 with BlockBuilder

use of com.facebook.presto.spi.block.BlockBuilder in project presto by prestodb.

the class TestTinyintArrayType method getGreaterValue.

@Override
protected Object getGreaterValue(Object value) {
    Block block = (Block) value;
    BlockBuilder blockBuilder = TINYINT.createBlockBuilder(new BlockBuilderStatus(), block.getPositionCount() + 1);
    for (int i = 0; i < block.getPositionCount(); i++) {
        TINYINT.appendTo(block, i, blockBuilder);
    }
    TINYINT.writeLong(blockBuilder, 1L);
    return blockBuilder.build();
}
Also used : Block(com.facebook.presto.spi.block.Block) BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Aggregations

BlockBuilder (com.facebook.presto.spi.block.BlockBuilder)290 BlockBuilderStatus (com.facebook.presto.spi.block.BlockBuilderStatus)211 Block (com.facebook.presto.spi.block.Block)56 Slice (io.airlift.slice.Slice)53 InterleavedBlockBuilder (com.facebook.presto.spi.block.InterleavedBlockBuilder)39 Test (org.testng.annotations.Test)38 Type (com.facebook.presto.spi.type.Type)33 SqlType (com.facebook.presto.spi.function.SqlType)24 ArrayType (com.facebook.presto.type.ArrayType)19 Page (com.facebook.presto.spi.Page)18 UsedByGeneratedCode (com.facebook.presto.annotation.UsedByGeneratedCode)17 TypeParameter (com.facebook.presto.spi.function.TypeParameter)15 MapType (com.facebook.presto.type.MapType)14 RowType (com.facebook.presto.type.RowType)14 TypeJsonUtils.appendToBlockBuilder (com.facebook.presto.type.TypeJsonUtils.appendToBlockBuilder)13 PageBuilder (com.facebook.presto.spi.PageBuilder)12 ImmutableList (com.google.common.collect.ImmutableList)12 PrestoException (com.facebook.presto.spi.PrestoException)11 RunLengthEncodedBlock (com.facebook.presto.spi.block.RunLengthEncodedBlock)11 DictionaryBlock (com.facebook.presto.spi.block.DictionaryBlock)10