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));
}
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();
}
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();
}
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();
}
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));
}
Aggregations