ORC-2223 : [Java] RecordReaderImpl reads and parses each StripeFooter twice per stripe during scans #2717
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.54) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.54 · 494 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.371
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #2717"
general
weight: 0.35
cxzl25
(java): reuse stripe footer in RecordReaderImpl to avoid duplicate read
<!--
Thanks for sending a pull request! Here are some tips for you:
1. File a JIRA issue first and use it as a prefix of your PR title, e.g.,
ORC-001: Fix ABC.2. Use your PR title to summarize what this PR proposes instead of describing the problem.
3. Make PR title and description complete because these will be the permanent commit log.
4. If possible, provide a concise and reproducible example to reproduce the issue for a faster review.
5. If the PR is unfinished, use GitHub PR Draft feature.
-->
What changes were proposed in this pull request?
This PR eliminates a duplicate
StripeFooterread in the Java reader: each stripe's footer was being read and parsed twice per scan.RecordReaderImpl.beginReadStripe()already reads theOrcProto.StripeFooterfor the current stripe, butRecordReaderImpl.readStripe()then calledStripePlanner.parseStripe(stripe, fileIncluded), which read the same footer again internally.Changes:
1. Add an overloaded
StripePlanner.parseStripe(StripeInformation, boolean[], OrcProto.StripeFooter)that accepts a footer already read by the caller. The existing two-argumentparseStripeis kept as a thin wrapper that reads the footer itself, so other callers are unaffected.2.
RecordReaderImpl.readStripe()now passes the footer obtained inbeginReadStripe()to the new overload, removing oneDataReader.readStripeFootercall per stripe.3. Lowered read-percentage thresholds in
TestMinSeekSize,TestRowFilteringComplexTypesNulls, andTestRowFilteringIOSkipto reflect the genuinely reduced bytes read per stripe.Why are the changes needed?
Every stripe read during a scan performed a redundant footer read (plus protobuf re-parse) from the underlying
DataReader. On remote/object stores or for files with many stripes, this is a measurable and avoidable source of extra I/O and CPU that scales linearly with the number of stripes read. The fix removes the duplication without changing any read semantics: both reads previously fetched the identical footer bytes for the same stripe.How was this patch tested?
Added a new regression test
TestRecordReaderImpl.testNoDuplicateStripeFooterRead. It installs a Mockito spy on theDataReader(stubbingclone()to return the spy, sinceRecordReaderImplclones the supplied reader) and verifiesreadStripeFooteris invoked exactly once per stripe — covering both a plain scan and an SArg-filtered scan (a predicate that evaluates to YES_NO for every row group, sopickRowGroupsis exercised without skipping whole stripes).Also adjusted the read-percentage assertions in
TestMinSeekSize,TestRowFilteringComplexTypesNulls, andTestRowFilteringIOSkip: those tests assert lower bounds on bytes read, and the fix legitimately reduces bytes read, so thresholds were lowered accordingly (e.g. 5.9 -> 5.0, 0.06 -> 0.03) with comments explaining why.Run: cd java && ./mvnw test -pl core
Was this patch authored or co-authored using generative AI tooling?
Yes. co-authored-by: Claude (Anthropic)