Skip to content

Commit 3d3a91c

Browse files
committed
Rely on List offset invariants in List take
Signed-off-by: Daniel King <dan@spiraldb.com>
1 parent 01cb491 commit 3d3a91c

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

  • vortex-array/src/arrays/list/compute

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use itertools::Itertools as _;
55
use vortex_buffer::BufferMut;
6+
use vortex_error::VortexExpect;
67
use vortex_error::VortexResult;
78
use vortex_error::vortex_ensure;
89
use vortex_error::vortex_err;
@@ -105,7 +106,7 @@ fn take_with_piecewise_elements<
105106

106107
for (&data_idx, is_valid) in indices.iter().zip_eq(validity_mask.iter()) {
107108
if !is_valid {
108-
new_offsets.push(new_offset_value::<OutputOffsetType>(current_offset)?);
109+
new_offsets.push(new_offset_value::<OutputOffsetType>(current_offset));
109110
element_starts.push(0);
110111
element_lengths.push(0);
111112
continue;
@@ -117,14 +118,12 @@ fn take_with_piecewise_elements<
117118
let stop = offsets[data_idx + 1];
118119
let start: usize = start.as_();
119120
let stop: usize = stop.as_();
120-
let length = stop
121-
.checked_sub(start)
122-
.ok_or_else(|| vortex_err!("List offsets are not monotonic at offset {stop}"))?;
121+
let length = stop - start;
123122

124123
current_offset = current_offset
125124
.checked_add(length)
126125
.ok_or_else(|| vortex_err!("List take output elements length overflow"))?;
127-
new_offsets.push(new_offset_value::<OutputOffsetType>(current_offset)?);
126+
new_offsets.push(new_offset_value::<OutputOffsetType>(current_offset));
128127
element_starts.push(start as u64);
129128
element_lengths.push(length as u64);
130129
}

0 commit comments

Comments
 (0)