Search in sources :

Example 86 with BlockBuilder

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

the class TestRowOperators method assertRowHashOperator.

private void assertRowHashOperator(String inputString, List<Type> types, List<Object> elements) {
    checkArgument(types.size() == elements.size(), "types and elements must have the same size");
    RowType rowType = RowType.anonymous(types);
    BlockBuilder blockBuilder = rowType.createBlockBuilder(null, 1);
    BlockBuilder singleRowBlockWriter = blockBuilder.beginBlockEntry();
    for (int i = 0; i < types.size(); i++) {
        appendToBlockBuilder(types.get(i), elements.get(i), singleRowBlockWriter);
    }
    blockBuilder.closeEntry();
    assertOperator(HASH_CODE, inputString, BIGINT, rowType.hash(blockBuilder.build(), 0));
}
Also used : RowType(com.facebook.presto.common.type.RowType) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) StructuralTestUtil.appendToBlockBuilder(com.facebook.presto.util.StructuralTestUtil.appendToBlockBuilder)

Example 87 with BlockBuilder

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

the class TestShortDecimalType method createTestBlock.

public static Block createTestBlock() {
    BlockBuilder blockBuilder = SHORT_DECIMAL_TYPE.createBlockBuilder(null, 15);
    SHORT_DECIMAL_TYPE.writeLong(blockBuilder, -1234);
    SHORT_DECIMAL_TYPE.writeLong(blockBuilder, -1234);
    SHORT_DECIMAL_TYPE.writeLong(blockBuilder, -1234);
    SHORT_DECIMAL_TYPE.writeLong(blockBuilder, 2321);
    SHORT_DECIMAL_TYPE.writeLong(blockBuilder, 2321);
    SHORT_DECIMAL_TYPE.writeLong(blockBuilder, 2321);
    SHORT_DECIMAL_TYPE.writeLong(blockBuilder, 2321);
    SHORT_DECIMAL_TYPE.writeLong(blockBuilder, 2321);
    SHORT_DECIMAL_TYPE.writeLong(blockBuilder, 3321);
    SHORT_DECIMAL_TYPE.writeLong(blockBuilder, 3321);
    SHORT_DECIMAL_TYPE.writeLong(blockBuilder, 4321);
    return blockBuilder.build();
}
Also used : BlockBuilder(com.facebook.presto.common.block.BlockBuilder)

Example 88 with BlockBuilder

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

the class TestSmallintArrayType method createTestBlock.

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

Example 89 with BlockBuilder

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

the class TestDateType method createTestBlock.

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

Example 90 with BlockBuilder

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

the class TestDoubleType method testNaNHash.

@Test
public void testNaNHash() {
    BlockBuilder blockBuilder = new LongArrayBlockBuilder(null, 4);
    blockBuilder.writeLong(doubleToLongBits(Double.NaN));
    blockBuilder.writeLong(doubleToRawLongBits(Double.NaN));
    // the following two are the long values of a double NaN
    blockBuilder.writeLong(-0x000fffffffffffffL);
    blockBuilder.writeLong(0x7ff8000000000000L);
    assertEquals(DOUBLE.hash(blockBuilder, 0), DOUBLE.hash(blockBuilder, 1));
    assertEquals(DOUBLE.hash(blockBuilder, 0), DOUBLE.hash(blockBuilder, 2));
    assertEquals(DOUBLE.hash(blockBuilder, 0), DOUBLE.hash(blockBuilder, 3));
}
Also used : LongArrayBlockBuilder(com.facebook.presto.common.block.LongArrayBlockBuilder) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) LongArrayBlockBuilder(com.facebook.presto.common.block.LongArrayBlockBuilder) Test(org.testng.annotations.Test)

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