Skip to content

[SPARK-56317][SQL] GetJsonObjectEvaluator should reuse output buffer#55134

Open
leixm wants to merge 1 commit intoapache:masterfrom
leixm:SPARK-56317
Open

[SPARK-56317][SQL] GetJsonObjectEvaluator should reuse output buffer#55134
leixm wants to merge 1 commit intoapache:masterfrom
leixm:SPARK-56317

Conversation

@leixm
Copy link
Copy Markdown
Contributor

@leixm leixm commented Apr 1, 2026

What changes were proposed in this pull request?

GetJsonObjectEvaluator should reuse output buffer.

Why are the changes needed?

Currently, GetJsonObjectEvaluator.evaluate() creates a new ByteArrayOutputStream on every invocation. Since the evaluator is reused across rows, this results in unnecessary object allocation and GC pressure. We can reuse the output buffer by promoting it to a class-level lazy val and calling reset() before each use, this is consistent with StructsToJsonEvaluator, which reuses a CharArrayWriter across rows.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing UTs.

Was this patch authored or co-authored using generative AI tooling?

No.

@leixm
Copy link
Copy Markdown
Contributor Author

leixm commented Apr 1, 2026

cc @LuciferYang @panbingkun , Can you help review?

@LuciferYang LuciferYang changed the title [SPARK-56317] GetJsonObjectEvaluator should reuse output buffer [SPARK-56317][SQL] GetJsonObjectEvaluator should reuse output buffer Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants