Package io.airlift.slice

Examples of io.airlift.slice.SliceOutput


            for (int i = 0; i < accumulators.size(); i++) {
                blocks[i] = accumulators.get(i).evaluateIntermediate();
                sizeEstimate += blocks[i].getDataSize().toBytes();
            }

            SliceOutput output = new DynamicSliceOutput(sizeEstimate);
            PagesSerde.writePages(output, new Page(blocks));
            BlockBuilder builder = new BlockBuilder(SINGLE_VARBINARY);
            builder.append(output.slice());
            return builder.build();
        }
View Full Code Here


                accumulators.get(i).evaluateIntermediate(groupId, builder);
                blocks[i] = builder.build();
                sizeEstimate += blocks[i].getDataSize().toBytes();
            }

            SliceOutput sliceOutput = new DynamicSliceOutput(sizeEstimate);
            PagesSerde.writePages(sliceOutput, new Page(blocks));
            output.append(sliceOutput.slice());
        }
View Full Code Here

            for (int i = 0; i < accumulators.size(); i++) {
                blocks[i] = accumulators.get(i).evaluateIntermediate();
                sizeEstimate += blocks[i].getSizeInBytes();
            }

            SliceOutput output = new DynamicSliceOutput(sizeEstimate);
            PagesSerde.writePages(blockEncodingSerde, output, new Page(blocks));
            BlockBuilder builder = VARCHAR.createBlockBuilder(new BlockBuilderStatus());
            builder.appendSlice(output.slice());
            return builder.build();
        }
View Full Code Here

                accumulators.get(i).evaluateIntermediate(groupId, builder);
                blocks[i] = builder.build();
                sizeEstimate += blocks[i].getSizeInBytes();
            }

            SliceOutput sliceOutput = new DynamicSliceOutput(sizeEstimate);
            PagesSerde.writePages(blockEncodingSerde, sliceOutput, new Page(blocks));
            output.appendSlice(sliceOutput.slice());
        }
View Full Code Here

    }

    @Override
    public void serialize(MaxByState state, BlockBuilder out)
    {
        SliceOutput sliceOutput = new DynamicSliceOutput((int) state.getEstimatedSize());

        int keyLength = 0;
        if (state.getKey() != null && !state.getKey().isNull(0)) {
            keyLength = state.getKey().getLength(0);
        }
        sliceOutput.writeInt(keyLength);

        int valueLength = 0;
        if (state.getValue() != null && !state.getValue().isNull(0)) {
            valueLength = state.getValue().getLength(0);
        }
        sliceOutput.writeInt(valueLength);

        if (state.getKey() != null && !state.getKey().isNull(0)) {
            appendTo(state.getKeyType(), sliceOutput, state.getKey());
        }
        if (state.getValue() != null && !state.getValue().isNull(0)) {
            appendTo(state.getValueType(), sliceOutput, state.getValue());
        }
        Slice slice = sliceOutput.slice();
        out.writeBytes(slice, 0, slice.length());
        out.closeEntry();
    }
View Full Code Here

{
    @Test
    public void testEmpty()
            throws Exception
    {
        SliceOutput expected = new DynamicSliceOutput(1)
                .appendByte(1// format tag
                .appendByte(12) // p
                .appendByte(0); // baseline

        for (int i = 0; i < 1 << (12 - 1); i++) {
            expected.appendByte(0);
        }

        // overflow bucket
        expected.appendByte(0xff)
                .appendByte(0xff);

        // overflow value
        expected.appendByte(0);

        assertSlicesEqual(makeHll(12).serialize(), expected.slice());
    }
View Full Code Here

    @Override
    public byte[] getSerializedData()
    {
        // Serialization format is (<key:int><min:double><max:double>)*
        SliceOutput output = Slices.allocate((SizeOf.SIZE_OF_INT + 2 * SizeOf.SIZE_OF_DOUBLE) * mins.size()).getOutput();
        for (int key : mins.keySet()) {
            output.appendInt(key);
            output.appendDouble(mins.get(key));
            output.appendDouble(maxs.get(key));
        }
        return output.slice().getBytes();
    }
View Full Code Here

            for (int i = 0; i < accumulators.size(); i++) {
                blocks[i] = accumulators.get(i).evaluateIntermediate();
                sizeEstimate += blocks[i].getDataSize().toBytes();
            }

            SliceOutput output = new DynamicSliceOutput(sizeEstimate);
            PagesSerde.writePages(output, new Page(blocks));
            BlockBuilder builder = new BlockBuilder(SINGLE_VARBINARY);
            builder.append(output.slice());
            return builder.build();
        }
View Full Code Here

                accumulators.get(i).evaluateIntermediate(groupId, builder);
                blocks[i] = builder.build();
                sizeEstimate += blocks[i].getDataSize().toBytes();
            }

            SliceOutput sliceOutput = new DynamicSliceOutput(sizeEstimate);
            PagesSerde.writePages(sliceOutput, new Page(blocks));
            output.append(sliceOutput.slice());
        }
View Full Code Here

TOP

Related Classes of io.airlift.slice.SliceOutput

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.