GH-50994: [C++][Compute] Implement casting from ListView to List with zero-copy fast-path #50976
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 · 319 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.345
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #50976"
general
weight: 0.35
Reranko05
Rationale for this change
This PR implements missing type-casting compute kernels to convert
ListViewTypeandLargeListViewTypearrays to standardListTypeandLargeListTypearrays.Previously, these casts routed to
CastList, which ignored the sizes buffer and read offsets out-of-bounds, resulting in corrupted output arrays. This PR introduces a dedicatedCastListViewfunctor to perform correct conversions.What changes are included in this PR?
To maximize performance and optimize memory layouts, a dual-execution path was implemented in the
CastListViewexecution functor insidescalar_cast_nested.cc:1. Contiguous Zero-Copy Fast-Path: Triggered when the input list-view elements are contiguous and adjacent (i.e.
offsets[i] + sizes[i] == offsets[i+1]). It avoids copying the child values array entirely, allocating the new output offset buffer, shifting offsets relative to the start, and slicing the child array directly to preserve zero-copy pointer semantics.2. Non-Contiguous Fallback Path: Triggered for gapped, overlapping, or out-of-order layouts. It dynamically tracks target offsets, builds integer index mappings using an
Int64Builder, and invokes Arrow's internaltakecompute kernel to reconstruct a new contiguous child values array.3. Kernel Registration: Formally wired into Arrow's casting system for standard and large variants of both nested types, replacing the incorrect routing.
Are these changes tested?
Yes, added comprehensive unit test suites in
scalar_cast_test.ccpassing all cases. Tests explicitly cover:Contiguous Arrays: Validated zero-copy memory behavior programmatically by ensuring the source and destination child buffers share the exact same physical memory address.
Gapped & Overlapping Arrays: Verified correct offset tracking and reconstruction when offsets intersect or contain unused slots.
Null Propagation: Checked that null validity maps propagate correctly at both the parent and child levels.
Generic/Nested Types: Validated casting on non-primitive data types (e.g. utf8 strings) and recursive child type promotions (e.g.,
ListView<int16>toList<int32>).Boundary Slices: Verified that taking slices of non-contiguous arrays computes correct offsets and avoids out-of-bound errors.
Are there any user-facing changes?
No public API contracts were broken. This adds correct, declarative casting support natively to the existing internal compute framework.
GitHub Issue: #50994