Search in sources :

Example 21 with BlockBuilder

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

the class TestDoubleType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = DOUBLE.createBlockBuilder(new BlockBuilderStatus(), 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.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Example 22 with BlockBuilder

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

the class TestIntegerArrayType method getGreaterValue.

@Override
protected Object getGreaterValue(Object value) {
    Block block = (Block) value;
    BlockBuilder blockBuilder = INTEGER.createBlockBuilder(new BlockBuilderStatus(), block.getPositionCount() + 1);
    for (int i = 0; i < block.getPositionCount(); i++) {
        INTEGER.appendTo(block, i, blockBuilder);
    }
    INTEGER.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)

Example 23 with BlockBuilder

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

the class TestIntegerType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = INTEGER.createBlockBuilder(new BlockBuilderStatus(), 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.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Example 24 with BlockBuilder

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

the class TestJsonType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = JSON.createBlockBuilder(new BlockBuilderStatus(), 1);
    Slice slice = Slices.utf8Slice("{\"x\":1, \"y\":2}");
    JSON.writeSlice(blockBuilder, slice);
    return blockBuilder.build();
}
Also used : Slice(io.airlift.slice.Slice) BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Example 25 with BlockBuilder

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

the class MLFunctions method featuresHelper.

private static Block featuresHelper(double... features) {
    BlockBuilder blockBuilder = new InterleavedBlockBuilder(ImmutableList.of(BigintType.BIGINT, DoubleType.DOUBLE), new BlockBuilderStatus(), features.length);
    for (int i = 0; i < features.length; i++) {
        BigintType.BIGINT.writeLong(blockBuilder, i);
        DoubleType.DOUBLE.writeDouble(blockBuilder, features[i]);
    }
    return blockBuilder.build();
}
Also used : InterleavedBlockBuilder(com.facebook.presto.spi.block.InterleavedBlockBuilder) BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) InterleavedBlockBuilder(com.facebook.presto.spi.block.InterleavedBlockBuilder) 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