Skip to content

Commit b9e29a1

Browse files
authored
Feature: ListViewArray (#4708)
Tracking Issue: #4699 Adds a new `ListViewArray` encoding. The compute functions and the `ListViewBuilder` will come in a future PR. --------- Signed-off-by: Connor Tsui <[email protected]>
1 parent 450dbd2 commit b9e29a1

File tree

24 files changed

+1786
-26
lines changed

24 files changed

+1786
-26
lines changed

encodings/sparse/src/canonical.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ use itertools::Itertools;
77
use num_traits::NumCast;
88
use vortex_array::arrays::{
99
BinaryView, BoolArray, BooleanBuffer, ConstantArray, FixedSizeListArray, ListArray, NullArray,
10-
OffsetPType, PrimitiveArray, StructArray, VarBinViewArray, smallest_storage_type,
10+
PrimitiveArray, StructArray, VarBinViewArray, smallest_storage_type,
1111
};
1212
use vortex_array::builders::{ArrayBuilder, DecimalBuilder, ListBuilder, builder_with_capacity};
1313
use vortex_array::patches::Patches;
1414
use vortex_array::validity::Validity;
1515
use vortex_array::vtable::{CanonicalVTable, ValidityHelper};
16-
use vortex_array::{Array, ArrayRef, Canonical, IntoArray as _, ToCanonical as _};
16+
use vortex_array::{Array, ArrayRef, Canonical, IntoArray as _, OffsetPType, ToCanonical as _};
1717
use vortex_buffer::{Buffer, BufferMut, BufferString, ByteBuffer, buffer, buffer_mut};
1818
use vortex_dtype::{
1919
DType, DecimalDType, NativePType, Nullability, StructFields, match_each_integer_ptype,

vortex-array/src/arrays/arbitrary.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ use vortex_scalar::arbitrary::random_scalar;
1414
use vortex_scalar::{Scalar, match_each_decimal_value_type};
1515

1616
use super::{
17-
BoolArray, ChunkedArray, NullArray, OffsetPType, PrimitiveArray, StructArray,
18-
smallest_storage_type,
17+
BoolArray, ChunkedArray, NullArray, PrimitiveArray, StructArray, smallest_storage_type,
1918
};
2019
use crate::arrays::{VarBinArray, VarBinViewArray};
2120
use crate::builders::{ArrayBuilder, DecimalBuilder, FixedSizeListBuilder};
2221
use crate::validity::Validity;
23-
use crate::{Array, ArrayRef, IntoArray, ToCanonical, builders};
22+
use crate::{Array, ArrayRef, IntoArray, OffsetPType, ToCanonical, builders};
2423

2524
/// A wrapper type to implement `Arbitrary` for `ArrayRef`.
2625
#[derive(Clone, Debug)]

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ pub struct FixedSizeListArray {
8383

8484
/// The validity / null map of the array.
8585
///
86-
/// Note that this null map refers to the fixed-size list scalars, **not** the elements of the
87-
/// _individual_ fixed-size list scalars. The `elements` array will track individual value
88-
/// nullability.
86+
/// Note that this null map refers to which fixed-size list scalars are null, **not** which
87+
/// sub-elements of fixed-size list scalars are null. The `elements` array will track individual
88+
/// value nullability.
8989
validity: Validity,
9090

9191
/// The length of the array.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ impl SerdeVTable<FixedSizeListVTable> for FixedSizeListVTable {
3232
) -> VortexResult<FixedSizeListArray> {
3333
vortex_ensure!(
3434
buffers.is_empty(),
35-
"`FixedSizeListVTable::build` got some buffers"
35+
"`FixedSizeListVTable::build` expects no buffers"
3636
);
3737

38+
let DType::FixedSizeList(element_dtype, list_size, _) = &dtype else {
39+
vortex_bail!("Expected `DType::FixedSizeList`, got {:?}", dtype);
40+
};
41+
3842
let validity = {
3943
if children.len() > 2 {
4044
vortex_bail!("`FixedSizeListVTable::build` method expected 1 or 2 children")
@@ -49,10 +53,6 @@ impl SerdeVTable<FixedSizeListVTable> for FixedSizeListVTable {
4953
}
5054
};
5155

52-
let DType::FixedSizeList(element_dtype, list_size, _) = &dtype else {
53-
vortex_bail!("Expected `DType::FixedSizeList`, got {:?}", dtype);
54-
};
55-
5656
let num_elements = len * (*list_size as usize);
5757
let elements = children.get(0, element_dtype.as_ref(), num_elements)?;
5858

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use vortex_dtype::{NativePType, Nullability, match_each_integer_ptype};
77
use vortex_error::{VortexExpect, VortexResult, vortex_panic};
88
use vortex_mask::Mask;
99

10-
use crate::arrays::{ListArray, ListVTable, OffsetPType, PrimitiveArray};
10+
use crate::arrays::{ListArray, ListVTable, PrimitiveArray};
1111
use crate::builders::{ArrayBuilder, PrimitiveBuilder};
1212
use crate::compute::{TakeKernel, TakeKernelAdapter, take};
1313
use crate::validity::Validity;
1414
use crate::vtable::ValidityHelper;
15-
use crate::{Array, ArrayRef, ToCanonical, register_kernel};
15+
use crate::{Array, ArrayRef, OffsetPType, ToCanonical, register_kernel};
1616

1717
impl TakeKernel for ListVTable {
1818
fn take(&self, array: &ListArray, indices: &dyn Array) -> VortexResult<ArrayRef> {

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ use std::sync::Arc;
99

1010
#[cfg(feature = "test-harness")]
1111
use itertools::Itertools;
12-
use num_traits::{AsPrimitive, PrimInt};
13-
use vortex_dtype::{DType, NativePType, match_each_integer_ptype, match_each_native_ptype};
12+
use num_traits::AsPrimitive;
13+
use vortex_dtype::{DType, match_each_integer_ptype, match_each_native_ptype};
1414
use vortex_error::{VortexExpect, VortexResult, vortex_bail, vortex_ensure};
1515
use vortex_scalar::Scalar;
1616

17+
#[cfg(feature = "test-harness")]
18+
use crate::OffsetPType;
1719
use crate::arrays::PrimitiveVTable;
1820
#[cfg(feature = "test-harness")]
1921
use crate::builders::{ArrayBuilder, ListBuilder};
@@ -115,10 +117,6 @@ pub struct ListArray {
115117
#[derive(Clone, Debug)]
116118
pub struct ListEncoding;
117119

118-
pub trait OffsetPType: NativePType + PrimInt + AsPrimitive<usize> + Into<Scalar> {}
119-
120-
impl<T> OffsetPType for T where T: NativePType + PrimInt + AsPrimitive<usize> + Into<Scalar> {}
121-
122120
impl ListArray {
123121
/// Creates a new [`ListArray`].
124122
///

0 commit comments

Comments
 (0)