ihuzenko commented on a change in pull request #1635: DRILL-7021: HTTPD Throws 
NPE and Doesn't Recognize Timeformat
URL: https://github.com/apache/drill/pull/1635#discussion_r266418146
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/httpd/HttpdLogRecord.java
 ##########
 @@ -103,19 +114,47 @@ public void set(final String field, final String value) {
    * @param value value of field
    */
   @SuppressWarnings("unused")
-  public void set(final String field, final Long value) {
+  public void set(String field, Long value) {
 
 Review comment:
   All this ```set*``` methods are pretty the same and all the duplication can 
be minimized using some generics & lambda tricks. Check example code below 
(note: some javadocs omitted for clarity, and just one ```setWildcard``` is 
shown for example): 
   ```java
     public void set(final String field, final String value) {
       setInternal(field, "string", value, strings::get, this::writeString);
     }
   
     public void set(final String field, final Long value) {
       setInternal(field, "long", value, longs::get, BigIntWriter::writeBigInt);
     }
   
     public void set(final String field, final Double value) {
       setInternal(field, "double", value, doubles::get, 
Float8Writer::writeFloat8);
     }
   
     public void setWildcard(final String field, final Double value) {
       setInternal(field, "double wildcard", value, this::getWildcardWriter, 
(w, v) -> w.float8(cleanExtensions.get(field)).writeFloat8(v));
     }
   
     /**
      * Generic method for passing parsed value into concrete
      * vector writer
      *
      * @param field         field name serves as input for getWriterFunc
      * @param type          value type used for logging only
      * @param value         value to set using writer
      * @param getWriterFunc func for getting field's writer
      * @param writeFunc     func for setting value using concrete writer
      * @param <V>           type of value
      * @param <W>           type of writer
      */
     private static <V, W> void setInternal(String field, String type, V value, 
Function<String, W> getWriterFunc, BiConsumer<W, V> writeFunc) {
       if (value != null) {
         final W writer = getWriterFunc.apply(field);
         if (writer != null) {
           LOG.trace("Parsed field: {}, as {}: {}", field, type, value);
           writeFunc.accept(writer, value);
         } else {
           LOG.warn("No '{}' writer found for field: {}", type, field);
         }
       }
     }
   ``` 
    
    

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to