LuciferYang opened a new pull request, #56691:
URL: https://github.com/apache/spark/pull/56691

   ### What changes were proposed in this pull request?
   
   This PR reuses a single shared `JsonFactory` in the variant module instead 
of allocating a new one on every call. `Variant.escapeJson` and 
`VariantBuilder.parseJson` each created a `new JsonFactory()` per invocation; 
both now reference a `private static final` instance.
   
   ### Why are the changes needed?
   
   `JsonFactory` is thread-safe and designed to be reused. `escapeJson` runs 
once per string value and object key while serializing a variant, and 
`parseJson` runs once per input JSON value (e.g. per row in `parse_json`), so 
creating a fresh factory on each call adds avoidable allocation (including its 
symbol tables) on these hot paths. Sharing one instance removes that overhead.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Existing variant tests cover both the parsing and serialization paths. There 
is no behavior change: both factories use the default configuration and are 
never mutated, so a shared instance produces identical results.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   No.
   


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

Reply via email to