Search in sources :

Example 21 with DynamicSliceOutput

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);
}
Also used : SliceOutput(io.airlift.slice.SliceOutput) DynamicSliceOutput(io.airlift.slice.DynamicSliceOutput) DynamicSliceOutput(io.airlift.slice.DynamicSliceOutput) Test(org.testng.annotations.Test)

Example 22 with DynamicSliceOutput

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);
}
Also used : DynamicSliceOutput(io.airlift.slice.DynamicSliceOutput) Test(org.testng.annotations.Test)

Example 23 with DynamicSliceOutput

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);
}
Also used : TypeSerde.readType(com.facebook.presto.spi.type.TypeSerde.readType) TypeSerde.writeType(com.facebook.presto.spi.type.TypeSerde.writeType) DynamicSliceOutput(io.airlift.slice.DynamicSliceOutput) Test(org.testng.annotations.Test)

Example 24 with DynamicSliceOutput

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();
}
Also used : DynamicSliceOutput(io.airlift.slice.DynamicSliceOutput)

Aggregations

DynamicSliceOutput (io.airlift.slice.DynamicSliceOutput)24 SliceOutput (io.airlift.slice.SliceOutput)9 Test (org.testng.annotations.Test)8 Block (com.facebook.presto.spi.block.Block)5 Slice (io.airlift.slice.Slice)4 BlockSerdeUtil.writeBlock (com.facebook.presto.block.BlockSerdeUtil.writeBlock)3 BlockBuilderStatus (com.facebook.presto.spi.block.BlockBuilderStatus)3 Page (com.facebook.presto.spi.Page)2 PrestoException (com.facebook.presto.spi.PrestoException)2 LiteralParameters (com.facebook.presto.spi.function.LiteralParameters)2 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)2 SqlType (com.facebook.presto.spi.function.SqlType)2 UsedByGeneratedCode (com.facebook.presto.annotation.UsedByGeneratedCode)1 BufferResult (com.facebook.presto.execution.buffer.BufferResult)1 Signature (com.facebook.presto.metadata.Signature)1 BlockBuilder (com.facebook.presto.spi.block.BlockBuilder)1 BlockEncoding (com.facebook.presto.spi.block.BlockEncoding)1 InterleavedBlockBuilder (com.facebook.presto.spi.block.InterleavedBlockBuilder)1 Description (com.facebook.presto.spi.function.Description)1 Type (com.facebook.presto.spi.type.Type)1