use of com.facebook.presto.common.block.RowBlock in project presto by prestodb.
the class TestWriterBlockRawSize method testRowType.
@Test
public void testRowType() {
Type elementType = INTEGER;
Type rowType = RowType.anonymous(ImmutableList.of(elementType, elementType));
ColumnWriter columnWriter = createColumnWriter(rowType);
BlockBuilder blockBuilder = elementType.createBlockBuilder(null, NUM_ELEMENTS);
boolean[] isNull = new boolean[NUM_ELEMENTS * 2];
for (int i = 0; i < NUM_ELEMENTS; i++) {
elementType.writeLong(blockBuilder, i);
isNull[i * 2] = true;
}
Block elementBlock = blockBuilder.build();
Block[] elementBlocks = new Block[] { elementBlock, elementBlock };
Block rowBlock = RowBlock.fromFieldBlocks(NUM_ELEMENTS * 2, Optional.of(isNull), elementBlocks);
long rawSize = columnWriter.writeBlock(rowBlock);
long expectedSize = NUM_ELEMENTS + (NUM_ELEMENTS * 2 * ((FixedWidthType) elementType).getFixedSize());
assertEquals(rawSize, expectedSize);
}
Aggregations