presto-main/src/main/java/io/prestosql/operator/aggregation/minmaxby/MinMaxByNStateSerializer.java/MinMaxByNStateSerializer/serialize
class MinMaxByNStateSerializer:    @Override
    public void serialize(MinMaxByNState state, BlockBuilder out)
    {
        TypedKeyValueHeap heap = state.getTypedKeyValueHeap();
        if (heap == null) {
            out.appendNull();
            return;
        }

        heap.serialize(out);
    }