richardstartin commented on a change in pull request #7402:
URL: https://github.com/apache/pinot/pull/7402#discussion_r703771456
##########
File path:
pinot-common/src/main/java/org/apache/pinot/common/utils/PinotDataType.java
##########
@@ -776,30 +777,70 @@ public String toString(Object value) {
// Mapping Java class type to PinotDataType, for SV and MV value separately.
// OBJECT and OBJECT_ARRAY are default type for unknown Java types.
- private static final Map<Class<?>, PinotDataType> SINGLE_VALUE_TYPE_MAP =
new HashMap<Class<?>, PinotDataType>() {{
- put(Boolean.class, BOOLEAN);
- put(Byte.class, BYTE);
- put(Character.class, CHARACTER);
- put(Short.class, SHORT);
- put(Integer.class, INTEGER);
- put(Long.class, LONG);
- put(Float.class, FLOAT);
- put(Double.class, DOUBLE);
- put(Timestamp.class, TIMESTAMP);
- put(String.class, STRING);
- put(byte[].class, BYTES);
- }};
-
- private static final Map<Class<?>, PinotDataType> MULTI_VALUE_TYPE_MAP = new
HashMap<Class<?>, PinotDataType>() {{
- put(Byte.class, BYTE_ARRAY);
- put(Character.class, CHARACTER_ARRAY);
- put(Short.class, SHORT_ARRAY);
- put(Integer.class, INTEGER_ARRAY);
- put(Long.class, LONG_ARRAY);
- put(Float.class, FLOAT_ARRAY);
- put(Double.class, DOUBLE_ARRAY);
- put(String.class, STRING_ARRAY);
- }};
+ private static final Function<Class<?>, PinotDataType>
SINGLE_VALUE_TYPE_MAPPING = memoize(cls -> {
Review comment:
Java switch statements don't support class literals because classes are
discriminated by their `ClassLoader`. By all means, I can try what you suggest.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]