[ 
https://issues.apache.org/jira/browse/FLINK-41650?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated FLINK-41650:
-----------------------------------
    Labels: pull-request-available  (was: )

> Build JSON format VARIANT values from the JsonNode tree without printing it 
> to text
> -----------------------------------------------------------------------------------
>
>                 Key: FLINK-41650
>                 URL: https://issues.apache.org/jira/browse/FLINK-41650
>             Project: Flink
>          Issue Type: Improvement
>            Reporter: Pritish Thombare
>            Priority: Minor
>              Labels: pull-request-available
>
> When the json format reads a VARIANT column, both readers already hold the 
> value as a Jackson tree, but they print it back to text and parse that text 
> again:
>  - JsonToRowDataConverters: 
> BinaryVariantInternalBuilder.parseJson(jsonNode.toString(), false)
>  - JsonParserToRowDataConverters: 
> BinaryVariantInternalBuilder.parseJson(jp.readValueAsTree().toString(), false)
> The round trip costs time and allocations on every record.
> h3. Proposal
> Add BinaryVariantInternalBuilder.parseJson(JsonNode, boolean), which walks 
> the tree with JsonNode.traverse() and gives the same variant as 
> parseJson(node.toString(), boolean). Both readers call it. The stored bytes 
> stay the same.
> On a typical event with nested objects and arrays (JMH, JDK 21):
>  - JsonToRowDataConverters: 1879 ns -> 1073 ns, 5520 B -> 3656 B allocated
> JsonParserToRowDataConverters: 2949 ns -> 2110 ns, 18256 B -> 7936 B allocated
> h3. Out of scope
> The streaming reader could hand its JsonParser to the builder directly and 
> skip the tree too. That changes results: \{"a":1,"a":2} would fail on the 
> duplicate key instead of keeping the last value, and -11E+0 would be stored 
> as a double instead of an integer. It is left for a separate ticket.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to