presto-main/src/main/java/io/prestosql/operator/aggregation/histogram/HistogramStateFactory.java/HistogramStateFactory/createGroupedState
class HistogramStateFactory:    @Override
    public HistogramState createGroupedState()
    {
        if (mode == NEW) {
            return new GroupedHistogramState(keyType, expectedEntriesCount);
        }

        if (mode == LEGACY) {
            return new LegacyHistogramGroupState(keyType, expectedEntriesCount);
        }

        throw new PrestoException(FUNCTION_IMPLEMENTATION_ERROR, format("expected group enum type %s", mode));
    }