Search in sources :

Example 81 with BlockBuilder

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

the class TestIntegerType method createTestBlock.

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

Example 82 with BlockBuilder

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

the class TestIpAddressOperators method hashFromType.

private static long hashFromType(String address) {
    BlockBuilder blockBuilder = IPADDRESS.createBlockBuilder(null, 1);
    IPADDRESS.writeSlice(blockBuilder, Slices.wrappedBuffer(InetAddresses.forString(address).getAddress()));
    Block block = blockBuilder.build();
    return IPADDRESS.hash(block, 0);
}
Also used : Block(com.facebook.presto.common.block.Block) BlockBuilder(com.facebook.presto.common.block.BlockBuilder)

Example 83 with BlockBuilder

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

the class TestRealType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = REAL.createBlockBuilder(null, 30);
    REAL.writeLong(blockBuilder, floatToRawIntBits(11.11F));
    REAL.writeLong(blockBuilder, floatToRawIntBits(11.11F));
    REAL.writeLong(blockBuilder, floatToRawIntBits(11.11F));
    REAL.writeLong(blockBuilder, floatToRawIntBits(22.22F));
    REAL.writeLong(blockBuilder, floatToRawIntBits(22.22F));
    REAL.writeLong(blockBuilder, floatToRawIntBits(22.22F));
    REAL.writeLong(blockBuilder, floatToRawIntBits(22.22F));
    REAL.writeLong(blockBuilder, floatToRawIntBits(22.22F));
    REAL.writeLong(blockBuilder, floatToRawIntBits(33.33F));
    REAL.writeLong(blockBuilder, floatToRawIntBits(33.33F));
    REAL.writeLong(blockBuilder, floatToRawIntBits(44.44F));
    return blockBuilder.build();
}
Also used : BlockBuilder(com.facebook.presto.common.block.BlockBuilder) IntArrayBlockBuilder(com.facebook.presto.common.block.IntArrayBlockBuilder)

Example 84 with BlockBuilder

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

the class TestSmallintVarcharMapType method createTestBlock.

public static Block createTestBlock(Type mapType) {
    BlockBuilder blockBuilder = mapType.createBlockBuilder(null, 2);
    mapType.writeObject(blockBuilder, mapBlockOf(SMALLINT, VARCHAR, ImmutableMap.of(1, "hi")));
    mapType.writeObject(blockBuilder, mapBlockOf(SMALLINT, VARCHAR, ImmutableMap.of(1, "2", 2, "hello")));
    return blockBuilder.build();
}
Also used : BlockBuilder(com.facebook.presto.common.block.BlockBuilder)

Example 85 with BlockBuilder

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

the class TestTimeWithTimeZoneType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = TIME_WITH_TIME_ZONE.createBlockBuilder(null, 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.common.block.BlockBuilder)

Aggregations

BlockBuilder (com.facebook.presto.common.block.BlockBuilder)493 Block (com.facebook.presto.common.block.Block)124 Test (org.testng.annotations.Test)106 Slice (io.airlift.slice.Slice)85 Type (com.facebook.presto.common.type.Type)76 Page (com.facebook.presto.common.Page)49 SqlType (com.facebook.presto.spi.function.SqlType)46 ArrayType (com.facebook.presto.common.type.ArrayType)44 MapType (com.facebook.presto.common.type.MapType)32 RowType (com.facebook.presto.common.type.RowType)28 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)26 RowBlockBuilder (com.facebook.presto.common.block.RowBlockBuilder)22 PrestoException (com.facebook.presto.spi.PrestoException)22 PageBuilder (com.facebook.presto.common.PageBuilder)21 StructuralTestUtil.appendToBlockBuilder (com.facebook.presto.util.StructuralTestUtil.appendToBlockBuilder)21 Map (java.util.Map)21 UsedByGeneratedCode (com.facebook.presto.annotation.UsedByGeneratedCode)20 BlockAssertions.createLongsBlock (com.facebook.presto.block.BlockAssertions.createLongsBlock)19 DictionaryBlock (com.facebook.presto.common.block.DictionaryBlock)18 MapBlockBuilder (com.facebook.presto.common.block.MapBlockBuilder)18