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



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/data/recordtransformer/PinotDataType.java
##########
@@ -632,4 +721,22 @@ public static PinotDataType getPinotDataType(FieldSpec 
fieldSpec) {
             "Unsupported data type: " + dataType + " in field: " + 
fieldSpec.getName());
     }
   }
+
+  public static PinotDataType getSpecificMapDataTypeFromMap(Map<Object, 
Object> map) {
+    Iterator<Object> iterator = map.values().iterator();
+    Object obj = iterator.next();
+    if (obj instanceof Integer) {
+      return PinotDataType.INTEGER_MAP;
+    } else if (obj instanceof Long) {
+      return PinotDataType.LONG_MAP;
+    } else if (obj instanceof Float) {
+      return PinotDataType.FLOAT_MAP;
+    } else if (obj instanceof Double) {
+      return PinotDataType.DOUBLE_MAP;
+    } else if (obj instanceof String) {
+      return PinotDataType.STRING_MAP;
+    } else {
+      throw new IllegalStateException(String.format("'%s' isn't supported in 
the hash map.", obj.getClass()));

Review comment:
       How about nested Map? How about single-entry map with multi-valued value 
(e.g. `Object[]`)?

##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/data/recordtransformer/DataTypeTransformer.java
##########
@@ -56,6 +56,7 @@
     MULTI_VALUE_TYPE_MAP.put(Float.class, PinotDataType.FLOAT_ARRAY);
     MULTI_VALUE_TYPE_MAP.put(Double.class, PinotDataType.DOUBLE_ARRAY);
     MULTI_VALUE_TYPE_MAP.put(String.class, PinotDataType.STRING_ARRAY);
+    MULTI_VALUE_TYPE_MAP.put(HashMap.class, PinotDataType.MAP);

Review comment:
       `HashMap` is not good enough, should use `instanceof Map` instead




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