Package com.facebook.presto.spi.block

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


            // missing file and a file that legitimately has no rows.
            createEmptyFile();
            return;
        }

        BlockEncoding blockEncoding = encoder.finish();

        int startingIndex = sliceOutput.size();

        // write file encoding
        blockEncodingSerde.writeBlockEncoding(sliceOutput, blockEncoding);
View Full Code Here


                .appendSlice(Slices.utf8Slice("charlie"))
                .appendSlice(Slices.utf8Slice("charlie"))
                .build();

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
        BlockEncoding blockEncoding = new RunLengthEncoder(sliceOutput).append(expectedBlock).finish();
        SliceInput sliceInput = sliceOutput.slice().getInput();

        Block block = blockEncoding.readBlock(sliceInput);
        assertInstanceOf(block, RunLengthEncodedBlock.class);
        RunLengthEncodedBlock rleBlock = (RunLengthEncodedBlock) block;
        assertTrue(rleBlock.equalTo(0, expectedBlock, 0));
        assertEquals(rleBlock.getPositionCount(), 2);
        assertEquals(rleBlock.getSlice(0).toStringUtf8(), "alice");

        block = blockEncoding.readBlock(sliceInput);
        assertInstanceOf(block, RunLengthEncodedBlock.class);
        rleBlock = (RunLengthEncodedBlock) block;
        assertTrue(rleBlock.equalTo(0, expectedBlock, 2));
        assertEquals(rleBlock.getPositionCount(), 4);
        assertEquals(rleBlock.getSlice(0).toStringUtf8(), "bob");

        block = blockEncoding.readBlock(sliceInput);
        assertInstanceOf(block, RunLengthEncodedBlock.class);
        rleBlock = (RunLengthEncodedBlock) block;
        assertTrue(rleBlock.equalTo(0, expectedBlock, 6));
        assertEquals(rleBlock.getPositionCount(), 6);
        assertEquals(rleBlock.getSlice(0).toStringUtf8(), "charlie");
View Full Code Here

                .appendSlice(Slices.utf8Slice("charlie"))
                .appendSlice(Slices.utf8Slice("dave"))
                .build();

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
        BlockEncoding blockEncoding = new VariableWidthBlockEncoding(VARCHAR);
        blockEncoding.writeBlock(sliceOutput, expectedBlock);
        Block actualBlock = blockEncoding.readBlock(sliceOutput.slice().getInput());
        BlockAssertions.assertBlockEquals(actualBlock, expectedBlock);
    }
View Full Code Here

                .appendSlice(Slices.utf8Slice("charlie"))
                .appendSlice(Slices.utf8Slice("dave"))
                .build();

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
        BlockEncoding blockEncoding = new UncompressedEncoder(sliceOutput).append(block).append(block).finish();
        Block actualBlock = blockEncoding.readBlock(sliceOutput.slice().getInput());
        BlockAssertions.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

                .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

        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

            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

                Block[] blocks = page.getBlocks();
                blockEncodings = new BlockEncoding[blocks.length];
                sliceOutput.writeInt(blocks.length);
                for (int i = 0; i < blocks.length; i++) {
                    Block block = blocks[i];
                    BlockEncoding blockEncoding = block.getEncoding();
                    blockEncodings[i] = blockEncoding;
                    blockEncodingSerde.writeBlockEncoding(sliceOutput, blockEncoding);
                }
            }
View Full Code Here

            // missing file and a file that legitimately has no rows.
            createEmptyFile();
            return;
        }

        BlockEncoding blockEncoding = encoder.finish();

        int startingIndex = sliceOutput.size();

        // write file encoding
        blockEncodingSerde.writeBlockEncoding(sliceOutput, blockEncoding);
View Full Code Here

        @Override
        public DictionaryBlockEncoding readEncoding(TypeManager manager, BlockEncodingSerde serde, SliceInput input)
        {
            // read the dictionary
            BlockEncoding dictionaryEncoding = serde.readBlockEncoding(input);
            RandomAccessBlock dictionary = dictionaryEncoding.readBlock(input).toRandomAccessBlock();

            // read the id block encoding
            BlockEncoding idBlockEncoding = serde.readBlockEncoding(input);
            return new DictionaryBlockEncoding(dictionary, idBlockEncoding);
        }
View Full Code Here

TOP

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

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.