Search in sources :

Example 21 with BlockBuilder

use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.

the class TestUuidOperators method hashFromType.

private static long hashFromType(String uuidString) {
    BlockBuilder blockBuilder = UUID.createBlockBuilder(null, 1);
    UUID.writeSlice(blockBuilder, castFromVarcharToUuid(utf8Slice(uuidString)));
    Block block = blockBuilder.build();
    return UUID.hash(block, 0);
}
Also used : Block(io.prestosql.spi.block.Block) BlockBuilder(io.prestosql.spi.block.BlockBuilder)

Example 22 with BlockBuilder

use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.

the class TestVarbinaryType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = VARBINARY.createBlockBuilder(null, 15);
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("apple"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("apple"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("apple"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("banana"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("banana"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("banana"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("banana"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("banana"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("cherry"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("cherry"));
    VARBINARY.writeSlice(blockBuilder, Slices.utf8Slice("date"));
    return blockBuilder.build();
}
Also used : BlockBuilder(io.prestosql.spi.block.BlockBuilder)

Example 23 with BlockBuilder

use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.

the class TestVarcharType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = VARCHAR.createBlockBuilder(null, 15);
    VARCHAR.writeString(blockBuilder, "apple");
    VARCHAR.writeString(blockBuilder, "apple");
    VARCHAR.writeString(blockBuilder, "apple");
    VARCHAR.writeString(blockBuilder, "banana");
    VARCHAR.writeString(blockBuilder, "banana");
    VARCHAR.writeString(blockBuilder, "banana");
    VARCHAR.writeString(blockBuilder, "banana");
    VARCHAR.writeString(blockBuilder, "banana");
    VARCHAR.writeString(blockBuilder, "cherry");
    VARCHAR.writeString(blockBuilder, "cherry");
    VARCHAR.writeString(blockBuilder, "date");
    return blockBuilder.build();
}
Also used : BlockBuilder(io.prestosql.spi.block.BlockBuilder)

Example 24 with BlockBuilder

use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.

the class TestPage method createSlicesBlock.

private static Block createSlicesBlock(Slice[] values) {
    BlockBuilder builder = VARBINARY.createBlockBuilder(null, 100);
    for (Slice value : values) {
        verify(value != null);
        VARBINARY.writeSlice(builder, value);
    }
    return builder.build();
}
Also used : Slice(io.airlift.slice.Slice) BlockBuilder(io.prestosql.spi.block.BlockBuilder)

Example 25 with BlockBuilder

use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.

the class AbstractTestType method createBlock.

private static Block createBlock(Type type, Object value) {
    BlockBuilder blockBuilder = type.createBlockBuilder(null, 1);
    Class<?> javaType = type.getJavaType();
    if (value == null) {
        blockBuilder.appendNull();
    } else if (javaType == boolean.class) {
        type.writeBoolean(blockBuilder, (Boolean) value);
    } else if (javaType == long.class) {
        type.writeLong(blockBuilder, (Long) value);
    } else if (javaType == double.class) {
        type.writeDouble(blockBuilder, (Double) value);
    } else if (javaType == Slice.class) {
        Slice slice = (Slice) value;
        type.writeSlice(blockBuilder, slice, 0, slice.length());
    } else {
        type.writeObject(blockBuilder, value);
    }
    return blockBuilder.build();
}
Also used : Slice(io.airlift.slice.Slice) BlockBuilder(io.prestosql.spi.block.BlockBuilder)

Aggregations

BlockBuilder (io.prestosql.spi.block.BlockBuilder)440 Block (io.prestosql.spi.block.Block)100 Test (org.testng.annotations.Test)84 Slice (io.airlift.slice.Slice)80 Type (io.prestosql.spi.type.Type)78 Page (io.prestosql.spi.Page)52 SqlType (io.prestosql.spi.function.SqlType)42 ArrayType (io.prestosql.spi.type.ArrayType)38 Map (java.util.Map)36 RowType (io.prestosql.spi.type.RowType)34 MapType (io.prestosql.spi.type.MapType)31 List (java.util.List)26 PageBuilder (io.prestosql.spi.PageBuilder)24 TimestampType (io.prestosql.spi.type.TimestampType)24 ImmutableList (com.google.common.collect.ImmutableList)23 PrestoException (io.prestosql.spi.PrestoException)23 BigintType (io.prestosql.spi.type.BigintType)23 BooleanType (io.prestosql.spi.type.BooleanType)21 DoubleType (io.prestosql.spi.type.DoubleType)21 UsedByGeneratedCode (io.prestosql.spi.annotation.UsedByGeneratedCode)20