Package com.facebook.presto.spi.block

Examples of com.facebook.presto.spi.block.Block


        extends AbstractTestBlockCursor
{
    @Override
    protected RunLengthEncodedBlockCursor createTestCursor()
    {
        Block value = VARCHAR.createBlockBuilder(new BlockBuilderStatus())
                .appendNull()
                .build();

        return new RunLengthEncodedBlock(value, 11).cursor();
    }
View Full Code Here


        extends AbstractTestBlockCursor
{
    @Override
    protected RunLengthEncodedBlockCursor createTestCursor()
    {
        Block value = VARCHAR.createBlockBuilder(new BlockBuilderStatus())
                .appendSlice(Slices.utf8Slice("cherry"))
                .build();

        return new RunLengthEncodedBlock(value, 11).cursor();
    }
View Full Code Here

public class TestDictionaryEncodedBlockSerde
{
    @Test
    public void testRoundTrip()
    {
        Block block = VARCHAR.createBlockBuilder(new BlockBuilderStatus())
                .appendSlice(Slices.utf8Slice("alice"))
                .appendSlice(Slices.utf8Slice("bob"))
                .appendSlice(Slices.utf8Slice("charlie"))
                .appendSlice(Slices.utf8Slice("dave"))
                .build();

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
        BlockEncoding blockEncoding = new DictionaryEncoder(new UncompressedEncoder(sliceOutput)).append(block).append(block).append(block).finish();
        Block actualBlock = blockEncoding.readBlock(sliceOutput.slice().getInput());
        assertBlockEquals(actualBlock, VARCHAR.createBlockBuilder(new BlockBuilderStatus())
                .appendSlice(Slices.utf8Slice("alice"))
                .appendSlice(Slices.utf8Slice("bob"))
                .appendSlice(Slices.utf8Slice("charlie"))
                .appendSlice(Slices.utf8Slice("dave"))
View Full Code Here

public class TestSnappyBlockSerde
{
    @Test
    public void testRoundTrip()
    {
        Block block = VARCHAR.createBlockBuilder(new BlockBuilderStatus())
                .appendSlice(Slices.utf8Slice("alice"))
                .appendSlice(Slices.utf8Slice("bob"))
                .appendSlice(Slices.utf8Slice("charlie"))
                .appendSlice(Slices.utf8Slice("dave"))
                .build();

        DynamicSliceOutput compressedOutput = new DynamicSliceOutput(1024);
        Encoder encoder = BlocksFileEncoding.SNAPPY.createBlocksWriter(compressedOutput);

        encoder.append(block);
        BlockEncoding snappyEncoding = encoder.finish();
        Block actualBlock = snappyEncoding.readBlock(compressedOutput.slice().getInput());
        BlockAssertions.assertBlockEquals(actualBlock, block);
    }
View Full Code Here

    }

    @Test
    public void testLotsOfStuff()
    {
        Block block = VARCHAR.createBlockBuilder(new BlockBuilderStatus())
                .appendSlice(Slices.utf8Slice("alice"))
                .appendSlice(Slices.utf8Slice("bob"))
                .appendSlice(Slices.utf8Slice("charlie"))
                .appendSlice(Slices.utf8Slice("dave"))
                .build();

        DynamicSliceOutput encoderOutput = new DynamicSliceOutput(1024);
        Encoder encoder = BlocksFileEncoding.SNAPPY.createBlocksWriter(encoderOutput);

        BlockBuilder expectedBlockBuilder = VARCHAR.createBlockBuilder(new BlockBuilderStatus());

        int count = 1000;
        for (int i = 0; i < count; i++) {
            // select a random position
            int position = ThreadLocalRandom.current().nextInt(block.getPositionCount());

            // add to expected block
            block.appendTo(position, expectedBlockBuilder);

            // create block with single value and add to encoder
            encoder.append(block.getSingleValueBlock(position));
        }

        Block expectedBlock = expectedBlockBuilder.build();

        BlockEncoding snappyEncoding = encoder.finish();
        assertTrue(encoderOutput.size() < expectedBlock.getSizeInBytes());

        Block actualBlock = snappyEncoding.readBlock(encoderOutput.slice().getInput());

        BlockAssertions.assertBlockEquals(actualBlock, expectedBlock);
    }
View Full Code Here

    }

    @Override
    protected BlockCursor createTestCursor()
    {
        Block dictionary = VARCHAR.createBlockBuilder(new BlockBuilderStatus())
                .appendNull()
                .appendSlice(Slices.utf8Slice("apple"))
                .appendSlice(Slices.utf8Slice("banana"))
                .appendSlice(Slices.utf8Slice("cherry"))
                .appendSlice(Slices.utf8Slice("date"))
View Full Code Here

        }

        public BlockIterableBuilder newBlock()
        {
            if (!blockBuilder.isEmpty()) {
                Block block = blockBuilder.build();
                blocks.add(block);
                blockBuilder = block.getType().createBlockBuilder(new BlockBuilderStatus());
            }
            return this;
        }
View Full Code Here

    }

    @Override
    protected BlockCursor createTestCursor()
    {
        Block dictionary = VARCHAR.createBlockBuilder(new BlockBuilderStatus())
                .appendSlice(Slices.utf8Slice("apple"))
                .appendSlice(Slices.utf8Slice("banana"))
                .appendSlice(Slices.utf8Slice("cherry"))
                .appendSlice(Slices.utf8Slice("date"))
                .build();
View Full Code Here

    public void addInput(Page page)
    {
        checkNotNull(page, "page is null");
        checkState(!isFinished(), "Operator is already finished");

        Block sourceBlock = page.getBlock(setChannel);
        channelSetBuilder.addBlock(sourceBlock);
    }
View Full Code Here

        return encoding;
    }

    private void writeBlock()
    {
        Block block = blockBuilder.build();
        encoding.writeBlock(sliceOutput, block);
        blockBuilder = block.getType().createBlockBuilder(new BlockBuilderStatus());
    }
View Full Code Here

TOP

Related Classes of com.facebook.presto.spi.block.Block

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.