use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.
the class TestArrayOperators method assertArrayHashOperator.
private void assertArrayHashOperator(String inputArray, Type elementType, List<Object> elements) {
ArrayType arrayType = new ArrayType(elementType);
BlockBuilder arrayArrayBuilder = arrayType.createBlockBuilder(null, 1);
BlockBuilder arrayBuilder = elementType.createBlockBuilder(null, elements.size());
for (Object element : elements) {
appendToBlockBuilder(elementType, element, arrayBuilder);
}
arrayType.writeObject(arrayArrayBuilder, arrayBuilder.build());
assertOperator(HASH_CODE, inputArray, BIGINT, arrayType.hash(arrayArrayBuilder.build(), 0));
}
use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.
the class TestBigintArrayType method createTestBlock.
public static Block createTestBlock(Type arrayType) {
BlockBuilder blockBuilder = arrayType.createBlockBuilder(null, 4);
arrayType.writeObject(blockBuilder, arrayBlockOf(BIGINT, 1, 2));
arrayType.writeObject(blockBuilder, arrayBlockOf(BIGINT, 1, 2, 3));
arrayType.writeObject(blockBuilder, arrayBlockOf(BIGINT, 1, 2, 3));
arrayType.writeObject(blockBuilder, arrayBlockOf(BIGINT, 100, 200, 300));
return blockBuilder.build();
}
use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.
the class TestCharType method testGetObjectValue.
@Test
public void testGetObjectValue() {
CharType charType = createCharType(3);
for (int codePoint : ImmutableList.of(0, 1, 10, 17, (int) ' ', 127, 1011, 11_000, 65_891, MIN_SUPPLEMENTARY_CODE_POINT, MAX_CODE_POINT)) {
BlockBuilder blockBuilder = charType.createBlockBuilder(null, 1);
Slice slice = (codePoint != ' ') ? codePointToUtf8(codePoint) : EMPTY_SLICE;
blockBuilder.writeBytes(slice, 0, slice.length());
blockBuilder.closeEntry();
Block block = blockBuilder.build();
int codePointLengthInUtf16 = isSupplementaryCodePoint(codePoint) ? 2 : 1;
String objectValue = (String) charType.getObjectValue(SESSION, block, 0);
assertNotNull(objectValue);
assertEquals(objectValue.codePointAt(0), codePoint, "first code point");
assertEquals(objectValue.length(), codePointLengthInUtf16 + 2, "size");
for (int i = codePointLengthInUtf16; i < objectValue.length(); i++) {
assertEquals(objectValue.codePointAt(i), ' ');
}
}
}
use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.
the class TestCharType method createTestBlock.
public static Block createTestBlock() {
BlockBuilder blockBuilder = CHAR_TYPE.createBlockBuilder(null, 15);
CHAR_TYPE.writeString(blockBuilder, "apple");
CHAR_TYPE.writeString(blockBuilder, "apple");
CHAR_TYPE.writeString(blockBuilder, "apple");
CHAR_TYPE.writeString(blockBuilder, "banana");
CHAR_TYPE.writeString(blockBuilder, "banana");
CHAR_TYPE.writeString(blockBuilder, "banana");
CHAR_TYPE.writeString(blockBuilder, "banana");
CHAR_TYPE.writeString(blockBuilder, "banana");
CHAR_TYPE.writeString(blockBuilder, "cherry");
CHAR_TYPE.writeString(blockBuilder, "cherry");
CHAR_TYPE.writeString(blockBuilder, "date");
return blockBuilder.build();
}
use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.
the class TestIntegerArrayType method createTestBlock.
public static Block createTestBlock(Type arrayType) {
BlockBuilder blockBuilder = arrayType.createBlockBuilder(null, 4);
arrayType.writeObject(blockBuilder, arrayBlockOf(INTEGER, 1, 2));
arrayType.writeObject(blockBuilder, arrayBlockOf(INTEGER, 1, 2, 3));
arrayType.writeObject(blockBuilder, arrayBlockOf(INTEGER, 1, 2, 3));
arrayType.writeObject(blockBuilder, arrayBlockOf(INTEGER, 100, 200, 300));
return blockBuilder.build();
}
Aggregations