Skip to content

Commit ad5d6ff

Browse files
committed
Rename contiguous range take helpers
Signed-off-by: Daniel King <dan@spiraldb.com>
1 parent 7c4811b commit ad5d6ff

5 files changed

Lines changed: 66 additions & 74 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl TakeExecute for Bool {
3838
ctx: &mut ExecutionCtx,
3939
) -> VortexResult<Option<ArrayRef>> {
4040
if let Some(piecewise_indices) = indices.as_opt::<PiecewiseSequence>()
41-
&& let Some(taken) = take_piecewise_sequence(array, piecewise_indices, indices, ctx)?
41+
&& let Some(taken) = take_contiguous_ranges(array, piecewise_indices, indices, ctx)?
4242
{
4343
return Ok(Some(taken));
4444
}
@@ -69,7 +69,7 @@ impl TakeExecute for Bool {
6969
}
7070
}
7171

72-
fn take_piecewise_sequence(
72+
fn take_contiguous_ranges(
7373
array: ArrayView<'_, Bool>,
7474
indices: ArrayView<'_, PiecewiseSequence>,
7575
indices_ref: &ArrayRef,
@@ -83,7 +83,7 @@ fn take_piecewise_sequence(
8383
let buffer = match &lengths {
8484
UnitMultiplierLengths::Constant(length) => {
8585
match_each_unsigned_integer_ptype!(starts.ptype(), |S| {
86-
take_piecewise_bits_constant_length(
86+
take_bit_slices_constant_length(
8787
&source,
8888
starts.as_slice::<S>(),
8989
*length,
@@ -94,7 +94,7 @@ fn take_piecewise_sequence(
9494
UnitMultiplierLengths::Array(lengths) => {
9595
match_each_unsigned_integer_ptype!(starts.ptype(), |S| {
9696
match_each_unsigned_integer_ptype!(lengths.ptype(), |L| {
97-
take_piecewise_bits(
97+
take_bit_slices(
9898
&source,
9999
starts.as_slice::<S>(),
100100
lengths.as_slice::<L>(),
@@ -137,7 +137,7 @@ fn take_bool_impl<I: AsPrimitive<usize>>(bools: BitBufferView<'_>, indices: &[I]
137137
})
138138
}
139139

140-
fn take_piecewise_bits_constant_length<S>(
140+
fn take_bit_slices_constant_length<S>(
141141
source: &BitBuffer,
142142
starts: &[S],
143143
length: usize,
@@ -157,7 +157,7 @@ where
157157
Ok(values.freeze())
158158
}
159159

160-
fn take_piecewise_bits<S, L>(
160+
fn take_bit_slices<S, L>(
161161
source: &BitBuffer,
162162
starts: &[S],
163163
lengths: &[L],

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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl TakeExecute for Decimal {
3434
ctx: &mut ExecutionCtx,
3535
) -> VortexResult<Option<ArrayRef>> {
3636
if let Some(piecewise_indices) = indices.as_opt::<PiecewiseSequence>()
37-
&& let Some(taken) = take_piecewise_sequence(array, piecewise_indices, indices, ctx)?
37+
&& let Some(taken) = take_contiguous_ranges(array, piecewise_indices, indices, ctx)?
3838
{
3939
return Ok(Some(taken));
4040
}
@@ -58,7 +58,7 @@ impl TakeExecute for Decimal {
5858
}
5959
}
6060

61-
fn take_piecewise_sequence(
61+
fn take_contiguous_ranges(
6262
array: ArrayView<'_, Decimal>,
6363
indices: ArrayView<'_, PiecewiseSequence>,
6464
indices_ref: &ArrayRef,
@@ -71,30 +71,28 @@ fn take_piecewise_sequence(
7171
let output_len = indices_ref.len();
7272
let taken = match lengths {
7373
UnitMultiplierLengths::Constant(length) => {
74-
take_piecewise_sequence_constant_length(array, &starts, length, validity, output_len)?
74+
take_slices_constant_length(array, &starts, length, validity, output_len)?
7575
}
7676
UnitMultiplierLengths::Array(lengths) => {
77-
take_piecewise_sequence_lengths(array, &starts, &lengths, validity, output_len)?
77+
take_slices(array, &starts, &lengths, validity, output_len)?
7878
}
7979
};
8080
Ok(Some(taken))
8181
}
8282

83-
fn take_piecewise_sequence_constant_length(
83+
fn take_slices_constant_length(
8484
array: ArrayView<'_, Decimal>,
8585
starts: &PrimitiveArray,
8686
length: usize,
8787
validity: Validity,
8888
output_len: usize,
8989
) -> VortexResult<ArrayRef> {
9090
match_each_decimal_value_type!(array.values_type(), |D| {
91-
take_piecewise_sequence_constant_length_typed::<D>(
92-
array, starts, length, validity, output_len,
93-
)
91+
take_slices_constant_length_typed::<D>(array, starts, length, validity, output_len)
9492
})
9593
}
9694

97-
fn take_piecewise_sequence_constant_length_typed<D>(
95+
fn take_slices_constant_length_typed<D>(
9896
array: ArrayView<'_, Decimal>,
9997
starts: &PrimitiveArray,
10098
length: usize,
@@ -105,7 +103,7 @@ where
105103
D: NativeDecimalType,
106104
{
107105
match_each_unsigned_integer_ptype!(starts.ptype(), |S| {
108-
let values = take_piecewise_constant_length_to_buffer::<S, D>(
106+
let values = take_slices_constant_length_to_buffer::<S, D>(
109107
starts.as_slice::<S>(),
110108
length,
111109
array.buffer::<D>().as_slice(),
@@ -120,19 +118,19 @@ where
120118
})
121119
}
122120

123-
fn take_piecewise_sequence_lengths(
121+
fn take_slices(
124122
array: ArrayView<'_, Decimal>,
125123
starts: &PrimitiveArray,
126124
lengths: &PrimitiveArray,
127125
validity: Validity,
128126
output_len: usize,
129127
) -> VortexResult<ArrayRef> {
130128
match_each_decimal_value_type!(array.values_type(), |D| {
131-
take_piecewise_sequence_lengths_typed::<D>(array, starts, lengths, validity, output_len)
129+
take_slices_typed::<D>(array, starts, lengths, validity, output_len)
132130
})
133131
}
134132

135-
fn take_piecewise_sequence_lengths_typed<D>(
133+
fn take_slices_typed<D>(
136134
array: ArrayView<'_, Decimal>,
137135
starts: &PrimitiveArray,
138136
lengths: &PrimitiveArray,
@@ -143,13 +141,11 @@ where
143141
D: NativeDecimalType,
144142
{
145143
match_each_unsigned_integer_ptype!(starts.ptype(), |S| {
146-
take_piecewise_sequence_lengths_start_typed::<D, S>(
147-
array, starts, lengths, validity, output_len,
148-
)
144+
take_slices_start_typed::<D, S>(array, starts, lengths, validity, output_len)
149145
})
150146
}
151147

152-
fn take_piecewise_sequence_lengths_start_typed<D, S>(
148+
fn take_slices_start_typed<D, S>(
153149
array: ArrayView<'_, Decimal>,
154150
starts: &PrimitiveArray,
155151
lengths: &PrimitiveArray,
@@ -161,7 +157,7 @@ where
161157
S: UnsignedPType,
162158
{
163159
match_each_unsigned_integer_ptype!(lengths.ptype(), |L| {
164-
let values = take_piecewise_to_buffer::<S, L, D>(
160+
let values = take_slices_to_buffer::<S, L, D>(
165161
starts.as_slice::<S>(),
166162
lengths.as_slice::<L>(),
167163
array.buffer::<D>().as_slice(),
@@ -180,7 +176,7 @@ fn take_to_buffer<I: IntegerPType, T: NativeDecimalType>(indices: &[I], values:
180176
indices.iter().map(|idx| values[idx.as_()]).collect()
181177
}
182178

183-
fn take_piecewise_constant_length_to_buffer<S, T>(
179+
fn take_slices_constant_length_to_buffer<S, T>(
184180
starts: &[S],
185181
length: usize,
186182
values: &[T],
@@ -201,7 +197,7 @@ where
201197
Ok(result.freeze())
202198
}
203199

204-
fn take_piecewise_to_buffer<S, L, T>(
200+
fn take_slices_to_buffer<S, L, T>(
205201
starts: &[S],
206202
lengths: &[L],
207203
values: &[T],

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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl TakeExecute for Primitive {
8989
ctx: &mut ExecutionCtx,
9090
) -> VortexResult<Option<ArrayRef>> {
9191
if let Some(piecewise_indices) = indices.as_opt::<PiecewiseSequence>()
92-
&& let Some(taken) = take_piecewise_sequence(array, piecewise_indices, indices, ctx)?
92+
&& let Some(taken) = take_contiguous_ranges(array, piecewise_indices, indices, ctx)?
9393
{
9494
return Ok(Some(taken));
9595
}
@@ -138,7 +138,7 @@ impl TakeExecute for Primitive {
138138
}
139139
}
140140

141-
fn take_piecewise_sequence(
141+
fn take_contiguous_ranges(
142142
array: ArrayView<'_, Primitive>,
143143
indices: ArrayView<'_, PiecewiseSequence>,
144144
indices_ref: &ArrayRef,
@@ -151,10 +151,10 @@ fn take_piecewise_sequence(
151151
let output_len = indices_ref.len();
152152
let taken = match lengths {
153153
UnitMultiplierLengths::Constant(length) => {
154-
take_piecewise_sequence_constant_length(array, &starts, length, validity, output_len)?
154+
take_slices_constant_length(array, &starts, length, validity, output_len)?
155155
}
156156
UnitMultiplierLengths::Array(lengths) => {
157-
take_piecewise_sequence_lengths(array, &starts, &lengths, validity, output_len)?
157+
take_slices(array, &starts, &lengths, validity, output_len)?
158158
}
159159
};
160160
Ok(Some(taken))
@@ -181,19 +181,19 @@ fn take_primitive_scalar<T: Copy, I: IntegerPType>(buffer: &[T], indices: &[I])
181181
result.freeze()
182182
}
183183

184-
fn take_piecewise_sequence_lengths(
184+
fn take_slices(
185185
array: ArrayView<'_, Primitive>,
186186
starts: &PrimitiveArray,
187187
lengths: &PrimitiveArray,
188188
validity: Validity,
189189
output_len: usize,
190190
) -> VortexResult<ArrayRef> {
191191
match_each_native_ptype!(array.ptype(), |T| {
192-
take_piecewise_sequence_lengths_typed::<T>(array, starts, lengths, validity, output_len)
192+
take_slices_typed::<T>(array, starts, lengths, validity, output_len)
193193
})
194194
}
195195

196-
fn take_piecewise_sequence_lengths_typed<T>(
196+
fn take_slices_typed<T>(
197197
array: ArrayView<'_, Primitive>,
198198
starts: &PrimitiveArray,
199199
lengths: &PrimitiveArray,
@@ -204,13 +204,11 @@ where
204204
T: NativePType,
205205
{
206206
match_each_unsigned_integer_ptype!(starts.ptype(), |S| {
207-
take_piecewise_sequence_lengths_start_typed::<T, S>(
208-
array, starts, lengths, validity, output_len,
209-
)
207+
take_slices_start_typed::<T, S>(array, starts, lengths, validity, output_len)
210208
})
211209
}
212210

213-
fn take_piecewise_sequence_lengths_start_typed<T, S>(
211+
fn take_slices_start_typed<T, S>(
214212
array: ArrayView<'_, Primitive>,
215213
starts: &PrimitiveArray,
216214
lengths: &PrimitiveArray,
@@ -222,7 +220,7 @@ where
222220
S: UnsignedPType,
223221
{
224222
match_each_unsigned_integer_ptype!(lengths.ptype(), |L| {
225-
let values = primitive_piecewise_values::<T, S, L>(
223+
let values = take_slices_to_buffer::<T, S, L>(
226224
array.as_slice::<T>(),
227225
starts.as_slice::<S>(),
228226
lengths.as_slice::<L>(),
@@ -232,7 +230,7 @@ where
232230
})
233231
}
234232

235-
fn primitive_piecewise_values<T, S, L>(
233+
fn take_slices_to_buffer<T, S, L>(
236234
source: &[T],
237235
starts: &[S],
238236
lengths: &[L],
@@ -255,21 +253,19 @@ where
255253
Ok(values.freeze())
256254
}
257255

258-
fn take_piecewise_sequence_constant_length(
256+
fn take_slices_constant_length(
259257
array: ArrayView<'_, Primitive>,
260258
starts: &PrimitiveArray,
261259
length: usize,
262260
validity: Validity,
263261
output_len: usize,
264262
) -> VortexResult<ArrayRef> {
265263
match_each_native_ptype!(array.ptype(), |T| {
266-
take_piecewise_sequence_constant_length_typed::<T>(
267-
array, starts, length, validity, output_len,
268-
)
264+
take_slices_constant_length_typed::<T>(array, starts, length, validity, output_len)
269265
})
270266
}
271267

272-
fn take_piecewise_sequence_constant_length_typed<T>(
268+
fn take_slices_constant_length_typed<T>(
273269
array: ArrayView<'_, Primitive>,
274270
starts: &PrimitiveArray,
275271
length: usize,
@@ -280,7 +276,7 @@ where
280276
T: NativePType,
281277
{
282278
match_each_unsigned_integer_ptype!(starts.ptype(), |S| {
283-
let values = primitive_piecewise_constant_length_values::<T, S>(
279+
let values = take_slices_constant_length_to_buffer::<T, S>(
284280
array.as_slice::<T>(),
285281
starts.as_slice::<S>(),
286282
length,
@@ -290,7 +286,7 @@ where
290286
})
291287
}
292288

293-
fn primitive_piecewise_constant_length_values<T, S>(
289+
fn take_slices_constant_length_to_buffer<T, S>(
294290
source: &[T],
295291
starts: &[S],
296292
length: usize,

0 commit comments

Comments
 (0)