Skip to content

Commit e3eabde

Browse files
Feature: implement DictArray batched execute (#5686)
Tracking Issue: #5652 Adds batched execution to `DictArray`, which is just implemented as `take` on the child `values` vector with the codes as indices. ~~Additionally adds an optimization for `BoolVector::take` which is similar to the optimization we have for `BoolArray`'s `canonicalize` function, but does an additional check for zero or one `false`s (instead of just zero or one `true`s). That code is located at https://github.com/vortex-data/vortex/blob/develop/vortex-array/src/arrays/dict/vtable/canonical.rs.~~ ~~The difference here is that I use a heuristic check on the default `take` implementation on `BoolVector` (instead of only use this optimization for dictionary decompression) because I don't think there is any reason not to utilize this in general.~~ ~~I still need to add some benchmarks.~~ Also note that we don't need to specialize for the string types like in #1146 since we are _always_ decompressing the children immediately. Signed-off-by: Connor Tsui <[email protected]> Co-authored-by: Joe Isaacs <[email protected]>
1 parent 6e2a2a0 commit e3eabde

File tree

1 file changed

+16
-0
lines changed
  • vortex-array/src/arrays/dict/vtable

1 file changed

+16
-0
lines changed

vortex-array/src/arrays/dict/vtable/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
use vortex_buffer::BufferHandle;
5+
use vortex_compute::take::Take;
56
use vortex_dtype::DType;
67
use vortex_dtype::Nullability;
78
use vortex_dtype::PType;
@@ -16,6 +17,9 @@ use crate::ArrayRef;
1617
use crate::DeserializeMetadata;
1718
use crate::ProstMetadata;
1819
use crate::SerializeMetadata;
20+
use crate::kernel::BindCtx;
21+
use crate::kernel::KernelRef;
22+
use crate::kernel::kernel;
1923
use crate::serde::ArrayChildren;
2024
use crate::vtable;
2125
use crate::vtable::ArrayId;
@@ -124,4 +128,16 @@ impl VTable for DictVTable {
124128
array.values = values;
125129
Ok(())
126130
}
131+
132+
fn bind_kernel(array: &Self::Array, ctx: &mut BindCtx) -> VortexResult<KernelRef> {
133+
let values_kernel = array.values().bind_kernel(ctx)?;
134+
let codes_kernel = array.codes().bind_kernel(ctx)?;
135+
136+
Ok(kernel(move || {
137+
let values = values_kernel.execute()?;
138+
let codes = codes_kernel.execute()?.into_primitive();
139+
140+
Ok(values.take(&codes))
141+
}))
142+
}
127143
}

0 commit comments

Comments
 (0)