Jackie-Jiang commented on a change in pull request #5653:
URL: https://github.com/apache/incubator-pinot/pull/5653#discussion_r449912034



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/indexsegment/mutable/MutableSegmentImpl.java
##########
@@ -366,12 +368,68 @@ public SegmentPartitionConfig getSegmentPartitionConfig() 
{
     }
   }
 
+  /**
+   * Get min time from the segment, based on the time column, only used by 
Kafka HLC.
+   */
+  @Deprecated
   public long getMinTime() {
-    return _minTime;
+    Long minTime = extractTimeValue(getMinVal(_timeColumnName));
+    if (minTime != null) {
+      return minTime;
+    }
+    return Long.MAX_VALUE;
   }
 
+  /**
+   * Get max time from the segment, based on the time column, only used by 
Kafka HLC.
+   */
+  @Deprecated
   public long getMaxTime() {
-    return _maxTime;
+    Long maxTime = extractTimeValue(getMaxVal(_timeColumnName));
+    if (maxTime != null) {
+      return maxTime;
+    }
+    return Long.MIN_VALUE;
+  }
+
+  private Long extractTimeValue(Comparable time) {
+    if (time != null) {
+      if (time instanceof Number) {
+        return ((Number) time).longValue();
+      } else {
+        String stringValue = time.toString();
+        if (StringUtils.isNumeric(stringValue)) {

Review comment:
       Is numeric is not good enough, recommend put try-catch over 
`Long.parseLong(stringValue)`

##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/indexsegment/mutable/MutableSegmentImpl.java
##########
@@ -227,6 +226,9 @@ public long getLatestIngestionTimestamp() {
         if (isFixedWidthColumn) {
           forwardIndexColumnSize = dataType.size();
         }
+        // Init min/max value map to avoid potential thread safety issue 
(expanding hashMap while reading).
+        _minValueMap.put(fieldSpec.getName(), null);
+        _maxValueMap.put(fieldSpec.getName(), null);

Review comment:
       ```suggestion
           _minValueMap.put(column, null);
           _maxValueMap.put(column, null);
   ```




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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to