Skip to content

Commit 542d297

Browse files
committed
move BitPacked slice from kernel -> parent reduce
This is free and cheap since we do not need to materialize any data to do it. Signed-off-by: Andrew Duffy <andrew@a10y.dev>
1 parent 1f3206f commit 542d297

3 files changed

Lines changed: 10 additions & 16 deletions

File tree

encodings/fastlanes/src/bitpacking/compute/slice.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,15 @@ use std::cmp::max;
55
use std::ops::Range;
66

77
use vortex_array::ArrayRef;
8-
use vortex_array::ExecutionCtx;
98
use vortex_array::IntoArray;
10-
use vortex_array::arrays::slice::SliceKernel;
9+
use vortex_array::arrays::slice::SliceReduce;
1110
use vortex_error::VortexResult;
1211

1312
use crate::BitPacked;
1413
use crate::BitPackedArray;
1514

16-
impl SliceKernel for BitPacked {
17-
fn slice(
18-
array: &BitPackedArray,
19-
range: Range<usize>,
20-
_ctx: &mut ExecutionCtx,
21-
) -> VortexResult<Option<ArrayRef>> {
15+
impl SliceReduce for BitPacked {
16+
fn slice(array: &BitPackedArray, range: Range<usize>) -> VortexResult<Option<ArrayRef>> {
2217
let offset_start = range.start + array.offset() as usize;
2318
let offset_stop = range.end + array.offset() as usize;
2419
let offset = offset_start % 1024;
@@ -55,7 +50,6 @@ mod tests {
5550

5651
use vortex_array::DynArray;
5752
use vortex_array::IntoArray;
58-
use vortex_array::VortexSessionExecute;
5953
use vortex_array::arrays::PrimitiveArray;
6054
use vortex_array::arrays::SliceArray;
6155
use vortex_array::session::ArraySession;
@@ -69,17 +63,16 @@ mod tests {
6963
LazyLock::new(|| VortexSession::empty().with::<ArraySession>());
7064

7165
#[test]
72-
fn test_execute_parent_returns_bitpacked_slice() -> VortexResult<()> {
66+
fn test_reduce_parent_returns_bitpacked_slice() -> VortexResult<()> {
7367
let values = PrimitiveArray::from_iter(0u32..2048);
7468
let bitpacked = bitpack_encode(&values, 11, None)?;
7569

7670
let slice_array = SliceArray::new(bitpacked.clone().into_array(), 500..1500);
7771

78-
let mut ctx = SESSION.create_execution_ctx();
7972
let bitpacked_ref = bitpacked.into_array();
8073
let reduced = bitpacked_ref
8174
.vtable()
82-
.execute_parent(&bitpacked_ref, &slice_array.into_array(), 0, &mut ctx)?
75+
.reduce_parent(&bitpacked_ref, &slice_array.into_array(), 0)?
8376
.expect("expected slice kernel to execute");
8477

8578
assert!(reduced.is::<BitPacked>());

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33

44
use vortex_array::arrays::dict::TakeExecuteAdaptor;
55
use vortex_array::arrays::filter::FilterExecuteAdaptor;
6-
use vortex_array::arrays::slice::SliceExecuteAdaptor;
76
use vortex_array::kernel::ParentKernelSet;
87

98
use crate::BitPacked;
109

1110
pub(crate) const PARENT_KERNELS: ParentKernelSet<BitPacked> = ParentKernelSet::new(&[
1211
ParentKernelSet::lift(&FilterExecuteAdaptor(BitPacked)),
13-
ParentKernelSet::lift(&SliceExecuteAdaptor(BitPacked)),
1412
ParentKernelSet::lift(&TakeExecuteAdaptor(BitPacked)),
1513
]);
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4+
use vortex_array::arrays::slice::SliceReduceAdaptor;
45
use vortex_array::optimizer::rules::ParentRuleSet;
56
use vortex_array::scalar_fn::fns::cast::CastReduceAdaptor;
67

78
use crate::BitPacked;
89

9-
pub(crate) const RULES: ParentRuleSet<BitPacked> =
10-
ParentRuleSet::new(&[ParentRuleSet::lift(&CastReduceAdaptor(BitPacked))]);
10+
pub(crate) const RULES: ParentRuleSet<BitPacked> = ParentRuleSet::new(&[
11+
ParentRuleSet::lift(&CastReduceAdaptor(BitPacked)),
12+
ParentRuleSet::lift(&SliceReduceAdaptor(BitPacked)),
13+
]);

0 commit comments

Comments
 (0)