Skip to content

Commit 66e309c

Browse files
committed
Deprecate scalar_at for execute_scalar
Signed-off-by: Nicholas Gates <nick@nickgates.com>
1 parent 6259da9 commit 66e309c

53 files changed

Lines changed: 484 additions & 622 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

encodings/alp/benches/alp_compress.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use vortex_alp::ALPRDFloat;
1212
use vortex_alp::RDEncoder;
1313
use vortex_alp::alp_encode;
1414
use vortex_alp::decompress_into_array;
15+
use vortex_array::Canonical;
16+
use vortex_array::IntoArray;
1517
use vortex_array::LEGACY_SESSION;
1618
use vortex_array::VortexSessionExecute;
1719
use vortex_array::arrays::PrimitiveArray;
@@ -153,6 +155,6 @@ fn decompress_rd<T: ALPRDFloat + NativePType>(bencher: Bencher, args: (usize, f6
153155
let encoded = encoder.encode(primitive.as_view());
154156

155157
bencher
156-
.with_inputs(|| &encoded)
157-
.bench_refs(|encoded| encoded.to_canonical());
158+
.with_inputs(|| (&encoded, LEGACY_SESSION.create_execution_ctx()))
159+
.bench_refs(|(encoded, ctx)| (**encoded).clone().into_array().execute::<Canonical>(ctx));
158160
}

encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ impl ValidityChild<DecimalByteParts> for DecimalByteParts {
329329
#[cfg(test)]
330330
mod tests {
331331
use vortex_array::IntoArray;
332+
use vortex_array::LEGACY_SESSION;
333+
use vortex_array::VortexSessionExecute;
332334
use vortex_array::arrays::BoolArray;
333335
use vortex_array::arrays::PrimitiveArray;
334336
use vortex_array::dtype::DType;
@@ -360,12 +362,7 @@ mod tests {
360362
assert_eq!(
361363
Scalar::null(dtype.clone()),
362364
array
363-
.execute_scalar(
364-
0,
365-
&mut vortex_array::VortexSessionExecute::create_execution_ctx(
366-
&*vortex_array::LEGACY_SESSION
367-
)
368-
)
365+
.execute_scalar(0, &mut LEGACY_SESSION.create_execution_ctx())
369366
.unwrap()
370367
);
371368
assert_eq!(
@@ -375,23 +372,13 @@ mod tests {
375372
)
376373
.unwrap(),
377374
array
378-
.execute_scalar(
379-
1,
380-
&mut vortex_array::VortexSessionExecute::create_execution_ctx(
381-
&*vortex_array::LEGACY_SESSION
382-
)
383-
)
375+
.execute_scalar(1, &mut LEGACY_SESSION.create_execution_ctx())
384376
.unwrap()
385377
);
386378
assert_eq!(
387379
Scalar::try_new(dtype, Some(ScalarValue::Decimal(DecimalValue::I64(400)))).unwrap(),
388380
array
389-
.execute_scalar(
390-
2,
391-
&mut vortex_array::VortexSessionExecute::create_execution_ctx(
392-
&*vortex_array::LEGACY_SESSION
393-
)
394-
)
381+
.execute_scalar(2, &mut LEGACY_SESSION.create_execution_ctx())
395382
.unwrap()
396383
);
397384
}

encodings/fastlanes/benches/canonicalize_bench.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ fn into_canonical_non_nullable(
5353
.collect::<Vec<_>>();
5454

5555
bencher
56-
.with_inputs(|| ChunkedArray::from_iter(chunks.clone()).into_array())
57-
.bench_refs(|chunked| chunked.to_canonical());
56+
.with_inputs(|| {
57+
(
58+
ChunkedArray::from_iter(chunks.clone()).into_array(),
59+
SESSION.create_execution_ctx(),
60+
)
61+
})
62+
.bench_refs(|(chunked, ctx)| chunked.clone().execute::<Canonical>(ctx));
5863
}
5964

6065
#[cfg(not(codspeed))]

encodings/fastlanes/src/bitpacking/vtable/operations.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ mod test {
3434

3535
use vortex_array::ArrayRef;
3636
use vortex_array::IntoArray;
37+
use vortex_array::LEGACY_SESSION;
38+
use vortex_array::VortexSessionExecute;
3739
use vortex_array::arrays::PrimitiveArray;
3840
use vortex_array::arrays::SliceArray;
3941
use vortex_array::assert_arrays_eq;
@@ -203,12 +205,7 @@ mod test {
203205
.into_array();
204206
assert_eq!(
205207
packed_array
206-
.execute_scalar(
207-
1,
208-
&mut vortex_array::VortexSessionExecute::create_execution_ctx(
209-
&*vortex_array::LEGACY_SESSION
210-
)
211-
)
208+
.execute_scalar(1, &mut LEGACY_SESSION.create_execution_ctx())
212209
.unwrap(),
213210
Scalar::null(DType::Primitive(PType::U32, Nullability::Nullable))
214211
);
@@ -225,12 +222,7 @@ mod test {
225222
assert_eq!(
226223
usize::try_from(
227224
&patches
228-
.execute_scalar(
229-
0,
230-
&mut vortex_array::VortexSessionExecute::create_execution_ctx(
231-
&*vortex_array::LEGACY_SESSION
232-
)
233-
)
225+
.execute_scalar(0, &mut LEGACY_SESSION.create_execution_ctx())
234226
.unwrap()
235227
)
236228
.unwrap(),

encodings/fastlanes/src/rle/array/mod.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use std::fmt::Display;
55
use std::fmt::Formatter;
66

77
use vortex_array::ArrayRef;
8+
use vortex_array::LEGACY_SESSION;
89
use vortex_array::TypedArrayRef;
10+
use vortex_array::VortexSessionExecute;
911
use vortex_error::VortexExpect as _;
1012
use vortex_error::VortexResult;
1113
use vortex_error::vortex_ensure;
@@ -111,24 +113,14 @@ pub trait RLEArrayExt: TypedArrayRef<crate::RLE> {
111113
)]
112114
fn values_idx_offset(&self, chunk_idx: usize) -> usize {
113115
self.values_idx_offsets()
114-
.execute_scalar(
115-
chunk_idx,
116-
&mut vortex_array::VortexSessionExecute::create_execution_ctx(
117-
&*vortex_array::LEGACY_SESSION,
118-
),
119-
)
116+
.execute_scalar(chunk_idx, &mut LEGACY_SESSION.create_execution_ctx())
120117
.expect("index must be in bounds")
121118
.as_primitive()
122119
.as_::<usize>()
123120
.expect("index must be of type usize")
124121
- self
125122
.values_idx_offsets()
126-
.execute_scalar(
127-
0,
128-
&mut vortex_array::VortexSessionExecute::create_execution_ctx(
129-
&*vortex_array::LEGACY_SESSION,
130-
),
131-
)
123+
.execute_scalar(0, &mut LEGACY_SESSION.create_execution_ctx())
132124
.expect("index must be in bounds")
133125
.as_primitive()
134126
.as_::<usize>()
@@ -147,6 +139,7 @@ impl<T: TypedArrayRef<crate::RLE>> RLEArrayExt for T {}
147139
#[cfg(test)]
148140
mod tests {
149141
use vortex_array::ArrayContext;
142+
use vortex_array::Canonical;
150143
use vortex_array::IntoArray;
151144
use vortex_array::LEGACY_SESSION;
152145
use vortex_array::ToCanonical;
@@ -279,7 +272,7 @@ mod tests {
279272
let invalid_slice = rle_array
280273
.slice(2..5)
281274
.unwrap()
282-
.to_canonical()
275+
.execute::<Canonical>(&mut LEGACY_SESSION.create_execution_ctx())
283276
.unwrap()
284277
.into_primitive();
285278
let mut ctx = SESSION.create_execution_ctx();

encodings/fastlanes/src/rle/vtable/operations.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ impl OperationsVTable<RLE> for RLE {
4242
#[cfg(test)]
4343
mod tests {
4444
use vortex_array::IntoArray;
45+
use vortex_array::LEGACY_SESSION;
4546
use vortex_array::ToCanonical;
47+
use vortex_array::VortexSessionExecute;
4648
use vortex_array::arrays::PrimitiveArray;
4749
use vortex_array::assert_arrays_eq;
4850
use vortex_array::validity::Validity;
@@ -179,12 +181,7 @@ mod tests {
179181
if idx < encoded.len() {
180182
let original_value = expected[idx];
181183
let encoded_value = encoded
182-
.execute_scalar(
183-
idx,
184-
&mut vortex_array::VortexSessionExecute::create_execution_ctx(
185-
&*vortex_array::LEGACY_SESSION,
186-
),
187-
)
184+
.execute_scalar(idx, &mut LEGACY_SESSION.create_execution_ctx())
188185
.unwrap()
189186
.as_primitive()
190187
.as_::<u16>()
@@ -199,12 +196,7 @@ mod tests {
199196
fn test_scalar_at_out_of_bounds() {
200197
let array = fixture::rle_array();
201198
array
202-
.execute_scalar(
203-
1025,
204-
&mut vortex_array::VortexSessionExecute::create_execution_ctx(
205-
&*vortex_array::LEGACY_SESSION,
206-
),
207-
)
199+
.execute_scalar(1025, &mut LEGACY_SESSION.create_execution_ctx())
208200
.unwrap();
209201
}
210202

@@ -213,12 +205,7 @@ mod tests {
213205
fn test_scalar_at_slice_out_of_bounds() {
214206
let array = fixture::rle_array().slice(0..1).unwrap();
215207
array
216-
.execute_scalar(
217-
1,
218-
&mut vortex_array::VortexSessionExecute::create_execution_ctx(
219-
&*vortex_array::LEGACY_SESSION,
220-
),
221-
)
208+
.execute_scalar(1, &mut LEGACY_SESSION.create_execution_ctx())
222209
.unwrap();
223210
}
224211

encodings/fsst/benches/chunked_dict_fsst_builder.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::sync::LazyLock;
55

66
use divan::Bencher;
77
use vortex_array::ArrayRef;
8+
use vortex_array::Canonical;
89
use vortex_array::IntoArray;
910
use vortex_array::VortexSessionExecute;
1011
use vortex_array::arrays::ChunkedArray;
@@ -68,6 +69,6 @@ fn chunked_dict_fsst_into_canonical(
6869
let chunk = make_dict_fsst_chunks::<u16>(len, unique_values, chunk_count);
6970

7071
bencher
71-
.with_inputs(|| &chunk)
72-
.bench_refs(|chunk| chunk.to_canonical())
72+
.with_inputs(|| (&chunk, SESSION.create_execution_ctx()))
73+
.bench_refs(|(chunk, ctx)| (**chunk).clone().execute::<Canonical>(ctx))
7374
}

encodings/fsst/benches/fsst_compress.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use divan::Bencher;
99
use rand::RngExt;
1010
use rand::SeedableRng;
1111
use rand::rngs::StdRng;
12+
use vortex_array::Canonical;
1213
use vortex_array::IntoArray;
1314
use vortex_array::LEGACY_SESSION;
1415
use vortex_array::RecursiveCanonical;
@@ -71,8 +72,8 @@ fn decompress_fsst(bencher: Bencher, (string_count, avg_len, unique_chars): (usi
7172
let encoded = fsst_compress(array, len, &dtype, &compressor);
7273

7374
bencher
74-
.with_inputs(|| &encoded)
75-
.bench_refs(|encoded| encoded.to_canonical())
75+
.with_inputs(|| (&encoded, LEGACY_SESSION.create_execution_ctx()))
76+
.bench_refs(|(encoded, ctx)| (**encoded).clone().into_array().execute::<Canonical>(ctx))
7677
}
7778

7879
#[divan::bench(args = BENCH_ARGS)]
@@ -128,8 +129,10 @@ fn canonicalize_compare(
128129
)
129130
})
130131
.bench_refs(|(fsst_array, constant, ctx)| {
131-
fsst_array
132-
.to_canonical()
132+
(*fsst_array)
133+
.clone()
134+
.into_array()
135+
.execute::<Canonical>(ctx)
133136
.unwrap()
134137
.into_array()
135138
.binary(constant.clone().into_array(), Operator::Eq)
@@ -179,8 +182,8 @@ fn chunked_into_canonical(
179182
let array = generate_chunked_test_data(chunk_size, string_count, avg_len, unique_chars);
180183

181184
bencher
182-
.with_inputs(|| &array)
183-
.bench_refs(|array| array.to_canonical());
185+
.with_inputs(|| (&array, SESSION.create_execution_ctx()))
186+
.bench_refs(|(array, ctx)| (**array).clone().into_array().execute::<Canonical>(ctx));
184187
}
185188

186189
/// Helper function to generate random string data.

encodings/fsst/benches/fsst_url_compare.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use std::sync::LazyLock;
77

88
use divan::Bencher;
9+
use vortex_array::Canonical;
910
use vortex_array::IntoArray;
1011
use vortex_array::RecursiveCanonical;
1112
use vortex_array::VortexSessionExecute;
@@ -105,8 +106,10 @@ fn eq_canonicalize_high_match(bencher: Bencher) {
105106
bencher
106107
.with_inputs(|| (&fsst_array, &constant, SESSION.create_execution_ctx()))
107108
.bench_refs(|(fsst_array, constant, ctx)| {
108-
fsst_array
109-
.to_canonical()
109+
(*fsst_array)
110+
.clone()
111+
.into_array()
112+
.execute::<Canonical>(ctx)
110113
.unwrap()
111114
.into_array()
112115
.binary(constant.clone().into_array(), Operator::Eq)
@@ -127,8 +130,10 @@ fn eq_canonicalize_low_match(bencher: Bencher) {
127130
bencher
128131
.with_inputs(|| (&fsst_array, &constant, SESSION.create_execution_ctx()))
129132
.bench_refs(|(fsst_array, constant, ctx)| {
130-
fsst_array
131-
.to_canonical()
133+
(*fsst_array)
134+
.clone()
135+
.into_array()
136+
.execute::<Canonical>(ctx)
132137
.unwrap()
133138
.into_array()
134139
.binary(constant.clone().into_array(), Operator::Eq)

encodings/fsst/src/array.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ use vortex_array::Canonical;
2323
use vortex_array::ExecutionCtx;
2424
use vortex_array::ExecutionResult;
2525
use vortex_array::IntoArray;
26+
use vortex_array::LEGACY_SESSION;
2627
use vortex_array::Precision;
2728
use vortex_array::TypedArrayRef;
29+
use vortex_array::VortexSessionExecute;
2830
use vortex_array::arrays::VarBin;
2931
use vortex_array::arrays::VarBinArray;
3032
use vortex_array::arrays::varbin::VarBinArrayExt;
@@ -582,9 +584,7 @@ impl FSSTData {
582584
let last_offset: usize = (&codes_offsets
583585
.execute_scalar(
584586
codes_offsets.len() - 1,
585-
&mut vortex_array::VortexSessionExecute::create_execution_ctx(
586-
&*vortex_array::LEGACY_SESSION,
587-
),
587+
&mut LEGACY_SESSION.create_execution_ctx(),
588588
)
589589
.vortex_expect("offsets must support scalar_at"))
590590
.try_into()

0 commit comments

Comments
 (0)