use of io.airlift.slice.DynamicSliceOutput in project presto by prestodb.
the class TestRcFileReaderManual method testNoStartSync.
@Test
public void testNoStartSync() throws Exception {
SliceOutput output = new DynamicSliceOutput(10 * 1024);
List<Segment> segments = ImmutableList.of(writeSegment(output, ImmutableList.of(ImmutableList.of(0, 2, 3, 4), ImmutableList.of(10, 12, 13))), writeSegment(output, ImmutableList.of(ImmutableList.of(20, 22), ImmutableList.of(30, 33), ImmutableList.of(40, 44))), writeSegment(output, ImmutableList.of(ImmutableList.of(100, 101, 102))));
assertFileSegments(output.slice(), segments);
}
use of io.airlift.slice.DynamicSliceOutput in project presto by prestodb.
the class TestVariableWidthBlockEncoding method testRoundTrip.
@Test
public void testRoundTrip() {
BlockBuilder expectedBlockBuilder = VARCHAR.createBlockBuilder(new BlockBuilderStatus(), 4);
VARCHAR.writeString(expectedBlockBuilder, "alice");
VARCHAR.writeString(expectedBlockBuilder, "bob");
VARCHAR.writeString(expectedBlockBuilder, "charlie");
VARCHAR.writeString(expectedBlockBuilder, "dave");
Block expectedBlock = expectedBlockBuilder.build();
DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
BlockEncoding blockEncoding = new VariableWidthBlockEncoding();
blockEncoding.writeBlock(sliceOutput, expectedBlock);
Block actualBlock = blockEncoding.readBlock(sliceOutput.slice().getInput());
assertBlockEquals(VARCHAR, actualBlock, expectedBlock);
}
use of io.airlift.slice.DynamicSliceOutput in project presto by prestodb.
the class TestTypeSerde method testRoundTrip.
@Test
public void testRoundTrip() {
DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
writeType(sliceOutput, BOOLEAN);
Type actualType = readType(new TestingTypeManager(), sliceOutput.slice().getInput());
assertEquals(actualType, BOOLEAN);
}
use of io.airlift.slice.DynamicSliceOutput in project presto by prestodb.
the class VariableWidthBlockBuilder method reset.
@Override
public void reset(BlockBuilderStatus blockBuilderStatus) {
this.blockBuilderStatus = requireNonNull(blockBuilderStatus, "blockBuilderStatus is null");
int newSize = calculateBlockResetSize(positions);
valueIsNull = new boolean[newSize];
offsets = new int[newSize + 1];
sliceOutput = new DynamicSliceOutput(calculateBlockResetSize(sliceOutput.size()));
positions = 0;
currentEntrySize = 0;
updateArraysDataSize();
}
Aggregations