mqliang commented on pull request #6710: URL: https://github.com/apache/incubator-pinot/pull/6710#issuecomment-806330983
> By "Id" do you mean strings? Why is that any more advantages than adding an enum? In fact, enum is better since we can declare all enums in one place and add whatever comments there to not remove an enum @mcvsubbu @Jackie-Jiang I think Jackie means to associate a sting with each enum ordinal. Use the pattern from Effective Java: ``` enum MyEnum { ENUM_1("A"), ENUM_2("B"); private String name; private static final Map<String,MyEnum> ENUM_MAP; MyEnum (String name) { this.name = name; } public String getName() { return this.name; } // Build an immutable map of String name to enum pairs. // Any Map impl can be used. static { Map<String,MyEnum> map = new ConcurrentHashMap<String, MyEnum>(); for (MyEnum instance : MyEnum.values()) { map.put(instance.getName().toLowerCase(),instance); } ENUM_MAP = Collections.unmodifiableMap(map); } public static MyEnum get (String name) { return ENUM_MAP.get(name.toLowerCase()); } } ``` This way, we are able to convert between enum ordinal and string. My current implementation use two helper map and two helper function outside of the enum definition (`TrailerKeyToMetadataKeyMap/MetadataKeyToTrailerKeyMap` and `trailerKeyToMetadataKey()/metaDataKeyToTrailerKey()`) to do the conversion. Use the pattern of Effective Java can put all helper funcitons/data structure inside the enum definition. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org