You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2018/11/09 14:06:56 UTC

[GitHub] QiuMM commented on a change in pull request #6590: optimize input row parsers

QiuMM commented on a change in pull request #6590: optimize input row parsers
URL: https://github.com/apache/incubator-druid/pull/6590#discussion_r232263392
 
 

 ##########
 File path: core/src/main/java/org/apache/druid/data/input/impl/MapInputRowParser.java
 ##########
 @@ -36,20 +36,22 @@
 public class MapInputRowParser implements InputRowParser<Map<String, Object>>
 {
   private final ParseSpec parseSpec;
+  private final List<String> dimensions;
 
   @JsonCreator
   public MapInputRowParser(
       @JsonProperty("parseSpec") ParseSpec parseSpec
   )
   {
     this.parseSpec = parseSpec;
+    this.dimensions = parseSpec.getDimensionsSpec().getDimensionNames();
   }
 
   @Override
   public List<InputRow> parseBatch(Map<String, Object> theMap)
   {
-    final List<String> dimensions = parseSpec.getDimensionsSpec().hasCustomDimensions()
-                                    ? parseSpec.getDimensionsSpec().getDimensionNames()
+    final List<String> dimensions = !this.dimensions.isEmpty()
 
 Review comment:
   @clintropolis I think so, but am not sure where to place this shared method. Add a default method in interface InputRowParser like below?
   ```java
   default List<String> getDimensions(ParseSpec parseSpec, List<String> dimensions, Map<String, Object> row) 
     {
       final List<String> rv;
       if (!dimensions.isEmpty()) {
         rv = dimensions;
       } else {
         rv = Lists.newArrayList(
             Sets.difference(row.keySet(), parseSpec.getDimensionsSpec().getDimensionExclusions())
         );
       }
       return rv;
     }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

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