← Back to Pull requests

Optimize byte-array dictionary gathering in arrow-row #12113

Closed
unknown closed this pull request without merging on Nov 08, 2026 04:39 UTC
View on GitHub
unknown unknown commented on Nov 07, 2026 06:53 UTC
Author

Which issue does this PR close?

Closes #12053.

Rationale for this change

The sparse-dictionary encoding path gathers one dictionary value per input row before encoding. The current gather performs a dynamic MutableArrayData extension for every key, which adds overhead for common string and binary dictionaries.

What changes are included in this PR?

Add typed gather implementations for Utf8, LargeUtf8, Binary, and LargeBinary dictionary values. These build the offsets, value buffer, and validity bitmap directly.

Other value types continue to use the generic MutableArrayData implementation. Offset growth is checked so that overflow continues to reach the existing fallback. The dictionary-gather thresholds are unchanged.

Are these changes tested?

I’ve simplified test_gather_dictionary_byte_values to use StringArray, since the string and binary variants share the same gather implementation. The test still covers sliced keys, null keys, and keys that reference null dictionary values.

All 110 arrow-row library tests pass. Workspace tests, workspace Clippy checks, formatting, and spelling checks also pass.

Performance was measured using the existing prepared 8,192-row string-dictionary benchmark on an Intel Xeon E5-2673 v4, Linux x86_64, with Rust 1.99.1. This benchmark cycles through contiguous key chunks.

Two paired Criterion runs used 50 samples, a one-second warmup, and a three-second measurement period. Execution order was reversed for the second pair. The table reports the average of the two runs’ mean estimates.

| Dictionary values | Before | After | Change in mean time |
| ---: | ---: | ---: | ---: |
| 10,000 | 170.3 µs | 174.5 µs | +2.5% |
| 32,768 | 310.8 µs | 242.0 µs | -22.1% |
| 100,000 | 318.5 µs | 242.9 µs | -23.7% |
| 1,000,000 | 309.4 µs | 244.9 µs | -20.8% |
| 4,000,000 | 312.4 µs | 240.1 µs | -23.1% |

The 10,000-value control does not enter the dictionary-gather path and averaged 2.5% slower in these measurements. Individual runs varied by several percent.

The additional dictionary sizes were used through a separate local benchmark patch; they are not included in this implementation diff.

Are there any significant user-facing changes?

No public API or intended result changes.

AI assistance: AI tools assisted with implementation, tests, independent review, and validation. I reviewed the code, tests, and description before submission.

Diff: 301 lines (+225 / -76) across 3 files Reviewer: JonSnow1807 Review duration: 1305m
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 301 lines diff across 3 files
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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.342
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #12113"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 40.1% (MEDIUM) · Higher = larger blast radius
40.1%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15.8% · Safe to merge
15.8%