Package io.airlift.slice

Examples of io.airlift.slice.DynamicSliceOutput.slice()


            if (page != null) {
                headers.put(CONTENT_TYPE, PRESTO_PAGES);
                headers.put(PRESTO_PAGE_NEXT_TOKEN, String.valueOf(pageToken + 1));
                DynamicSliceOutput output = new DynamicSliceOutput(256);
                PagesSerde.writePages(output, page);
                return new TestingResponse(HttpStatus.OK, headers.build(), output.slice().getInput());
            }
            else if (taskBuffer.isFinished()) {
                headers.put(PRESTO_PAGE_NEXT_TOKEN, String.valueOf(pageToken));
                return new TestingResponse(HttpStatus.GONE, headers.build(), new byte[0]);
            }
View Full Code Here


        long nextToken = token + responsePages.size();
        tokenByLocation.put(location, nextToken);

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(64);
        PagesSerde.writePages(sliceOutput, responsePages);
        byte[] bytes = sliceOutput.slice().getBytes();
        return new TestingResponse(HttpStatus.OK,
                ImmutableListMultimap.of(
                        CONTENT_TYPE, PRESTO_PAGES,
                        PRESTO_PAGE_TOKEN, String.valueOf(token),
                        PRESTO_PAGE_NEXT_TOKEN, String.valueOf(nextToken)
View Full Code Here

    {
        TupleInfo expectedTupleInfo = new TupleInfo(BOOLEAN);

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
        writeTupleInfo(sliceOutput, expectedTupleInfo);
        TupleInfo actualTupleInfo = readTupleInfo(sliceOutput.slice().getInput());
        assertEquals(actualTupleInfo, expectedTupleInfo);
    }
}
View Full Code Here

                .build();

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
        BlockEncoding blockEncoding = new UncompressedBlockEncoding(SINGLE_VARBINARY);
        blockEncoding.writeBlock(sliceOutput, expectedBlock);
        Block actualBlock = blockEncoding.readBlock(sliceOutput.slice().getInput());
        BlockAssertions.assertBlockEquals(actualBlock, expectedBlock);
    }

    @Test
    public void testCreateBlockWriter()
View Full Code Here

                createTuple("charlie"),
                createTuple("dave"));

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
        BlockEncoding blockEncoding = new UncompressedEncoder(sliceOutput).append(tuples).append(tuples).finish();
        Block actualBlock = blockEncoding.readBlock(sliceOutput.slice().getInput());
        BlockAssertions.assertBlockEquals(actualBlock, new BlockBuilder(SINGLE_VARBINARY)
                .append("alice")
                .append("bob")
                .append("charlie")
                .append("dave")
View Full Code Here

                .build();
        Page expectedPage = new Page(expectedBlock, expectedBlock, expectedBlock);

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
        writePages(sliceOutput, expectedPage, expectedPage, expectedPage);
        Iterator<Page> pageIterator = readPages(sliceOutput.slice().getInput());
        assertPageEquals(pageIterator.next(), expectedPage);
        assertPageEquals(pageIterator.next(), expectedPage);
        assertPageEquals(pageIterator.next(), expectedPage);
        assertFalse(pageIterator.hasNext());
    }
View Full Code Here

                createTuple("charlie"),
                createTuple("dave"));

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
        BlockEncoding blockEncoding = new DictionaryEncoder(new UncompressedEncoder(sliceOutput)).append(tuples).append(tuples).append(tuples).finish();
        Block actualBlock = blockEncoding.readBlock(sliceOutput.slice().getInput());
        assertBlockEquals(actualBlock, new BlockBuilder(SINGLE_VARBINARY)
                .append("alice")
                .append("bob")
                .append("charlie")
                .append("dave")
View Full Code Here

        }
        Block expectedBlock = new UncompressedBlock(tuples.size(), TupleInfo.SINGLE_VARBINARY, blockSlice.slice());

        encoder.append(tuples);
        BlockEncoding snappyEncoding = encoder.finish();
        Block actualBlock = snappyEncoding.readBlock(compressedOutput.slice().getInput());
        BlockAssertions.assertBlockEquals(actualBlock, expectedBlock);
    }

    @Test
    public void testLotsOfStuff()
View Full Code Here

        Block expectedBlock = new UncompressedBlock(count, TupleInfo.SINGLE_VARBINARY, blockSlice.slice());

        BlockEncoding snappyEncoding = encoder.finish();
        assertTrue(compressedOutput.size() < blockSlice.size());

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

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

        RunLengthEncodedBlock expectedBlock = new RunLengthEncodedBlock(value, 11);

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1024);
        RunLengthBlockEncoding blockEncoding = new RunLengthBlockEncoding(new VariableWidthBlockEncoding(VARCHAR));
        blockEncoding.writeBlock(sliceOutput, expectedBlock);
        RunLengthEncodedBlock actualBlock = blockEncoding.readBlock(sliceOutput.slice().getInput());
        assertTrue(actualBlock.equalTo(0, expectedBlock, 0));
        BlockAssertions.assertBlockEquals(actualBlock, expectedBlock);
    }

    @Test
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.