Skip to content

Commit e31db3e

Browse files
committed
Rely on PiecewiseSequence validation in VarBin takes
Signed-off-by: Daniel King <dan@spiraldb.com>
1 parent c654de4 commit e31db3e

2 files changed

Lines changed: 13 additions & 25 deletions

File tree

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

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ use vortex_buffer::BufferMut;
77
use vortex_buffer::ByteBufferMut;
88
use vortex_error::VortexExpect;
99
use vortex_error::VortexResult;
10-
use vortex_error::vortex_bail;
1110
use vortex_error::vortex_ensure;
1211
use vortex_error::vortex_err;
1312
use vortex_error::vortex_panic;
1413
use vortex_mask::Mask;
1514

1615
use crate::ArrayRef;
17-
use crate::Canonical;
1816
use crate::Columnar;
1917
use crate::IntoArray;
2018
use crate::array::ArrayView;
@@ -148,7 +146,7 @@ fn take_contiguous_ranges(
148146

149147
let result = match lengths {
150148
Columnar::Constant(lengths) => {
151-
let length = constant_unsigned_usize(&lengths)?;
149+
let length = constant_unsigned_usize(&lengths);
152150
gather_slices_constant_dispatch(
153151
&starts,
154152
length,
@@ -158,19 +156,16 @@ fn take_contiguous_ranges(
158156
out_offset_ptype,
159157
)?
160158
}
161-
Columnar::Canonical(Canonical::Primitive(lengths)) => gather_slices_dispatch(
162-
&starts,
163-
&lengths,
164-
&offsets,
165-
data,
166-
output_len,
167-
out_offset_ptype,
168-
)?,
169159
Columnar::Canonical(lengths) => {
170-
vortex_bail!(
171-
"PiecewiseSequenceArray lengths must be primitive or constant, got {}",
172-
lengths.dtype()
173-
)
160+
let lengths = lengths.into_primitive();
161+
gather_slices_dispatch(
162+
&starts,
163+
&lengths,
164+
&offsets,
165+
data,
166+
output_len,
167+
out_offset_ptype,
168+
)?
174169
}
175170
};
176171

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ use num_traits::AsPrimitive;
99
use vortex_buffer::Buffer;
1010
use vortex_buffer::BufferMut;
1111
use vortex_error::VortexResult;
12-
use vortex_error::vortex_bail;
1312
use vortex_error::vortex_ensure;
1413
use vortex_error::vortex_err;
1514
use vortex_mask::AllOr;
1615
use vortex_mask::Mask;
1716

1817
use crate::ArrayRef;
19-
use crate::Canonical;
2018
use crate::Columnar;
2119
use crate::IntoArray;
2220
use crate::array::ArrayView;
@@ -88,7 +86,7 @@ fn take_contiguous_ranges(
8886
let output_len = indices_ref.len();
8987
let views = match lengths {
9088
Columnar::Constant(lengths) => {
91-
let length = constant_unsigned_usize(&lengths)?;
89+
let length = constant_unsigned_usize(&lengths);
9290
match_each_unsigned_integer_ptype!(starts.ptype(), |S| {
9391
gather_view_slices_constant_length(
9492
source,
@@ -98,7 +96,8 @@ fn take_contiguous_ranges(
9896
)?
9997
})
10098
}
101-
Columnar::Canonical(Canonical::Primitive(lengths)) => {
99+
Columnar::Canonical(lengths) => {
100+
let lengths = lengths.into_primitive();
102101
match_each_unsigned_integer_ptype!(starts.ptype(), |S| {
103102
match_each_unsigned_integer_ptype!(lengths.ptype(), |L| {
104103
gather_view_slices(
@@ -110,12 +109,6 @@ fn take_contiguous_ranges(
110109
})
111110
})
112111
}
113-
Columnar::Canonical(lengths) => {
114-
vortex_bail!(
115-
"PiecewiseSequenceArray lengths must be primitive or constant, got {}",
116-
lengths.dtype()
117-
)
118-
}
119112
};
120113
let validity = array.validity()?.take(indices_ref)?;
121114

0 commit comments

Comments
 (0)