You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/03/25 03:10:56 UTC

[GitHub] [incubator-pinot] mqliang edited a comment on pull request #6710: Add a trailer section to data table and measure data table serialization cost on server

mqliang edited a comment 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 string 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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org