cgivre 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_r262853576
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/httpd/HttpdLogRecord.java
 ##########
 @@ -109,8 +117,36 @@ public void set(final String field, final Long value) {
       if (w != null) {
         LOG.trace("Parsed field: {}, as long: {}", field, value);
         w.writeBigInt(value);
+      } else {
+        LOG.warn("No 'long' writer found for field: {}", field);
       }
-      else {
+    }
+  }
+
+  /**
+   * This method is referenced and called via reflection. This is added as a 
parsing target for the parser. It will get
+   * called when the value of a log field is a timesstamp data type.
+   *
+   * @param field name of field
+   * @param value value of field
+   */
+  @SuppressWarnings("unused")
+  public void setTimestamp(final String field, final String value) {
+    if (value != null) {
+      //Convert the date string into a long
+      SimpleDateFormat dateFormatter = new SimpleDateFormat(this.timeFormat);
+      long ts = 0;
+      try {
+        Date d = dateFormatter.parse(value);
+        ts = d.getTime();
+      } catch (Exception e) {
+
+      }
+      final TimeStampWriter tw = times.get(field);
+      if (tw != null) {
+        LOG.trace("Parsed field: {}, as time: {}", field, value);
+        tw.writeTimeStamp(ts);
+      } else {
         LOG.warn("No 'long' writer found for field: {}", field);
 
 Review comment:
   Yes... Fixed.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to