Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions encodings/runend/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ pub struct RunEndArray {
stats_set: ArrayStats,
}

pub struct RunEndArrayParts {
pub ends: ArrayRef,
pub values: ArrayRef,
}

#[derive(Debug)]
pub struct RunEndVTable;

Expand Down Expand Up @@ -393,6 +398,15 @@ impl RunEndArray {
pub fn values(&self) -> &ArrayRef {
&self.values
}

/// Split an `RunEndArray` into parts.
#[inline]
pub fn into_parts(self) -> RunEndArrayParts {
RunEndArrayParts {
values: self.values,
ends: self.ends,
}
}
}

impl BaseArrayVTable<RunEndVTable> for RunEndVTable {
Expand Down
16 changes: 16 additions & 0 deletions vortex-array/src/arrays/bool/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ pub struct BoolArray {
pub(super) stats_set: ArrayStats,
}

pub struct BoolArrayParts {
pub dtype: DType,
pub bits: BitBuffer,
pub validity: Validity,
}

impl BoolArray {
/// Constructs a new `BoolArray`.
///
Expand Down Expand Up @@ -122,6 +128,16 @@ impl BoolArray {
Ok(())
}

/// Splits into owned parts
#[inline]
pub fn into_parts(self) -> BoolArrayParts {
BoolArrayParts {
dtype: self.dtype,
bits: self.bits,
validity: self.validity,
}
}

/// Creates a new [`BoolArray`] from a [`BitBuffer`] and [`Validity`] directly.
///
/// # Panics
Expand Down
3 changes: 2 additions & 1 deletion vortex-array/src/arrays/bool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
mod array;
mod patch;

pub use array::*;
pub use array::BoolArray;
pub use array::BoolArrayParts;

pub mod compute;

Expand Down
1 change: 0 additions & 1 deletion vortex-array/src/arrays/chunked/compute/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ pub(crate) fn chunk_filters(
}

/// Filter the chunks using indices.
#[allow(deprecated)]
fn filter_indices(
array: &ChunkedArray,
indices: impl Iterator<Item = usize>,
Expand Down
22 changes: 22 additions & 0 deletions vortex-array/src/arrays/decimal/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use vortex_dtype::DecimalDType;
use vortex_dtype::DecimalType;
use vortex_dtype::IntegerPType;
use vortex_dtype::NativeDecimalType;
use vortex_dtype::Nullability;
use vortex_dtype::match_each_decimal_value_type;
use vortex_dtype::match_each_integer_ptype;
use vortex_error::VortexExpect;
Expand Down Expand Up @@ -91,6 +92,14 @@ pub struct DecimalArray {
pub(super) stats_set: ArrayStats,
}

pub struct DecimalArrayParts {
pub decimal_dtype: DecimalDType,
pub nullability: Nullability,
pub values: ByteBuffer,
pub values_type: DecimalType,
pub validity: Validity,
}

impl DecimalArray {
/// Creates a new [`DecimalArray`].
///
Expand Down Expand Up @@ -221,6 +230,19 @@ impl DecimalArray {
}
}

pub fn into_parts(self) -> DecimalArrayParts {
let nullability = self.dtype.nullability();
let decimal_dtype = self.dtype.into_decimal_opt().vortex_expect("cannot fail");

DecimalArrayParts {
decimal_dtype,
nullability,
values: self.values,
values_type: self.values_type,
validity: self.validity,
}
}

/// Returns the underlying [`ByteBuffer`] of the array.
pub fn byte_buffer(&self) -> ByteBuffer {
self.values.clone()
Expand Down
1 change: 1 addition & 0 deletions vortex-array/src/arrays/decimal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

mod array;
pub use array::DecimalArray;
pub use array::DecimalArrayParts;

mod compute;

Expand Down
4 changes: 2 additions & 2 deletions vortex-array/src/arrays/fixed_size_list/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ impl FixedSizeListArray {
}
}

pub fn into_parts(self) -> (ArrayRef, Validity) {
(self.elements, self.validity)
pub fn into_parts(self) -> (ArrayRef, Validity, DType) {
(self.elements, self.validity, self.dtype)
}

/// Validates the components that would be used to create a [`FixedSizeListArray`].
Expand Down
17 changes: 17 additions & 0 deletions vortex-array/src/arrays/list/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ pub struct ListArray {
pub(super) stats_set: ArrayStats,
}

pub struct ListArrayParts {
pub dtype: DType,
pub elements: ArrayRef,
pub offsets: ArrayRef,
pub validity: Validity,
}

impl ListArray {
/// Creates a new [`ListArray`].
///
Expand Down Expand Up @@ -229,6 +236,16 @@ impl ListArray {
Ok(())
}

/// Splits an array into its parts
pub fn into_parts(self) -> ListArrayParts {
ListArrayParts {
dtype: self.dtype,
elements: self.elements,
offsets: self.offsets,
validity: self.validity,
}
}

/// Returns the offset at the given index from the list array.
///
/// Panics if the index is out of bounds.
Expand Down
1 change: 1 addition & 0 deletions vortex-array/src/arrays/list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

mod array;
pub use array::ListArray;
pub use array::ListArrayParts;

mod compute;

Expand Down
32 changes: 30 additions & 2 deletions vortex-array/src/arrays/listview/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::sync::Arc;
use num_traits::AsPrimitive;
use vortex_dtype::DType;
use vortex_dtype::IntegerPType;
use vortex_dtype::Nullability;
use vortex_dtype::match_each_integer_ptype;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;
Expand Down Expand Up @@ -124,6 +125,24 @@ pub struct ListViewArray {
pub(super) stats_set: ArrayStats,
}

pub struct ListViewArrayParts {
pub nullability: Nullability,

pub elements_dtype: Arc<DType>,

/// See `ListViewArray::elements`
pub elements: ArrayRef,

/// See `ListViewArray::offsets`
pub offsets: ArrayRef,

/// See `ListViewArray::sizes`
pub sizes: ArrayRef,

/// See `ListViewArray::validity`
pub validity: Validity,
}

impl ListViewArray {
/// Creates a new [`ListViewArray`].
///
Expand Down Expand Up @@ -319,8 +338,17 @@ impl ListViewArray {
.is_ok()
}

pub fn into_parts(self) -> (ArrayRef, ArrayRef, ArrayRef, Validity) {
(self.elements, self.offsets, self.sizes, self.validity)
pub fn into_parts(self) -> ListViewArrayParts {
let nullability = self.dtype.nullability();
let dtype = self.dtype.into_list_element_opt().vortex_expect("is list");
ListViewArrayParts {
nullability,
elements_dtype: dtype,
elements: self.elements,
offsets: self.offsets,
sizes: self.sizes,
validity: self.validity,
}
}

/// Returns the offset at the given index.
Expand Down
1 change: 1 addition & 0 deletions vortex-array/src/arrays/listview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

mod array;
pub use array::ListViewArray;
pub use array::ListViewArrayParts;

mod compute;

Expand Down
21 changes: 20 additions & 1 deletion vortex-array/src/arrays/struct_/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::sync::Arc;
use vortex_dtype::DType;
use vortex_dtype::FieldName;
use vortex_dtype::FieldNames;
use vortex_dtype::Nullability;
use vortex_dtype::StructFields;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;
Expand Down Expand Up @@ -148,6 +149,13 @@ pub struct StructArray {
pub(super) stats_set: ArrayStats,
}

pub struct StructArrayParts {
pub struct_fields: StructFields,
pub nullability: Nullability,
pub fields: Arc<[ArrayRef]>,
pub validity: Validity,
}

impl StructArray {
pub fn fields(&self) -> &Arc<[ArrayRef]> {
&self.fields
Expand Down Expand Up @@ -344,8 +352,19 @@ impl StructArray {
Ok(unsafe { Self::new_unchecked(fields, dtype, length, validity) })
}

pub fn into_parts(self) -> StructArrayParts {
let nullability = self.dtype.nullability();
let struct_fields = self.dtype.into_struct_fields();
StructArrayParts {
struct_fields,
nullability,
fields: self.fields,
validity: self.validity,
}
}

pub fn into_fields(self) -> Vec<ArrayRef> {
self.fields.to_vec()
self.into_parts().fields.to_vec()
}

pub fn from_fields<N: AsRef<str>>(items: &[(N, ArrayRef)]) -> VortexResult<Self> {
Expand Down
1 change: 1 addition & 0 deletions vortex-array/src/arrays/struct_/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

mod array;
pub use array::StructArray;
pub use array::StructArrayParts;
mod compute;

mod vtable;
Expand Down
17 changes: 17 additions & 0 deletions vortex-array/src/arrays/varbinview/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ pub struct VarBinViewArray {
pub(super) stats_set: ArrayStats,
}

pub struct VarBinViewArrayParts {
pub dtype: DType,
pub buffers: Arc<[ByteBuffer]>,
pub views: Buffer<BinaryView>,
pub validity: Validity,
}

impl VarBinViewArray {
/// Creates a new [`VarBinViewArray`].
///
Expand Down Expand Up @@ -262,6 +269,16 @@ impl VarBinViewArray {
Ok(())
}

/// Splits the array into owned parts
pub fn into_parts(self) -> VarBinViewArrayParts {
VarBinViewArrayParts {
dtype: self.dtype,
buffers: self.buffers,
views: self.views,
validity: self.validity,
}
}

/// Number of raw string data buffers held by this array.
pub fn nbuffers(&self) -> usize {
self.buffers.len()
Expand Down
1 change: 1 addition & 0 deletions vortex-array/src/arrays/varbinview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

mod array;
pub use array::VarBinViewArray;
pub use array::VarBinViewArrayParts;

mod accessor;
pub(crate) mod compact;
Expand Down
4 changes: 2 additions & 2 deletions vortex-array/src/arrow/compute/to_arrow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::compute::Options;
/// Warning: do not use this to convert a Vortex [`crate::stream::ArrayStream`] since each array
/// may have a different preferred Arrow type. Use [`to_arrow`] instead.
#[deprecated(note = "Use ArrowArrayExecutor::execute_arrow instead")]
#[allow(deprecated)]
#[expect(deprecated)]
pub fn to_arrow_preferred(array: &dyn Array) -> VortexResult<ArrowArrayRef> {
to_arrow_opts(array, &ToArrowOptions { arrow_type: None })
}
Expand All @@ -35,7 +35,7 @@ pub fn to_arrow(array: &dyn Array, arrow_type: &DataType) -> VortexResult<ArrowA
}

#[deprecated(note = "Use ArrowArrayExecutor::execute_arrow instead")]
#[allow(deprecated)]
#[expect(deprecated)]
pub fn to_arrow_opts(array: &dyn Array, options: &ToArrowOptions) -> VortexResult<ArrowArrayRef> {
let data_type = if let Some(data_type) = &options.arrow_type {
data_type.clone()
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/arrow/executor/byte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ where

let data = array.bytes().clone().into_arrow_buffer();

let null_buffer = to_arrow_null_buffer(array.validity(), array.len(), ctx)?;
let null_buffer = to_arrow_null_buffer(array.validity().clone(), array.len(), ctx)?;
Ok(Arc::new(unsafe {
GenericByteArray::<T>::new_unchecked(offsets, data, null_buffer)
}))
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/arrow/executor/byte_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn execute_varbinview_to_arrow<T: ByteViewType>(
.iter()
.map(|buffer| buffer.clone().into_arrow_buffer())
.collect();
let nulls = to_arrow_null_buffer(array.validity(), array.len(), ctx)?;
let nulls = to_arrow_null_buffer(array.validity().clone(), array.len(), ctx)?;

// SAFETY: our own VarBinView array is considered safe.
Ok(Arc::new(unsafe {
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/arrow/executor/fixed_size_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn list_to_list(
"Cannot convert FixedSizeListArray to non-nullable Arrow array when elements are nullable"
);

let null_buffer = to_arrow_null_buffer(array.validity(), array.len(), ctx)?;
let null_buffer = to_arrow_null_buffer(array.validity().clone(), array.len(), ctx)?;

Ok(Arc::new(arrow_array::FixedSizeListArray::new(
elements_field.clone(),
Expand Down
Loading
Loading