Skip to content

Commit 3d0b3b0

Browse files
committed
wip
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 8a5e626 commit 3d0b3b0

14 files changed

Lines changed: 65 additions & 108 deletions

File tree

vortex-array/public-api.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19230,8 +19230,6 @@ pub fn vortex_array::validity::Validity::to_array(&self, len: usize) -> vortex_a
1923019230

1923119231
pub fn vortex_array::validity::Validity::to_mask(&self, length: usize, ctx: &mut vortex_array::ExecutionCtx) -> vortex_error::VortexResult<vortex_mask::Mask>
1923219232

19233-
pub fn vortex_array::validity::Validity::to_mask_sync(&self, length: usize) -> vortex_mask::Mask
19234-
1923519233
pub fn vortex_array::validity::Validity::uncompressed_size(&self) -> usize
1923619234

1923719235
pub fn vortex_array::validity::Validity::union_nullability(self, nullability: vortex_array::dtype::Nullability) -> Self

vortex-array/src/arrays/fixed_size_list/array.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ use vortex_error::VortexResult;
1010
use vortex_error::vortex_ensure;
1111

1212
use crate::ArrayRef;
13-
use crate::LEGACY_SESSION;
14-
use crate::VortexSessionExecute;
1513
use crate::array::Array;
1614
use crate::array::ArrayParts;
1715
use crate::array::TypedArrayRef;
@@ -233,15 +231,6 @@ pub trait FixedSizeListArrayExt: TypedArrayRef<FixedSizeList> {
233231
child_to_validity(&self.as_ref().slots()[VALIDITY_SLOT], nullability)
234232
}
235233

236-
fn fixed_size_list_validity_mask(&self) -> vortex_mask::Mask {
237-
self.fixed_size_list_validity()
238-
.to_mask(
239-
self.as_ref().len(),
240-
&mut LEGACY_SESSION.create_execution_ctx(),
241-
)
242-
.vortex_expect("Failed to compute validity mask")
243-
}
244-
245234
fn fixed_size_list_elements_at(&self, index: usize) -> VortexResult<ArrayRef> {
246235
debug_assert!(
247236
index < self.as_ref().len(),

vortex-array/src/arrays/fixed_size_list/compute/take.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ use vortex_buffer::BufferMut;
66
use vortex_error::VortexExpect;
77
use vortex_error::VortexResult;
88
use vortex_error::vortex_panic;
9+
use vortex_mask::Mask;
910

1011
use crate::ArrayRef;
1112
use crate::IntoArray;
12-
use crate::LEGACY_SESSION;
13-
use crate::VortexSessionExecute;
13+
use crate::ToCanonical;
1414
use crate::array::ArrayView;
1515
use crate::arrays::FixedSizeList;
1616
use crate::arrays::FixedSizeListArray;
1717
use crate::arrays::Primitive;
1818
use crate::arrays::PrimitiveArray;
19+
use crate::arrays::bool::BoolArrayExt;
1920
use crate::arrays::dict::TakeExecute;
2021
use crate::arrays::fixed_size_list::FixedSizeListArrayExt;
2122
use crate::dtype::IntegerPType;
@@ -83,7 +84,7 @@ fn take_with_indices<I: IntegerPType, E: IntegerPType>(
8384
// The result's nullability is the union of the input nullabilities.
8485
if array.dtype().is_nullable() || indices_array.dtype().is_nullable() {
8586
let indices_array = indices_array.as_view();
86-
take_nullable_fsl::<I, E>(array, indices_array)
87+
take_nullable_fsl::<I, E>(array, indices_array, ctx)
8788
} else {
8889
let indices_array = indices_array.as_view();
8990
take_non_nullable_fsl::<I, E>(array, indices_array)
@@ -144,20 +145,25 @@ fn take_non_nullable_fsl<I: IntegerPType, E: IntegerPType>(
144145
fn take_nullable_fsl<I: IntegerPType, E: IntegerPType>(
145146
array: ArrayView<'_, FixedSizeList>,
146147
indices_array: ArrayView<'_, Primitive>,
148+
ctx: &mut ExecutionCtx,
147149
) -> VortexResult<ArrayRef> {
148150
let list_size = array.list_size() as usize;
149151
let indices: &[I] = indices_array.as_slice::<I>();
150152
let new_len = indices.len();
151153

152-
let array_validity = array.fixed_size_list_validity_mask();
153-
let indices_validity = indices_array
154+
let array_validity = array
155+
.fixed_size_list_validity()
156+
.to_mask(array.as_ref().len(), ctx)
157+
.vortex_expect("Failed to compute validity mask");
158+
let indices_len = indices_array.as_ref().len();
159+
let indices_validity = match indices_array
154160
.validity()
155161
.vortex_expect("Failed to compute validity mask")
156-
.to_mask(
157-
indices_array.as_ref().len(),
158-
&mut LEGACY_SESSION.create_execution_ctx(),
159-
)
160-
.vortex_expect("Failed to compute validity mask");
162+
{
163+
Validity::NonNullable | Validity::AllValid => Mask::new_true(indices_len),
164+
Validity::AllInvalid => Mask::new_false(indices_len),
165+
Validity::Array(a) => a.to_bool().to_mask(),
166+
};
161167

162168
// We must use placeholder zeros for null lists to maintain the array length without
163169
// propagating nullability to the element array's take operation.

vortex-array/src/arrays/list/array.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,6 @@ pub trait ListArrayExt: TypedArrayRef<List> {
288288
child_to_validity(&self.as_ref().slots()[VALIDITY_SLOT], self.nullability())
289289
}
290290

291-
fn list_validity_mask(&self) -> vortex_mask::Mask {
292-
self.list_validity()
293-
.to_mask(
294-
self.as_ref().len(),
295-
&mut LEGACY_SESSION.create_execution_ctx(),
296-
)
297-
.vortex_expect("Failed to compute validity mask")
298-
}
299-
300291
fn offset_at(&self, index: usize) -> VortexResult<usize> {
301292
vortex_ensure!(
302293
index <= self.as_ref().len(),

vortex-array/src/arrays/list/compute/take.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ fn _take<I: IntegerPType, O: IntegerPType, OutputOffsetType: IntegerPType>(
5959
indices_array: ArrayView<'_, Primitive>,
6060
ctx: &mut ExecutionCtx,
6161
) -> VortexResult<ArrayRef> {
62-
let data_validity = array.list_validity_mask();
62+
let data_validity = array
63+
.list_validity()
64+
.to_mask(array.as_ref().len(), ctx)?;
6365
let indices_validity = indices_array
6466
.validity()
6567
.vortex_expect("Failed to compute validity mask")
@@ -127,7 +129,9 @@ fn _take_nullable<I: IntegerPType, O: IntegerPType, OutputOffsetType: IntegerPTy
127129
let offsets_array = array.offsets().clone().execute::<PrimitiveArray>(ctx)?;
128130
let offsets: &[O] = offsets_array.as_slice();
129131
let indices: &[I] = indices_array.as_slice();
130-
let data_validity = array.list_validity_mask();
132+
let data_validity = array
133+
.list_validity()
134+
.to_mask(array.as_ref().len(), ctx)?;
131135
let indices_validity = indices_array
132136
.validity()
133137
.vortex_expect("Failed to compute validity mask")

vortex-array/src/arrays/listview/array.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ use vortex_error::vortex_ensure;
1313
use vortex_error::vortex_err;
1414

1515
use crate::ArrayRef;
16-
use crate::LEGACY_SESSION;
1716
use crate::ToCanonical;
18-
use crate::VortexSessionExecute;
1917
use crate::array::Array;
2018
use crate::array::ArrayParts;
2119
use crate::array::TypedArrayRef;
@@ -336,15 +334,6 @@ pub trait ListViewArrayExt: TypedArrayRef<ListView> {
336334
child_to_validity(&self.as_ref().slots()[VALIDITY_SLOT], self.nullability())
337335
}
338336

339-
fn listview_validity_mask(&self) -> vortex_mask::Mask {
340-
self.listview_validity()
341-
.to_mask(
342-
self.as_ref().len(),
343-
&mut LEGACY_SESSION.create_execution_ctx(),
344-
)
345-
.vortex_expect("Failed to compute validity mask")
346-
}
347-
348337
fn offset_at(&self, index: usize) -> usize {
349338
assert!(
350339
index < self.as_ref().len(),

vortex-array/src/arrays/masked/array.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ use vortex_error::VortexResult;
99
use vortex_error::vortex_bail;
1010

1111
use crate::ArrayRef;
12-
use crate::LEGACY_SESSION;
13-
use crate::VortexSessionExecute;
1412
use crate::array::Array;
1513
use crate::array::ArrayParts;
1614
use crate::array::TypedArrayRef;
@@ -52,15 +50,6 @@ pub trait MaskedArrayExt: TypedArrayRef<Masked> {
5250
self.as_ref().dtype().nullability(),
5351
)
5452
}
55-
56-
fn masked_validity_mask(&self) -> vortex_mask::Mask {
57-
self.masked_validity()
58-
.to_mask(
59-
self.as_ref().len(),
60-
&mut LEGACY_SESSION.create_execution_ctx(),
61-
)
62-
.vortex_expect("Failed to compute validity mask")
63-
}
6453
}
6554
impl<T: TypedArrayRef<Masked>> MaskedArrayExt for T {}
6655

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ impl VTable for Masked {
157157
}
158158

159159
fn execute(array: Array<Self>, ctx: &mut ExecutionCtx) -> VortexResult<ExecutionResult> {
160-
let validity_mask = array.masked_validity_mask();
160+
let validity_mask = array
161+
.masked_validity()
162+
.to_mask(array.len(), ctx)?;
161163

162164
// Fast path: all masked means result is all nulls.
163165
if validity_mask.all_false() {

vortex-array/src/arrays/varbin/array.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ use vortex_error::VortexExpect;
1010
use vortex_error::VortexResult;
1111
use vortex_error::vortex_ensure;
1212
use vortex_error::vortex_err;
13-
use vortex_mask::Mask;
1413

1514
use crate::ArrayRef;
16-
use crate::LEGACY_SESSION;
1715
use crate::ToCanonical;
18-
use crate::VortexSessionExecute;
1916
use crate::array::Array;
2017
use crate::array::ArrayParts;
2118
use crate::array::TypedArrayRef;
@@ -319,15 +316,6 @@ pub trait VarBinArrayExt: TypedArrayRef<VarBin> {
319316
child_to_validity(&self.as_ref().slots()[VALIDITY_SLOT], self.nullability())
320317
}
321318

322-
fn varbin_validity_mask(&self) -> Mask {
323-
self.varbin_validity()
324-
.to_mask(
325-
self.as_ref().len(),
326-
&mut LEGACY_SESSION.create_execution_ctx(),
327-
)
328-
.vortex_expect("Failed to compute validity mask")
329-
}
330-
331319
fn offset_at(&self, index: usize) -> usize {
332320
assert!(
333321
index <= self.as_ref().len(),

vortex-array/src/arrays/varbin/compute/filter.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ fn filter_select_var_bin_by_slice(
6868
offsets.as_slice::<O>(),
6969
values.bytes().as_slice(),
7070
mask_slices,
71-
values.varbin_validity_mask(),
71+
values
72+
.varbin_validity()
73+
.to_mask(values.as_ref().len(), ctx)
74+
.vortex_expect("Failed to compute validity mask"),
7275
selection_count,
7376
)
7477
})

0 commit comments

Comments
 (0)