presto-main/src/main/java/io/prestosql/operator/aggregation/state/DigestAndPercentileStateSerializer.java/DigestAndPercentileStateSerializer/serialize
class DigestAndPercentileStateSerializer:    @Override
    public void serialize(DigestAndPercentileState state, BlockBuilder out)
    {
        if (state.getDigest() == null) {
            out.appendNull();
        }
        else {
            Slice serialized = state.getDigest().serialize();

            SliceOutput output = Slices.allocate(SIZE_OF_DOUBLE + SIZE_OF_INT + serialized.length()).getOutput();
            output.appendDouble(state.getPercentile());
            output.appendInt(serialized.length());
            output.appendBytes(serialized);

            VARBINARY.writeSlice(out, output.slice());
        }
    }