[ 
https://issues.apache.org/jira/browse/METRON-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15301932#comment-15301932
 ] 

ASF GitHub Bot commented on METRON-186:
---------------------------------------

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

    https://github.com/apache/incubator-metron/pull/136#discussion_r64726176
  
    --- Diff: 
metron-platform/metron-parsers/src/main/java/org/apache/metron/parsers/bolt/ParserBolt.java
 ---
    @@ -61,18 +62,32 @@ public void prepare(Map stormConf, TopologyContext 
context, OutputCollector coll
         this.collector = collector;
         parser.init();
         writer.init();
    +    SensorParserConfig config = 
getConfigurations().getSensorParserConfig(sensorType);
    +    if(config != null) {
    +      config.init();
    +    }
       }
     
       @SuppressWarnings("unchecked")
       @Override
       public void execute(Tuple tuple) {
         byte[] originalMessage = tuple.getBinary(0);
    +    SensorParserConfig sensorParserConfig = 
configurations.getSensorParserConfig(sensorType);
         try {
           List<JSONObject> messages = parser.parse(originalMessage);
           for(JSONObject message: messages) {
             if (parser.validate(message)) {
               if (filter != null && filter.emitTuple(message)) {
                 message.put(Constants.SENSOR_TYPE, sensorType);
    +            List<MappingHandler> fieldMappings = sensorParserConfig == 
null?null:sensorParserConfig.getFieldMappings();
    --- End diff --
    
    If I'm interpreting correctly, 
org.apache.metron.common.configuration.SensorParserConfig won't vary with this 
implementation (i.e. not a user-provided impl). That said, I believe 
`sensorParserConfig.getFieldMappings()` should always return a non-null 
`List<MappingHandler>` (per the default init in that class -> `fieldMappings = 
new ArrayList<>()`)
    Maybe simplify line 82-84 to this?
    ```
    if(sensorParserConfig != null) {
      for(MappingHandler handler: sensorParserConfig.getFieldMappings()) {
    ...
      }
    }
    ```
    Also, might be worth a small test to see if line 85 handler null check can 
also go away.


> Create a fieldMapping functionality which allows for parsed fields to be 
> transformed
> ------------------------------------------------------------------------------------
>
>                 Key: METRON-186
>                 URL: https://issues.apache.org/jira/browse/METRON-186
>             Project: Metron
>          Issue Type: Improvement
>            Reporter: Casey Stella
>            Assignee: Casey Stella
>
> Currently the parsers take care of transforming raw data to the parsed JSON 
> representation.  Allow for a layer to be placed at a sensor level to 
> transform input fields from the parsed messages to create new fields.  For 
> instance, mapping IANA protocol numbers to a standardized textual 
> representation (i.e. 6 maps to TCP).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to