codope commented on a change in pull request #5102:
URL: https://github.com/apache/hudi/pull/5102#discussion_r832868782



##########
File path: 
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieColumnRangeMetadata.java
##########
@@ -18,41 +18,58 @@
 
 package org.apache.hudi.common.model;
 
+import javax.annotation.Nullable;
 import java.io.Serializable;
-import java.util.Arrays;
 import java.util.Comparator;
 import java.util.Objects;
 import java.util.function.BiFunction;
+import java.util.stream.Stream;
 
 /**
- * Hoodie Range metadata.
+ * Hoodie metadata for the column range of data stored in columnar format 
(like Parquet)
+ *
+ * NOTE: {@link Comparable} is used as raw-type so that we can handle 
polymorphism, where
+ *        caller apriori is not aware of the type {@link 
HoodieColumnRangeMetadata} is
+ *        associated with
  */
-public class HoodieColumnRangeMetadata<T> implements Serializable {
+@SuppressWarnings("rawtype")
+public class HoodieColumnRangeMetadata<T extends Comparable> implements 
Serializable {
   private final String filePath;
   private final String columnName;
+  @Nullable
   private final T minValue;
+  @Nullable
   private final T maxValue;
   private final long nullCount;
   private final long valueCount;
   private final long totalSize;
   private final long totalUncompressedSize;
 
   public static final BiFunction<HoodieColumnRangeMetadata<Comparable>, 
HoodieColumnRangeMetadata<Comparable>, HoodieColumnRangeMetadata<Comparable>> 
COLUMN_RANGE_MERGE_FUNCTION =
-      (oldColumnRange, newColumnRange) -> new HoodieColumnRangeMetadata<>(
+      (oldColumnRange, newColumnRange) -> new 
HoodieColumnRangeMetadata<Comparable>(
           newColumnRange.getFilePath(),
           newColumnRange.getColumnName(),
-          (Comparable) Arrays.asList(oldColumnRange.getMinValue(), 
newColumnRange.getMinValue())
-              
.stream().filter(Objects::nonNull).min(Comparator.naturalOrder()).orElse(null),
-          (Comparable) Arrays.asList(oldColumnRange.getMinValue(), 
newColumnRange.getMinValue())
-              
.stream().filter(Objects::nonNull).max(Comparator.naturalOrder()).orElse(null),
+          (Comparable) Stream.of(oldColumnRange.getMinValue(), 
newColumnRange.getMinValue())

Review comment:
       Good catch! We should replace `Arrays.asList` by `Stream` if there are 
other such places.




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to