Skip to content

[arrow-select] perf: Replace ArrayData with direct Array construction in concat - #10377

Open
liamzwbao wants to merge 2 commits into
apache:mainfrom
liamzwbao:issue-9298-concat-array-data
Open

liamzwbao wants to merge 2 commits into
apache:mainfrom
liamzwbao:issue-9298-concat-array-data

Conversation

@liamzwbao

@liamzwbao liamzwbao commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

concat_run_arrays built its result via RunArray::try_new, which re-validates the run ends on every call even though they're already known-valid here: inputs are valid RunArrays, so the adjusted run ends are strictly increasing by construction.

What changes are included in this PR?

  • concat.rs: concat_run_arrays now builds the result directly via RunArray::new_unchecked(data_type, RunEndBuffer::new_unchecked(...), values), skipping try_new's revalidation.
  • concat.rs: adds an explicit overflow guard and rejects up front if the total doesn't fit in the run-end type R, before any R::Native arithmetic runs.
  • nullif.rs/take.rs changes are test-only cleanup.

Are these changes tested?

Yes — existing test suite, plus a new regression test for the overflow guard.

Benchmark results

cargo bench -p arrow --bench concatenate_kernel --features test_utils -- "concat run"

this branch vs main (RunArray<Int32Type>, n arrays concatenated):

Case main this PR Change
logical=32, physical=4, n=4 773.6 ns 563.4 ns −27%
logical=1024, physical=128, n=8 3.33 µs 2.68 µs −19%
logical=8192, physical=1024, n=10 25.2 µs 20.4 µs −19%

Are there any user-facing changes?

No.

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jul 19, 2026
@liamzwbao
liamzwbao force-pushed the issue-9298-concat-array-data branch from ed45969 to db1e53c Compare September 12, 2026 17:33
@liamzwbao liamzwbao changed the title [arrow-select] minor: Replace ArrayData with direct Array construction in concat [arrow-select] perf: Replace ArrayData with direct Array construction in concat Sep 12, 2026
Comment on lines +433 to +441
// Reject lengths that do not fit in `R` before any `R::Native` arithmetic can wrap.
let total_len: usize = run_arrays.iter().map(|r| r.len()).sum();
if R::Native::from_usize(total_len).is_none() {
return Err(ArrowError::ComputeError(format!(
"Concatenating RunArrays results in a logical length of {total_len}, \
which overflows the run-end type {}",
R::DATA_TYPE
)));
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary to fix the failure reproduced in the UT test_concat_run_array_length_overflows_run_end_type

@liamzwbao
liamzwbao force-pushed the issue-9298-concat-array-data branch from db1e53c to 3ce2087 Compare September 12, 2026 17:46
@liamzwbao
liamzwbao marked this pull request as ready for review September 12, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-select

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant