Github user cestella commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/453#discussion_r100799069
  
    --- Diff: 
metron-platform/metron-writer/src/main/java/org/apache/metron/writer/bolt/BulkMessageWriterBolt.java
 ---
    @@ -74,7 +81,11 @@ public void prepare(Map stormConf, TopologyContext 
context, OutputCollector coll
         this.writerComponent = new BulkWriterComponent<>(collector);
         this.collector = collector;
         super.prepare(stormConf, context, collector);
    -    messageGetter = MessageGetters.valueOf(messageGetterStr);
    +    if 
(messageGetStrategyType.equals(MessageGetters.JSON_FROM_FIELD.name()) && 
messageGetField != null) {
    --- End diff --
    
    Why is this special case for JSON_FROM_FIELD required?  Is it because of 
the arg?  If so, it's probably better to adjust `MessageGetters` rather than 
doing it here.  I'd suggest making a factory rather than a strategy in this 
case for it:
    ```
    public enum MessageGetters {
    
      BYTES_FROM_POSITION(arg -> new BytesFromPosition(arg)),
      JSON_FROM_POSITION(arg -> new JSONFromPosition(arg)),
      JSON_FROM_FIELD(arg -> new JSONFromField(arg));
    
      Function<Object, MessageGetStrategy> messageGetStrategy;
    
      MessageGetters(Function<Object, MessageGetStrategy> messageGetStrategy) {
        this.messageGetStrategy = messageGetStrategy;
      }
    
      public MessageGetStrategy get(Object arg) {
        return messageGetStrategy.apply(arg);
      }
    }
    ```
    
    Then it becomes 
`MessageGetters.valueOf(messageGetStrategyType).get(messageGetField)`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to