Skip to content

Commit 225c3b4

Browse files
authored
Add operator for null and extension arrays (#5098)
Signed-off-by: Nicholas Gates <[email protected]>
1 parent 450a612 commit 225c3b4

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
mod array;
55
mod canonical;
66
mod operations;
7+
mod operator;
78
mod serde;
89
mod validity;
910
mod visitor;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
use vortex_error::VortexResult;
5+
6+
use crate::ArrayRef;
7+
use crate::arrays::{ExtensionArray, ExtensionVTable};
8+
use crate::execution::{BatchKernelRef, BindCtx};
9+
use crate::vtable::OperatorVTable;
10+
11+
impl OperatorVTable<ExtensionVTable> for ExtensionVTable {
12+
fn bind(
13+
array: &ExtensionArray,
14+
selection: Option<&ArrayRef>,
15+
ctx: &mut dyn BindCtx,
16+
) -> VortexResult<BatchKernelRef> {
17+
// Since vectors are physically typed, extension array can delegate to its storage array
18+
ctx.bind(&array.storage, selection)
19+
}
20+
}

vortex-array/src/arrays/null/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ use vortex_dtype::DType;
99
use vortex_error::VortexResult;
1010
use vortex_mask::Mask;
1111
use vortex_scalar::Scalar;
12+
use vortex_vector::NullVector;
1213

14+
use crate::execution::{BatchKernelRef, BindCtx, kernel};
1315
use crate::serde::ArrayChildren;
1416
use crate::stats::{ArrayStats, StatsSetRef};
1517
use crate::vtable::{
16-
ArrayVTable, CanonicalVTable, NotSupported, OperationsVTable, SerdeVTable, VTable,
17-
ValidityVTable, VisitorVTable,
18+
ArrayVTable, CanonicalVTable, NotSupported, OperationsVTable, OperatorVTable, SerdeVTable,
19+
VTable, ValidityVTable, VisitorVTable,
1820
};
1921
use crate::{
2022
ArrayBufferVisitor, ArrayChildVisitor, ArrayRef, Canonical, EmptyMetadata, EncodingId,
@@ -36,8 +38,8 @@ impl VTable for NullVTable {
3638
type VisitorVTable = Self;
3739
type ComputeVTable = NotSupported;
3840
type EncodeVTable = NotSupported;
39-
type OperatorVTable = NotSupported;
4041
type SerdeVTable = Self;
42+
type OperatorVTable = Self;
4143

4244
fn id(_encoding: &Self::Encoding) -> EncodingId {
4345
EncodingId::new_ref("vortex.null")
@@ -170,3 +172,14 @@ impl ValidityVTable<NullVTable> for NullVTable {
170172
Mask::AllFalse(array.len)
171173
}
172174
}
175+
176+
impl OperatorVTable<NullVTable> for NullVTable {
177+
fn bind(
178+
array: &NullArray,
179+
_selection: Option<&ArrayRef>,
180+
_ctx: &mut dyn BindCtx,
181+
) -> VortexResult<BatchKernelRef> {
182+
let len = array.len();
183+
Ok(kernel(move || Ok(NullVector::new(len).into())))
184+
}
185+
}

0 commit comments

Comments
 (0)