Skip to content

Commit 2ea44b6

Browse files
committed
Hoist take validity outside type dispatch
Signed-off-by: Daniel King <dan@spiraldb.com>
1 parent de4a71f commit 2ea44b6

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

vortex-array/src/arrays/decimal/compute/take.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ fn take_piecewise_sequence(
6363
let Some((starts, lengths)) = execute_unit_multiplier_index_arrays(indices, ctx)? else {
6464
return Ok(None);
6565
};
66+
let validity = array.validity()?.take(indices_ref)?;
6667
match_each_decimal_value_type!(array.values_type(), |D| {
6768
match_each_unsigned_integer_ptype!(starts.ptype(), |S| {
6869
match_each_unsigned_integer_ptype!(lengths.ptype(), |L| {
@@ -72,7 +73,6 @@ fn take_piecewise_sequence(
7273
array.buffer::<D>().as_slice(),
7374
indices_ref.len(),
7475
)?;
75-
let validity = array.validity()?.take(indices_ref)?;
7676

7777
// SAFETY: contiguous gather preserves the decimal dtype and value representation.
7878
Ok(Some(

vortex-array/src/arrays/list/compute/take.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ where
194194
validate_index_ranges(array.len(), starts, lengths, indices_ref.len())?;
195195
let total_elements =
196196
piecewise_list_elements_len(array.elements().len(), offsets, starts, lengths)?;
197+
let validity = array.validity()?.take(indices_ref)?;
197198

198199
match_smallest_offset_type!(total_elements, |OutputOffset| {
199200
let gathered = gather_piecewise_list::<S, L, Offset, OutputOffset>(
@@ -204,7 +205,6 @@ where
204205
indices_ref.len(),
205206
total_elements,
206207
)?;
207-
let validity = array.validity()?.take(indices_ref)?;
208208

209209
// SAFETY: output offsets are rebuilt from valid monotonic source offsets; output elements
210210
// are exactly the gathered child ranges referenced by those offsets; validity has one bit

vortex-array/src/arrays/primitive/compute/take/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ fn take_piecewise_sequence(
143143
let Some((starts, lengths)) = execute_unit_multiplier_index_arrays(indices, ctx)? else {
144144
return Ok(None);
145145
};
146+
let validity = array.validity()?.take(indices_ref)?;
146147
match_each_native_ptype!(array.ptype(), |T| {
147148
match_each_unsigned_integer_ptype!(starts.ptype(), |S| {
148149
match_each_unsigned_integer_ptype!(lengths.ptype(), |L| {
@@ -152,7 +153,6 @@ fn take_piecewise_sequence(
152153
lengths.as_slice::<L>(),
153154
indices_ref.len(),
154155
)?;
155-
let validity = array.validity()?.take(indices_ref)?;
156156
Ok(Some(PrimitiveArray::new(values, validity).into_array()))
157157
})
158158
})

0 commit comments

Comments
 (0)