Skip to content

Commit 74a63f8

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 74a63f8

3 files changed

Lines changed: 10 additions & 23 deletions

File tree

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

Lines changed: 5 additions & 19 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;
@@ -51,35 +46,26 @@ impl SliceKernel for BitPacked {
5146

5247
#[cfg(test)]
5348
mod tests {
54-
use std::sync::LazyLock;
55-
5649
use vortex_array::DynArray;
5750
use vortex_array::IntoArray;
58-
use vortex_array::VortexSessionExecute;
5951
use vortex_array::arrays::PrimitiveArray;
6052
use vortex_array::arrays::SliceArray;
61-
use vortex_array::session::ArraySession;
6253
use vortex_error::VortexResult;
63-
use vortex_session::VortexSession;
6454

6555
use crate::BitPacked;
6656
use crate::bitpack_compress::bitpack_encode;
6757

68-
static SESSION: LazyLock<VortexSession> =
69-
LazyLock::new(|| VortexSession::empty().with::<ArraySession>());
70-
7158
#[test]
72-
fn test_execute_parent_returns_bitpacked_slice() -> VortexResult<()> {
59+
fn test_reduce_parent_returns_bitpacked_slice() -> VortexResult<()> {
7360
let values = PrimitiveArray::from_iter(0u32..2048);
7461
let bitpacked = bitpack_encode(&values, 11, None)?;
7562

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

78-
let mut ctx = SESSION.create_execution_ctx();
7965
let bitpacked_ref = bitpacked.into_array();
8066
let reduced = bitpacked_ref
8167
.vtable()
82-
.execute_parent(&bitpacked_ref, &slice_array.into_array(), 0, &mut ctx)?
68+
.reduce_parent(&bitpacked_ref, &slice_array.into_array(), 0)?
8369
.expect("expected slice kernel to execute");
8470

8571
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)