Search in sources :

Example 91 with BlockBuilder

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

the class TestDoubleType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = DOUBLE.createBlockBuilder(null, 15);
    DOUBLE.writeDouble(blockBuilder, 11.11);
    DOUBLE.writeDouble(blockBuilder, 11.11);
    DOUBLE.writeDouble(blockBuilder, 11.11);
    DOUBLE.writeDouble(blockBuilder, 22.22);
    DOUBLE.writeDouble(blockBuilder, 22.22);
    DOUBLE.writeDouble(blockBuilder, 22.22);
    DOUBLE.writeDouble(blockBuilder, 22.22);
    DOUBLE.writeDouble(blockBuilder, 22.22);
    DOUBLE.writeDouble(blockBuilder, 33.33);
    DOUBLE.writeDouble(blockBuilder, 33.33);
    DOUBLE.writeDouble(blockBuilder, 44.44);
    return blockBuilder.build();
}
Also used : BlockBuilder(com.facebook.presto.common.block.BlockBuilder) LongArrayBlockBuilder(com.facebook.presto.common.block.LongArrayBlockBuilder)

Example 92 with BlockBuilder

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

the class TestSmallintType method createTestBlock.

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

Example 93 with BlockBuilder

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

the class TestMapOperators method assertMapHashOperator.

private void assertMapHashOperator(String inputString, Type keyType, Type valueType, List<Object> elements) {
    checkArgument(elements.size() % 2 == 0, "the size of elements should be even number");
    MapType mapType = mapType(keyType, valueType);
    BlockBuilder mapArrayBuilder = mapType.createBlockBuilder(null, 1);
    BlockBuilder singleMapWriter = mapArrayBuilder.beginBlockEntry();
    for (int i = 0; i < elements.size(); i += 2) {
        appendToBlockBuilder(keyType, elements.get(i), singleMapWriter);
        appendToBlockBuilder(valueType, elements.get(i + 1), singleMapWriter);
    }
    mapArrayBuilder.closeEntry();
    long hashResult = mapType.hash(mapArrayBuilder.build(), 0);
    assertOperator(HASH_CODE, inputString, BIGINT, hashResult);
}
Also used : MapType(com.facebook.presto.common.type.MapType) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) StructuralTestUtil.appendToBlockBuilder(com.facebook.presto.util.StructuralTestUtil.appendToBlockBuilder)

Example 94 with BlockBuilder

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

the class TestColorArrayType method createTestBlock.

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

Example 95 with BlockBuilder

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

the class TestIpAddressType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = IPADDRESS.createBlockBuilder(null, 1);
    IPADDRESS.writeSlice(blockBuilder, getSliceForAddress("2001:db8::ff00:42:8320"));
    IPADDRESS.writeSlice(blockBuilder, getSliceForAddress("2001:db8::ff00:42:8321"));
    IPADDRESS.writeSlice(blockBuilder, getSliceForAddress("2001:db8::ff00:42:8322"));
    IPADDRESS.writeSlice(blockBuilder, getSliceForAddress("2001:db8::ff00:42:8323"));
    IPADDRESS.writeSlice(blockBuilder, getSliceForAddress("2001:db8::ff00:42:8324"));
    IPADDRESS.writeSlice(blockBuilder, getSliceForAddress("2001:db8::ff00:42:8325"));
    IPADDRESS.writeSlice(blockBuilder, getSliceForAddress("2001:db8::ff00:42:8326"));
    IPADDRESS.writeSlice(blockBuilder, getSliceForAddress("2001:db8::ff00:42:8327"));
    IPADDRESS.writeSlice(blockBuilder, getSliceForAddress("2001:db8::ff00:42:8328"));
    IPADDRESS.writeSlice(blockBuilder, getSliceForAddress("2001:db8::ff00:42:8329"));
    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