Jackie-Jiang commented on code in PR #13897:
URL: https://github.com/apache/pinot/pull/13897#discussion_r1733576186


##########
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/metadata/ColumnMetadataImpl.java:
##########
@@ -264,39 +264,9 @@ public static ColumnMetadataImpl 
fromPropertiesConfiguration(String column, Prop
     // TODO: Use getProperty() for other properties as well to avoid the 
overhead of variable substitution
     String minString = (String) config.getProperty(Column.getKeyFor(column, 
Column.MIN_VALUE));
     String maxString = (String) config.getProperty(Column.getKeyFor(column, 
Column.MAX_VALUE));
-    if (minString != null && maxString != null) {
-      switch (storedType) {
-        case INT:
-          builder.setMinValue(Integer.valueOf(minString));
-          builder.setMaxValue(Integer.valueOf(maxString));
-          break;
-        case LONG:
-          builder.setMinValue(Long.valueOf(minString));
-          builder.setMaxValue(Long.valueOf(maxString));
-          break;
-        case FLOAT:
-          builder.setMinValue(Float.valueOf(minString));
-          builder.setMaxValue(Float.valueOf(maxString));
-          break;
-        case DOUBLE:
-          builder.setMinValue(Double.valueOf(minString));
-          builder.setMaxValue(Double.valueOf(maxString));
-          break;
-        case BIG_DECIMAL:
-          builder.setMinValue(new BigDecimal(minString));
-          builder.setMaxValue(new BigDecimal(maxString));
-          break;
-        case STRING:
-          
builder.setMinValue(CommonsConfigurationUtils.recoverSpecialCharacterInPropertyValue(minString));
-          
builder.setMaxValue(CommonsConfigurationUtils.recoverSpecialCharacterInPropertyValue(maxString));
-          break;
-        case BYTES:
-          builder.setMinValue(BytesUtils.toByteArray(minString));
-          builder.setMaxValue(BytesUtils.toByteArray(maxString));
-          break;
-        default:
-          throw new IllegalStateException("Unsupported data type: " + dataType 
+ " for column: " + column);
-      }
+    // Set min/max value if available
+    if (minString != null || maxString != null) {
+      builder.setColumnMinMaxValues(builder, storedType, column, minString, 
maxString);

Review Comment:
   IMO it is more readable this way:
   ```suggestion
       // Set min/max value if available
       if (minString != null) {
         builder.setMinValue(parseValue(storedType, column, minString));
       }
       if (maxString != null) {
         builder.setMaxValue(parseValue(storedType, column, maxString));
       }
   ```



-- 
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: commits-unsubscr...@pinot.apache.org

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