buptljy commented on a change in pull request #10107: [FLINK-14608]
[flink-json] Avoid using Java Streams in JsonRowDeserializationSchema
URL: https://github.com/apache/flink/pull/10107#discussion_r343476683
##########
File path:
flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowDeserializationSchema.java
##########
@@ -429,13 +428,21 @@ private Object convertField(
}
}
- private DeserializationRuntimeConverter
assembleArrayConverter(DeserializationRuntimeConverter elementConverter) {
+ private DeserializationRuntimeConverter assembleArrayConverter(
+ TypeInformation<?> elementType,
+ DeserializationRuntimeConverter elementConverter) {
+
+ final Class<?> elementClass = elementType.getTypeClass();
+
return (mapper, jsonNode) -> {
- ArrayNode node = (ArrayNode) jsonNode;
+ final ArrayNode node = (ArrayNode) jsonNode;
+ final Object[] array = (Object[])
Array.newInstance(elementClass, node.size());
Review comment:
`new Object[node.size()]` and `(Object[]) Array.newInstance(elementClass,
node.size())` are a bit different though it may not affect the result here
because we have `elementConverter` to care about the element type. I'm just
trying to make the expression's semantics more precise here :).
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services