presto-main/src/main/java/io/prestosql/operator/aggregation/TypedKeyValueHeap.java/TypedKeyValueHeap/serialize
class TypedKeyValueHeap:    public void serialize(BlockBuilder out)
    {
        BlockBuilder blockBuilder = out.beginBlockEntry();
        BIGINT.writeLong(blockBuilder, getCapacity());

        BlockBuilder keyElements = blockBuilder.beginBlockEntry();
        for (int i = 0; i < positionCount; i++) {
            keyType.appendTo(keyBlockBuilder, heapIndex[i], keyElements);
        }
        blockBuilder.closeEntry();

        BlockBuilder valueElements = blockBuilder.beginBlockEntry();
        for (int i = 0; i < positionCount; i++) {
            valueType.appendTo(valueBlockBuilder, heapIndex[i], valueElements);
        }
        blockBuilder.closeEntry();

        out.closeEntry();
    }