From 4d33a788bd8e08758e7fd4ccb325674d6be6aada Mon Sep 17 00:00:00 2001 From: Connor Tsui Date: Tue, 4 Nov 2025 10:03:49 -0500 Subject: [PATCH 1/3] move documentation around Signed-off-by: Connor Tsui --- vortex-vector/src/bool/mod.rs | 48 +++++++ vortex-vector/src/bool/vector.rs | 5 +- vortex-vector/src/bool/vector_mut.rs | 52 +------ vortex-vector/src/decimal/generic.rs | 7 +- vortex-vector/src/decimal/generic_mut.rs | 132 ------------------ vortex-vector/src/decimal/mod.rs | 127 ++++++++++++++++- vortex-vector/src/fixed_size_list/mod.rs | 78 +++++++++++ vortex-vector/src/fixed_size_list/vector.rs | 17 ++- .../src/fixed_size_list/vector_mut.rs | 78 ----------- vortex-vector/src/primitive/generic.rs | 5 - vortex-vector/src/primitive/generic_mut.rs | 85 ----------- vortex-vector/src/primitive/mod.rs | 81 ++++++++++- vortex-vector/src/struct_/mod.rs | 80 +++++++++++ vortex-vector/src/struct_/vector.rs | 6 +- vortex-vector/src/struct_/vector_mut.rs | 80 ----------- 15 files changed, 433 insertions(+), 448 deletions(-) diff --git a/vortex-vector/src/bool/mod.rs b/vortex-vector/src/bool/mod.rs index 0b5cdcad417..aedde4c2e5f 100644 --- a/vortex-vector/src/bool/mod.rs +++ b/vortex-vector/src/bool/mod.rs @@ -2,6 +2,54 @@ // SPDX-FileCopyrightText: Copyright the Vortex contributors //! Definition and implementation of [`BoolVector`] and [`BoolVectorMut`]. +//! +//! # Examples +//! +//! ## Extending and appending +//! +//! ``` +//! use vortex_vector::{BoolVectorMut, VectorMutOps}; +//! +//! let mut vec1 = BoolVectorMut::from_iter([true, false].map(Some)); +//! let vec2 = BoolVectorMut::from_iter([true, true].map(Some)).freeze(); +//! +//! // Extend from another vector. +//! vec1.extend_from_vector(&vec2); +//! assert_eq!(vec1.len(), 4); +//! +//! // Append null values. +//! vec1.append_nulls(2); +//! assert_eq!(vec1.len(), 6); +//! ``` +//! +//! ## Splitting and unsplitting +//! +//! ``` +//! use vortex_vector::{BoolVectorMut, VectorMutOps}; +//! +//! let mut vec = BoolVectorMut::from_iter([true, false, true, false, true].map(Some)); +//! +//! // Split the vector at index 3. +//! let mut second_half = vec.split_off(3); +//! assert_eq!(vec.len(), 3); +//! assert_eq!(second_half.len(), 2); +//! +//! // Rejoin the vectors. +//! vec.unsplit(second_half); +//! assert_eq!(vec.len(), 5); +//! ``` +//! +//! ## Converting to immutable +//! +//! ``` +//! use vortex_vector::{BoolVectorMut, VectorMutOps, VectorOps}; +//! +//! let mut vec = BoolVectorMut::from_iter([true, false, true].map(Some)); +//! +//! // Freeze into an immutable vector. +//! let immutable = vec.freeze(); +//! assert_eq!(immutable.len(), 3); +//! ``` mod vector; pub use vector::BoolVector; diff --git a/vortex-vector/src/bool/vector.rs b/vortex-vector/src/bool/vector.rs index 837577ced77..e292952aade 100644 --- a/vortex-vector/src/bool/vector.rs +++ b/vortex-vector/src/bool/vector.rs @@ -11,10 +11,7 @@ use crate::{BoolVectorMut, VectorOps}; /// An immutable vector of boolean values. /// -/// `BoolVector` can be considered a borrowed / frozen version of [`BoolVectorMut`], which is -/// created via the [`freeze`](crate::VectorMutOps::freeze) method. -/// -/// See the documentation for [`BoolVectorMut`] for more information. +/// Internally, this `BoolVector` is a wrapper around a [`BitBuffer`] and a validity mask. #[derive(Debug, Clone)] pub struct BoolVector { /// The bits that we use to represent booleans. diff --git a/vortex-vector/src/bool/vector_mut.rs b/vortex-vector/src/bool/vector_mut.rs index 30d1cefd182..effbc5a7bd3 100644 --- a/vortex-vector/src/bool/vector_mut.rs +++ b/vortex-vector/src/bool/vector_mut.rs @@ -11,57 +11,7 @@ use crate::{BoolVector, VectorMutOps, VectorOps}; /// A mutable vector of boolean values. /// -/// `BoolVectorMut` is the primary way to construct boolean vectors. It provides efficient methods -/// for building vectors incrementally before converting them to an immutable [`BoolVector`] using -/// the [`freeze`](crate::VectorMutOps::freeze) method. -/// -/// # Examples -/// -/// ## Extending and appending -/// -/// ``` -/// use vortex_vector::{BoolVectorMut, VectorMutOps}; -/// -/// let mut vec1 = BoolVectorMut::from_iter([true, false].map(Some)); -/// let vec2 = BoolVectorMut::from_iter([true, true].map(Some)).freeze(); -/// -/// // Extend from another vector. -/// vec1.extend_from_vector(&vec2); -/// assert_eq!(vec1.len(), 4); -/// -/// // Append null values. -/// vec1.append_nulls(2); -/// assert_eq!(vec1.len(), 6); -/// ``` -/// -/// ## Splitting and unsplitting -/// -/// ``` -/// use vortex_vector::{BoolVectorMut, VectorMutOps}; -/// -/// let mut vec = BoolVectorMut::from_iter([true, false, true, false, true].map(Some)); -/// -/// // Split the vector at index 3. -/// let mut second_half = vec.split_off(3); -/// assert_eq!(vec.len(), 3); -/// assert_eq!(second_half.len(), 2); -/// -/// // Rejoin the vectors. -/// vec.unsplit(second_half); -/// assert_eq!(vec.len(), 5); -/// ``` -/// -/// ## Converting to immutable -/// -/// ``` -/// use vortex_vector::{BoolVectorMut, VectorMutOps, VectorOps}; -/// -/// let mut vec = BoolVectorMut::from_iter([true, false, true].map(Some)); -/// -/// // Freeze into an immutable vector. -/// let immutable = vec.freeze(); -/// assert_eq!(immutable.len(), 3); -/// ``` +/// Internally, this `BoolVectorMut` is a wrapper around a [`BitBufferMut`] and a validity mask. #[derive(Debug, Clone)] pub struct BoolVectorMut { /// The mutable bits that we use to represent booleans. diff --git a/vortex-vector/src/decimal/generic.rs b/vortex-vector/src/decimal/generic.rs index f19fbfe745e..3c8beaa3d65 100644 --- a/vortex-vector/src/decimal/generic.rs +++ b/vortex-vector/src/decimal/generic.rs @@ -12,10 +12,11 @@ use crate::{DVectorMut, VectorOps}; /// An immutable vector of generic decimal values. /// -/// `DVector` can be considered a borrowed / frozen version of [`DVectorMut`], which is -/// created via the [`freeze`](crate::VectorMutOps::freeze) method. +/// `D` is bound by [`NativeDecimalType`], which can be one of the native integer types (`i8`, +/// `i16`, `i32`, `i64`, `i128`) or `i256`. `D` is used to store the decimal values. /// -/// See the documentation for [`DVectorMut`] for more information. +/// The decimal vector maintains a [`PrecisionScale`] that defines the precision (total number of +/// digits) and scale (digits after the decimal point) for all values in the vector. #[derive(Debug, Clone)] pub struct DVector { /// The precision and scale of each decimal in the decimal vector. diff --git a/vortex-vector/src/decimal/generic_mut.rs b/vortex-vector/src/decimal/generic_mut.rs index d3841676c86..914ad1ea7a9 100644 --- a/vortex-vector/src/decimal/generic_mut.rs +++ b/vortex-vector/src/decimal/generic_mut.rs @@ -22,139 +22,7 @@ use crate::{DVector, VectorMutOps, VectorOps}; /// modification to ensure values stay within the bounds defined by their precision and scale. /// This makes operations like "push" fallible, thus we have a [`try_push()`] method instead. /// -/// [`DVectorMut`] is the primary way to construct decimal vectors. It provides methods for -/// building vectors incrementally before converting them to an immutable [`DVector`] using -/// the [`freeze()`] method. -/// /// [`try_push()`]: Self::try_push -/// [`freeze()`]: crate::VectorMutOps::freeze -/// -/// # Examples -/// -/// ## Creating and building decimal vectors -/// -/// ``` -/// use vortex_dtype::{DecimalDType, PrecisionScale}; -/// use vortex_vector::{DVectorMut, VectorMutOps}; -/// -/// // Create a decimal vector with precision=9, scale=2 (e.g., up to 9999999.99). -/// let decimal_dtype = DecimalDType::new(9, 2); -/// let mut vec = DVectorMut::::with_capacity(&decimal_dtype, 5); -/// assert_eq!(vec.len(), 0); -/// assert!(vec.capacity() >= 5); -/// -/// // Values are stored as integers scaled by 10^scale. -/// // For scale=2: 123.45 is stored as 12345. -/// vec.try_push(12345).unwrap(); // Represents 123.45. -/// vec.try_push(9999).unwrap(); // Represents 99.99. -/// assert_eq!(vec.len(), 2); -/// -/// // Values that exceed precision will fail. -/// let too_large = 10_i32.pow(9); // Would represent 10000000.00. -/// assert!(vec.try_push(too_large).is_err()); -/// -/// // Create from buffers with validation. -/// use vortex_buffer::BufferMut; -/// use vortex_mask::MaskMut; -/// let elements = BufferMut::from_iter([100_i32, 200, 300]); // 1.00, 2.00, 3.00. -/// let validity = MaskMut::new_true(3); -/// let ps = PrecisionScale::::try_from(&decimal_dtype).unwrap(); -/// let decimal_vec = DVectorMut::new(ps, elements, validity); -/// assert_eq!(decimal_vec.len(), 3); -/// ``` -/// -/// ## Working with nulls and validity -/// -/// ``` -/// use vortex_buffer::BufferMut; -/// use vortex_dtype::{DecimalDType, PrecisionScale}; -/// use vortex_mask::MaskMut; -/// use vortex_vector::{DVectorMut, VectorMutOps}; -/// -/// // Create a decimal vector with nulls. -/// let decimal_dtype = DecimalDType::new(5, 2); // Up to 999.99. -/// let ps = PrecisionScale::::try_from(&decimal_dtype).unwrap(); -/// -/// // Create with some null values (validity mask: true = not null, false = null). -/// let elements = BufferMut::from_iter([1000_i32, 0, 2500, 0]); // 10.00, null, 25.00, null. -/// let mut validity = MaskMut::with_capacity(4); -/// validity.append_n(true, 1); // index 0: valid -/// validity.append_n(false, 1); // index 1: null -/// validity.append_n(true, 1); // index 2: valid -/// validity.append_n(false, 1); // index 3: null -/// let mut vec = DVectorMut::new(ps, elements, validity); -/// -/// // Check element access with nulls. -/// assert_eq!(vec.get(0), Some(&1000)); // 10.00. -/// assert_eq!(vec.get(1), None); // Null. -/// assert_eq!(vec.get(2), Some(&2500)); // 25.00. -/// -/// // Append null values. -/// vec.append_nulls(3); -/// assert_eq!(vec.len(), 7); -/// ``` -/// -/// ## Extending and manipulating vectors -/// -/// ``` -/// use vortex_dtype::DecimalDType; -/// use vortex_vector::{DVectorMut, VectorMutOps}; -/// -/// // Create two decimal vectors with scale=3 (3 decimal places). -/// let decimal_dtype = DecimalDType::new(10, 3); -/// let mut vec1 = DVectorMut::::with_capacity(&decimal_dtype, 10); -/// vec1.try_push(1234567).unwrap(); // 1234.567. -/// vec1.try_push(2345678).unwrap(); // 2345.678. -/// -/// let mut vec2 = DVectorMut::::with_capacity(&decimal_dtype, 10); -/// vec2.try_push(3456789).unwrap(); // 3456.789. -/// vec2.try_push(4567890).unwrap(); // 4567.890. -/// -/// // Extend from an immutable vector. -/// let immutable = vec2.freeze(); -/// vec1.extend_from_vector(&immutable); -/// assert_eq!(vec1.len(), 4); -/// -/// // Split vector at index 3. -/// let mut split = vec1.split_off(3); -/// assert_eq!(vec1.len(), 3); -/// assert_eq!(split.len(), 1); -/// -/// // Reserve capacity for future operations. -/// vec1.reserve(10); -/// assert!(vec1.capacity() >= 13); -/// -/// // Rejoin the vectors. -/// vec1.unsplit(split); -/// assert_eq!(vec1.len(), 4); -/// ``` -/// -/// ## Converting between mutable and immutable -/// -/// ``` -/// use vortex_dtype::DecimalDType; -/// use vortex_vector::{DVectorMut, VectorMutOps, VectorOps}; -/// -/// // Create a mutable decimal vector. -/// let decimal_dtype = DecimalDType::new(18, 6); // High precision with 6 decimal places. -/// let mut vec_mut = DVectorMut::::with_capacity(&decimal_dtype, 3); -/// vec_mut.try_push(1000000).unwrap(); // 1.000000. -/// vec_mut.try_push(2500000).unwrap(); // 2.500000. -/// vec_mut.try_push(3333333).unwrap(); // 3.333333. -/// -/// // Freeze into an immutable vector. -/// let vec_immutable = vec_mut.freeze(); -/// assert_eq!(vec_immutable.len(), 3); -/// -/// // Access elements from the immutable vector. -/// assert_eq!(vec_immutable.get(0), Some(&1000000)); -/// assert_eq!(vec_immutable.get(1), Some(&2500000)); -/// -/// // Can also convert immutable back to mutable using try_into_mut. -/// // Note: This may fail if the buffer is shared. -/// // let vec_mut_again = vec_immutable.try_into_mut().unwrap(); -/// // assert_eq!(vec_mut_again.len(), 3); -/// ``` #[derive(Debug, Clone)] pub struct DVectorMut { /// The precision and scale of each decimal in the decimal vector. diff --git a/vortex-vector/src/decimal/mod.rs b/vortex-vector/src/decimal/mod.rs index 350c1bcd172..cbf7e2faa80 100644 --- a/vortex-vector/src/decimal/mod.rs +++ b/vortex-vector/src/decimal/mod.rs @@ -10,7 +10,132 @@ //! [`DVector`]s. There are several macros defined in this crate to make working with these //! primitive vector types easier. //! -//! See the documentation for [`DVectorMut`] for more information. +//! # Examples +//! +//! ## Creating and building decimal vectors +//! +//! ``` +//! use vortex_dtype::{DecimalDType, PrecisionScale}; +//! use vortex_vector::{DVectorMut, VectorMutOps}; +//! +//! // Create a decimal vector with precision=9, scale=2 (e.g., up to 9999999.99). +//! let decimal_dtype = DecimalDType::new(9, 2); +//! let mut vec = DVectorMut::::with_capacity(&decimal_dtype, 5); +//! assert_eq!(vec.len(), 0); +//! assert!(vec.capacity() >= 5); +//! +//! // Values are stored as integers scaled by 10^scale. +//! // For scale=2: 123.45 is stored as 12345. +//! vec.try_push(12345).unwrap(); // Represents 123.45. +//! vec.try_push(9999).unwrap(); // Represents 99.99. +//! assert_eq!(vec.len(), 2); +//! +//! // Values that exceed precision will fail. +//! let too_large = 10_i32.pow(9); // Would represent 10000000.00. +//! assert!(vec.try_push(too_large).is_err()); +//! +//! // Create from buffers with validation. +//! use vortex_buffer::BufferMut; +//! use vortex_mask::MaskMut; +//! let elements = BufferMut::from_iter([100_i32, 200, 300]); // 1.00, 2.00, 3.00. +//! let validity = MaskMut::new_true(3); +//! let ps = PrecisionScale::::try_from(&decimal_dtype).unwrap(); +//! let decimal_vec = DVectorMut::new(ps, elements, validity); +//! assert_eq!(decimal_vec.len(), 3); +//! ``` +//! +//! ## Working with nulls and validity +//! +//! ``` +//! use vortex_buffer::BufferMut; +//! use vortex_dtype::{DecimalDType, PrecisionScale}; +//! use vortex_mask::MaskMut; +//! use vortex_vector::{DVectorMut, VectorMutOps}; +//! +//! // Create a decimal vector with nulls. +//! let decimal_dtype = DecimalDType::new(5, 2); // Up to 999.99. +//! let ps = PrecisionScale::::try_from(&decimal_dtype).unwrap(); +//! +//! // Create with some null values (validity mask: true = not null, false = null). +//! let elements = BufferMut::from_iter([1000_i32, 0, 2500, 0]); // 10.00, null, 25.00, null. +//! let mut validity = MaskMut::with_capacity(4); +//! validity.append_n(true, 1); // index 0: valid +//! validity.append_n(false, 1); // index 1: null +//! validity.append_n(true, 1); // index 2: valid +//! validity.append_n(false, 1); // index 3: null +//! let mut vec = DVectorMut::new(ps, elements, validity); +//! +//! // Check element access with nulls. +//! assert_eq!(vec.get(0), Some(&1000)); // 10.00. +//! assert_eq!(vec.get(1), None); // Null. +//! assert_eq!(vec.get(2), Some(&2500)); // 25.00. +//! +//! // Append null values. +//! vec.append_nulls(3); +//! assert_eq!(vec.len(), 7); +//! ``` +//! +//! ## Extending and manipulating vectors +//! +//! ``` +//! use vortex_dtype::DecimalDType; +//! use vortex_vector::{DVectorMut, VectorMutOps}; +//! +//! // Create two decimal vectors with scale=3 (3 decimal places). +//! let decimal_dtype = DecimalDType::new(10, 3); +//! let mut vec1 = DVectorMut::::with_capacity(&decimal_dtype, 10); +//! vec1.try_push(1234567).unwrap(); // 1234.567. +//! vec1.try_push(2345678).unwrap(); // 2345.678. +//! +//! let mut vec2 = DVectorMut::::with_capacity(&decimal_dtype, 10); +//! vec2.try_push(3456789).unwrap(); // 3456.789. +//! vec2.try_push(4567890).unwrap(); // 4567.890. +//! +//! // Extend from an immutable vector. +//! let immutable = vec2.freeze(); +//! vec1.extend_from_vector(&immutable); +//! assert_eq!(vec1.len(), 4); +//! +//! // Split vector at index 3. +//! let mut split = vec1.split_off(3); +//! assert_eq!(vec1.len(), 3); +//! assert_eq!(split.len(), 1); +//! +//! // Reserve capacity for future operations. +//! vec1.reserve(10); +//! assert!(vec1.capacity() >= 13); +//! +//! // Rejoin the vectors. +//! vec1.unsplit(split); +//! assert_eq!(vec1.len(), 4); +//! ``` +//! +//! ## Converting between mutable and immutable +//! +//! ``` +//! use vortex_dtype::DecimalDType; +//! use vortex_vector::{DVectorMut, VectorMutOps, VectorOps}; +//! +//! // Create a mutable decimal vector. +//! let decimal_dtype = DecimalDType::new(18, 6); // High precision with 6 decimal places. +//! let mut vec_mut = DVectorMut::::with_capacity(&decimal_dtype, 3); +//! vec_mut.try_push(1000000).unwrap(); // 1.000000. +//! vec_mut.try_push(2500000).unwrap(); // 2.500000. +//! vec_mut.try_push(3333333).unwrap(); // 3.333333. +//! +//! // Freeze into an immutable vector. +//! let vec_immutable = vec_mut.freeze(); +//! assert_eq!(vec_immutable.len(), 3); +//! +//! // Access elements from the immutable vector. +//! assert_eq!(vec_immutable.get(0), Some(&1000000)); +//! assert_eq!(vec_immutable.get(1), Some(&2500000)); +//! +//! // Can also convert immutable back to mutable using try_into_mut. +//! // Note: This may fail if the buffer is shared. +//! // let vec_mut_again = vec_immutable.try_into_mut().unwrap(); +//! // assert_eq!(vec_mut_again.len(), 3); +//! ``` mod generic; pub use generic::DVector; diff --git a/vortex-vector/src/fixed_size_list/mod.rs b/vortex-vector/src/fixed_size_list/mod.rs index 561e69a2ac7..ba51a6d4827 100644 --- a/vortex-vector/src/fixed_size_list/mod.rs +++ b/vortex-vector/src/fixed_size_list/mod.rs @@ -2,6 +2,84 @@ // SPDX-FileCopyrightText: Copyright the Vortex contributors //! Definition and implementation of [`FixedSizeListVector`] and [`FixedSizeListVectorMut`]. +//! +//! # Examples +//! +//! ## Working with nulls +//! +//! Nulls can exist at two levels: entire lists can be null, or individual elements within lists can +//! be null. +//! +//! ``` +//! use vortex_vector::{FixedSizeListVectorMut, PVectorMut, VectorMut, VectorMutOps}; +//! use vortex_mask::{Mask, MaskMut}; +//! +//! // Create elements with some null values. +//! // This will be 9 elements total: [1, null, 3, 4, 5, null, null, 8, 9] +//! let mut elements = PVectorMut::::from_iter([ +//! Some(1), None, Some(3), // First list +//! Some(4), Some(5), None, // Second list +//! None, Some(8), Some(9), // Third list +//! ]); +//! +//! // Create validity for the lists themselves. +//! // All lists are valid in this example. +//! let validity = MaskMut::new_true(3); +//! +//! let mut fsl_vec = FixedSizeListVectorMut::new( +//! Box::new(elements.into()), +//! 3, // Each list has 3 elements +//! validity, +//! ); +//! +//! assert_eq!(fsl_vec.len(), 3); +//! assert_eq!(fsl_vec.list_size(), 3); +//! +//! // Can also append null lists. +//! fsl_vec.append_nulls(2); +//! assert_eq!(fsl_vec.len(), 5); +//! ``` +//! +//! ## Working with [`split_off()`] and [`unsplit()`] +//! +//! [`split_off()`]: crate::VectorMutOps::split_off +//! [`unsplit()`]: crate::VectorMutOps::unsplit +//! +//! ``` +//! use vortex_vector::{FixedSizeListVectorMut, PVectorMut, VectorMut, VectorMutOps}; +//! use vortex_mask::MaskMut; +//! +//! // Create a vector with 6 lists, each containing 2 integers. +//! let elements = PVectorMut::::from_iter([ +//! 1, 2, // List 0 +//! 3, 4, // List 1 +//! 5, 6, // List 2 +//! 7, 8, // List 3 +//! 9, 10, // List 4 +//! 11, 12, // List 5 +//! ]); +//! +//! let mut fsl_vec = FixedSizeListVectorMut::new( +//! Box::new(elements.into()), +//! 2, // Each list has 2 elements +//! MaskMut::new_true(6), +//! ); +//! +//! // Split at position 4 (keeping first 4 lists, splitting off last 2). +//! let second_part = fsl_vec.split_off(4); +//! +//! assert_eq!(fsl_vec.len(), 4); +//! assert_eq!(second_part.len(), 2); +//! +//! // The elements are also split accordingly. +//! assert_eq!(fsl_vec.elements().len(), 8); // 4 lists * 2 elements +//! assert_eq!(second_part.elements().len(), 4); // 2 lists * 2 elements +//! +//! // Rejoin the parts. +//! fsl_vec.unsplit(second_part); +//! assert_eq!(fsl_vec.len(), 6); +//! assert_eq!(fsl_vec.elements().len(), 12); +//! ``` mod vector; pub use vector::FixedSizeListVector; diff --git a/vortex-vector/src/fixed_size_list/vector.rs b/vortex-vector/src/fixed_size_list/vector.rs index 10e042f5ce2..1608b74acd9 100644 --- a/vortex-vector/src/fixed_size_list/vector.rs +++ b/vortex-vector/src/fixed_size_list/vector.rs @@ -12,11 +12,20 @@ use crate::{FixedSizeListVectorMut, Vector, VectorOps}; /// An immutable vector of fixed-size lists. /// -/// `FixedSizeListVector` can be considered a borrowed / frozen version of -/// [`FixedSizeListVectorMut`], which is created via the [`freeze`](crate::VectorMutOps::freeze) -/// method. +/// `FixedSizeList` vectors can mostly be thought of as a wrapper around other vectors that "groups" +/// a fixed number of elements together for each list scalar. /// -/// See the documentation for [`FixedSizeListVectorMut`] for more information. +/// More specifically, each list scalar in the vector has the same number of elements (fixed size), +/// with all list elements stored contiguously in a child [`Vector`]. +/// +/// Note that the validity mask tracks which lists are null, not which individual elements are null. +/// +/// # Structure +/// +/// For a vector of `n` lists each with size `list_size`: +/// - The `elements` vector has length `n * list_size` +/// - The `validity` mask has length `n` +/// - Each list `i` occupies `elements[i * list_size..(i+1) * list_size] #[derive(Debug, Clone)] pub struct FixedSizeListVector { /// The child vector of elements. diff --git a/vortex-vector/src/fixed_size_list/vector_mut.rs b/vortex-vector/src/fixed_size_list/vector_mut.rs index 70f33ec008f..dcc387324ca 100644 --- a/vortex-vector/src/fixed_size_list/vector_mut.rs +++ b/vortex-vector/src/fixed_size_list/vector_mut.rs @@ -27,84 +27,6 @@ use crate::{FixedSizeListVector, VectorMut, VectorMutOps, match_vector_pair}; /// - The `elements` vector has length `n * list_size` /// - The `validity` mask has length `n` /// - Each list `i` occupies `elements[i * list_size..(i+1) * list_size] -/// -/// # Examples -/// -/// ## Working with nulls -/// -/// Nulls can exist at two levels: entire lists can be null, or individual elements within lists can -/// be null. -/// -/// ``` -/// use vortex_vector::{FixedSizeListVectorMut, PVectorMut, VectorMut, VectorMutOps}; -/// use vortex_mask::{Mask, MaskMut}; -/// -/// // Create elements with some null values. -/// // This will be 9 elements total: [1, null, 3, 4, 5, null, null, 8, 9] -/// let mut elements = PVectorMut::::from_iter([ -/// Some(1), None, Some(3), // First list -/// Some(4), Some(5), None, // Second list -/// None, Some(8), Some(9), // Third list -/// ]); -/// -/// // Create validity for the lists themselves. -/// // All lists are valid in this example. -/// let validity = MaskMut::new_true(3); -/// -/// let mut fsl_vec = FixedSizeListVectorMut::new( -/// Box::new(elements.into()), -/// 3, // Each list has 3 elements -/// validity, -/// ); -/// -/// assert_eq!(fsl_vec.len(), 3); -/// assert_eq!(fsl_vec.list_size(), 3); -/// -/// // Can also append null lists. -/// fsl_vec.append_nulls(2); -/// assert_eq!(fsl_vec.len(), 5); -/// ``` -/// -/// ## Working with [`split_off()`] and [`unsplit()`] -/// -/// [`split_off()`]: VectorMutOps::split_off -/// [`unsplit()`]: VectorMutOps::unsplit -/// -/// ``` -/// use vortex_vector::{FixedSizeListVectorMut, PVectorMut, VectorMut, VectorMutOps}; -/// use vortex_mask::MaskMut; -/// -/// // Create a vector with 6 lists, each containing 2 integers. -/// let elements = PVectorMut::::from_iter([ -/// 1, 2, // List 0 -/// 3, 4, // List 1 -/// 5, 6, // List 2 -/// 7, 8, // List 3 -/// 9, 10, // List 4 -/// 11, 12, // List 5 -/// ]); -/// -/// let mut fsl_vec = FixedSizeListVectorMut::new( -/// Box::new(elements.into()), -/// 2, // Each list has 2 elements -/// MaskMut::new_true(6), -/// ); -/// -/// // Split at position 4 (keeping first 4 lists, splitting off last 2). -/// let second_part = fsl_vec.split_off(4); -/// -/// assert_eq!(fsl_vec.len(), 4); -/// assert_eq!(second_part.len(), 2); -/// -/// // The elements are also split accordingly. -/// assert_eq!(fsl_vec.elements().len(), 8); // 4 lists * 2 elements -/// assert_eq!(second_part.elements().len(), 4); // 2 lists * 2 elements -/// -/// // Rejoin the parts. -/// fsl_vec.unsplit(second_part); -/// assert_eq!(fsl_vec.len(), 6); -/// assert_eq!(fsl_vec.elements().len(), 12); -/// ``` #[derive(Debug, Clone)] pub struct FixedSizeListVectorMut { /// The mutable child vector of elements. diff --git a/vortex-vector/src/primitive/generic.rs b/vortex-vector/src/primitive/generic.rs index 3eb0011d429..5277dc82de1 100644 --- a/vortex-vector/src/primitive/generic.rs +++ b/vortex-vector/src/primitive/generic.rs @@ -14,11 +14,6 @@ use crate::{PVectorMut, VectorOps}; /// /// `T` is expected to be bound by [`NativePType`], which templates an internal [`Buffer`] that /// stores the elements of the vector. -/// -/// `PVector` can be considered a borrowed / frozen version of [`PVectorMut`], which is -/// created via the [`freeze`](crate::VectorMutOps::freeze) method. -/// -/// See the documentation for [`PVectorMut`] for more information. #[derive(Debug, Clone)] pub struct PVector { /// The buffer representing the vector elements. diff --git a/vortex-vector/src/primitive/generic_mut.rs b/vortex-vector/src/primitive/generic_mut.rs index 860a88c0db3..9897ad27751 100644 --- a/vortex-vector/src/primitive/generic_mut.rs +++ b/vortex-vector/src/primitive/generic_mut.rs @@ -14,91 +14,6 @@ use crate::{PVector, VectorMutOps, VectorOps}; /// /// `T` is expected to be bound by [`NativePType`], which templates an internal [`BufferMut`] /// that stores the elements of the vector. -/// -/// [`PVectorMut`] is the primary way to construct primitive vectors. It provides efficient -/// methods for building vectors incrementally before converting them to an immutable [`PVector`] -/// using the [`freeze`](crate::VectorMutOps::freeze) method. -/// -/// # Examples -/// -/// ## Creating and building a vector -/// -/// ``` -/// use vortex_vector::{PVectorMut, VectorMutOps}; -/// -/// // Create with initial capacity for i32 values. -/// let mut vec = PVectorMut::::with_capacity(10); -/// assert_eq!(vec.len(), 0); -/// assert!(vec.capacity() >= 10); -/// -/// // Create from an iterator of optional values. -/// let mut vec = PVectorMut::::from_iter([Some(1), None, Some(3)]); -/// assert_eq!(vec.len(), 3); -/// -/// // Works with different primitive types. -/// let mut f64_vec = PVectorMut::::from_iter([1.5, 2.5, 3.5].map(Some)); -/// assert_eq!(f64_vec.len(), 3); -/// ``` -/// -/// ## Extending and appending -/// -/// ``` -/// use vortex_vector::{PVectorMut, VectorMutOps}; -/// -/// let mut vec1 = PVectorMut::::from_iter([1, 2].map(Some)); -/// let vec2 = PVectorMut::::from_iter([3, 4].map(Some)).freeze(); -/// -/// // Extend from another vector. -/// vec1.extend_from_vector(&vec2); -/// assert_eq!(vec1.len(), 4); -/// -/// // Append null values. -/// vec1.append_nulls(2); -/// assert_eq!(vec1.len(), 6); -/// ``` -/// -/// ## Splitting and unsplitting -/// -/// ``` -/// use vortex_vector::{PVectorMut, VectorMutOps}; -/// -/// let mut vec = PVectorMut::::from_iter([10, 20, 30, 40, 50].map(Some)); -/// -/// // Split the vector at index 3. -/// let mut second_half = vec.split_off(3); -/// assert_eq!(vec.len(), 3); -/// assert_eq!(second_half.len(), 2); -/// -/// // Rejoin the vectors. -/// vec.unsplit(second_half); -/// assert_eq!(vec.len(), 5); -/// ``` -/// -/// ## Working with nulls -/// -/// ``` -/// use vortex_vector::{PVectorMut, VectorMutOps}; -/// -/// // Create a vector with some null values. -/// let mut vec = PVectorMut::::from_iter([Some(100), None, Some(200), None]); -/// assert_eq!(vec.len(), 4); -/// -/// // Add more nulls. -/// vec.append_nulls(3); -/// assert_eq!(vec.len(), 7); -/// ``` -/// -/// ## Converting to immutable -/// -/// ``` -/// use vortex_vector::{PVectorMut, VectorMutOps, VectorOps}; -/// -/// let mut vec = PVectorMut::::from_iter([1.0, 2.0, 3.0].map(Some)); -/// -/// // Freeze into an immutable vector. -/// let immutable = vec.freeze(); -/// assert_eq!(immutable.len(), 3); -/// ``` #[derive(Debug, Clone)] pub struct PVectorMut { /// The mutable buffer representing the vector elements. diff --git a/vortex-vector/src/primitive/mod.rs b/vortex-vector/src/primitive/mod.rs index 315b1ae1aa2..356c80d7be6 100644 --- a/vortex-vector/src/primitive/mod.rs +++ b/vortex-vector/src/primitive/mod.rs @@ -11,7 +11,86 @@ //! [`PVector`]s. There are several macros defined in this crate to make working with these //! primitive vector types easier. //! -//! See the documentation for [`PVectorMut`] for more information. +//! # Examples +//! +//! ## Creating and building a vector +//! +//! ``` +//! use vortex_vector::{PVectorMut, VectorMutOps}; +//! +//! // Create with initial capacity for i32 values. +//! let mut vec = PVectorMut::::with_capacity(10); +//! assert_eq!(vec.len(), 0); +//! assert!(vec.capacity() >= 10); +//! +//! // Create from an iterator of optional values. +//! let mut vec = PVectorMut::::from_iter([Some(1), None, Some(3)]); +//! assert_eq!(vec.len(), 3); +//! +//! // Works with different primitive types. +//! let mut f64_vec = PVectorMut::::from_iter([1.5, 2.5, 3.5].map(Some)); +//! assert_eq!(f64_vec.len(), 3); +//! ``` +//! +//! ## Extending and appending +//! +//! ``` +//! use vortex_vector::{PVectorMut, VectorMutOps}; +//! +//! let mut vec1 = PVectorMut::::from_iter([1, 2].map(Some)); +//! let vec2 = PVectorMut::::from_iter([3, 4].map(Some)).freeze(); +//! +//! // Extend from another vector. +//! vec1.extend_from_vector(&vec2); +//! assert_eq!(vec1.len(), 4); +//! +//! // Append null values. +//! vec1.append_nulls(2); +//! assert_eq!(vec1.len(), 6); +//! ``` +//! +//! ## Splitting and unsplitting +//! +//! ``` +//! use vortex_vector::{PVectorMut, VectorMutOps}; +//! +//! let mut vec = PVectorMut::::from_iter([10, 20, 30, 40, 50].map(Some)); +//! +//! // Split the vector at index 3. +//! let mut second_half = vec.split_off(3); +//! assert_eq!(vec.len(), 3); +//! assert_eq!(second_half.len(), 2); +//! +//! // Rejoin the vectors. +//! vec.unsplit(second_half); +//! assert_eq!(vec.len(), 5); +//! ``` +//! +//! ## Working with nulls +//! +//! ``` +//! use vortex_vector::{PVectorMut, VectorMutOps}; +//! +//! // Create a vector with some null values. +//! let mut vec = PVectorMut::::from_iter([Some(100), None, Some(200), None]); +//! assert_eq!(vec.len(), 4); +//! +//! // Add more nulls. +//! vec.append_nulls(3); +//! assert_eq!(vec.len(), 7); +//! ``` +//! +//! ## Converting to immutable +//! +//! ``` +//! use vortex_vector::{PVectorMut, VectorMutOps, VectorOps}; +//! +//! let mut vec = PVectorMut::::from_iter([1.0, 2.0, 3.0].map(Some)); +//! +//! // Freeze into an immutable vector. +//! let immutable = vec.freeze(); +//! assert_eq!(immutable.len(), 3); +//! ``` //! //! [`f16`]: vortex_dtype::half::f16 diff --git a/vortex-vector/src/struct_/mod.rs b/vortex-vector/src/struct_/mod.rs index ae6ff7b91bd..cba8cd6c630 100644 --- a/vortex-vector/src/struct_/mod.rs +++ b/vortex-vector/src/struct_/mod.rs @@ -2,6 +2,86 @@ // SPDX-FileCopyrightText: Copyright the Vortex contributors //! Definition and implementation of [`StructVector`] and [`StructVectorMut`]. +//! +//! # Examples +//! +//! ## Creating a [`StructVector`] and [`StructVectorMut`] +//! +//! ``` +//! use vortex_vector::{ +//! BoolVectorMut, NullVectorMut, PVectorMut, StructVectorMut, VectorMut, VectorMutOps, +//! }; +//! use vortex_mask::MaskMut; +//! +//! // Create a struct with three fields: nulls, booleans, and integers. +//! let fields = Box::new([ +//! NullVectorMut::new(3).into(), +//! BoolVectorMut::from_iter([true, false, true]).into(), +//! PVectorMut::::from_iter([10, 20, 30]).into(), +//! ]); +//! +//! let mut struct_vec = StructVectorMut::new(fields, MaskMut::new_true(3)); +//! assert_eq!(struct_vec.len(), 3); +//! ``` +//! +//! ## Working with [`split_off()`] and [`unsplit()`] +//! +//! [`split_off()`]: crate::VectorMutOps::split_off +//! [`unsplit()`]: crate::VectorMutOps::unsplit +//! +//! ``` +//! use vortex_vector::{ +//! BoolVectorMut, NullVectorMut, PVectorMut, StructVectorMut, VectorMut, VectorMutOps, +//! }; +//! use vortex_mask::MaskMut; +//! +//! let fields = Box::new([ +//! NullVectorMut::new(6).into(), +//! PVectorMut::::from_iter([1, 2, 3, 4, 5, 6]).into(), +//! ]); +//! +//! let mut struct_vec = StructVectorMut::new(fields, MaskMut::new_true(6)); +//! +//! // Split at position 4. +//! let second_part = struct_vec.split_off(4); +//! +//! assert_eq!(struct_vec.len(), 4); +//! assert_eq!(second_part.len(), 2); +//! +//! // Rejoin the parts. +//! struct_vec.unsplit(second_part); +//! assert_eq!(struct_vec.len(), 6); +//! ``` +//! +//! ## Accessing field values +//! +//! ``` +//! use vortex_vector::{ +//! BoolVectorMut, NullVectorMut, PVectorMut, StructVectorMut, VectorMut, VectorMutOps, +//! }; +//! use vortex_mask::MaskMut; +//! use vortex_dtype::PTypeDowncast; +//! +//! let fields = Box::new([ +//! NullVectorMut::new(3).into(), +//! BoolVectorMut::from_iter([true, false, true]).into(), +//! PVectorMut::::from_iter([10, 20, 30]).into(), +//! ]); +//! +//! let struct_vec = StructVectorMut::new(fields, MaskMut::new_true(3)); +//! +//! // Access the boolean field vector (field index 1). +//! if let VectorMut::Bool(bool_vec) = struct_vec.fields()[1].clone() { +//! let values: Vec<_> = bool_vec.into_iter().map(|v| v.unwrap()).collect(); +//! assert_eq!(values, vec![true, false, true]); +//! } +//! +//! // Access the integer field column (field index 2). +//! if let VectorMut::Primitive(prim_vec) = struct_vec.fields()[2].clone() { +//! let values: Vec<_> = prim_vec.into_i32().into_iter().map(|v| v.unwrap()).collect(); +//! assert_eq!(values, vec![10, 20, 30]); +//! } +//! ``` mod vector; pub use vector::StructVector; diff --git a/vortex-vector/src/struct_/vector.rs b/vortex-vector/src/struct_/vector.rs index 494131a3a91..5ed22ce5212 100644 --- a/vortex-vector/src/struct_/vector.rs +++ b/vortex-vector/src/struct_/vector.rs @@ -12,10 +12,8 @@ use crate::{StructVectorMut, Vector, VectorMutOps, VectorOps}; /// An immutable vector of struct values. /// -/// `StructVector` can be considered a borrowed / frozen version of [`StructVectorMut`], which is -/// created via the [`freeze`](crate::VectorMutOps::freeze) method. -/// -/// See the documentation for [`StructVectorMut`] for more information. +/// Struct values are stored column-wise in the vector, so values in the same field are stored next +/// to each other (rather than values in the same struct stored next to each other). #[derive(Debug, Clone)] pub struct StructVector { /// The fields of the `StructVector`, each stored column-wise as a [`Vector`]. diff --git a/vortex-vector/src/struct_/vector_mut.rs b/vortex-vector/src/struct_/vector_mut.rs index c81ce5b34f2..99141befe63 100644 --- a/vortex-vector/src/struct_/vector_mut.rs +++ b/vortex-vector/src/struct_/vector_mut.rs @@ -15,86 +15,6 @@ use crate::{StructVector, Vector, VectorMut, VectorMutOps, VectorOps, match_vect /// /// Struct values are stored column-wise in the vector, so values in the same field are stored next /// to each other (rather than values in the same struct stored next to each other). -/// -/// # Examples -/// -/// ## Creating a [`StructVector`] and [`StructVectorMut`] -/// -/// ``` -/// use vortex_vector::{ -/// BoolVectorMut, NullVectorMut, PVectorMut, StructVectorMut, VectorMut, VectorMutOps, -/// }; -/// use vortex_mask::MaskMut; -/// -/// // Create a struct with three fields: nulls, booleans, and integers. -/// let fields = Box::new([ -/// NullVectorMut::new(3).into(), -/// BoolVectorMut::from_iter([true, false, true]).into(), -/// PVectorMut::::from_iter([10, 20, 30]).into(), -/// ]); -/// -/// let mut struct_vec = StructVectorMut::new(fields, MaskMut::new_true(3)); -/// assert_eq!(struct_vec.len(), 3); -/// ``` -/// -/// ## Working with [`split_off()`] and [`unsplit()`] -/// -/// [`split_off()`]: VectorMutOps::split_off -/// [`unsplit()`]: VectorMutOps::unsplit -/// -/// ``` -/// use vortex_vector::{ -/// BoolVectorMut, NullVectorMut, PVectorMut, StructVectorMut, VectorMut, VectorMutOps, -/// }; -/// use vortex_mask::MaskMut; -/// -/// let fields = Box::new([ -/// NullVectorMut::new(6).into(), -/// PVectorMut::::from_iter([1, 2, 3, 4, 5, 6]).into(), -/// ]); -/// -/// let mut struct_vec = StructVectorMut::new(fields, MaskMut::new_true(6)); -/// -/// // Split at position 4. -/// let second_part = struct_vec.split_off(4); -/// -/// assert_eq!(struct_vec.len(), 4); -/// assert_eq!(second_part.len(), 2); -/// -/// // Rejoin the parts. -/// struct_vec.unsplit(second_part); -/// assert_eq!(struct_vec.len(), 6); -/// ``` -/// -/// ## Accessing field values -/// -/// ``` -/// use vortex_vector::{ -/// BoolVectorMut, NullVectorMut, PVectorMut, StructVectorMut, VectorMut, VectorMutOps, -/// }; -/// use vortex_mask::MaskMut; -/// use vortex_dtype::PTypeDowncast; -/// -/// let fields = Box::new([ -/// NullVectorMut::new(3).into(), -/// BoolVectorMut::from_iter([true, false, true]).into(), -/// PVectorMut::::from_iter([10, 20, 30]).into(), -/// ]); -/// -/// let struct_vec = StructVectorMut::new(fields, MaskMut::new_true(3)); -/// -/// // Access the boolean field vector (field index 1). -/// if let VectorMut::Bool(bool_vec) = struct_vec.fields()[1].clone() { -/// let values: Vec<_> = bool_vec.into_iter().map(|v| v.unwrap()).collect(); -/// assert_eq!(values, vec![true, false, true]); -/// } -/// -/// // Access the integer field column (field index 2). -/// if let VectorMut::Primitive(prim_vec) = struct_vec.fields()[2].clone() { -/// let values: Vec<_> = prim_vec.into_i32().into_iter().map(|v| v.unwrap()).collect(); -/// assert_eq!(values, vec![10, 20, 30]); -/// } -/// ``` #[derive(Debug, Clone)] pub struct StructVectorMut { /// The (owned) fields of the `StructVectorMut`, each stored column-wise as a [`VectorMut`]. From afc818428e82635fc9eedfabd9d066c9b81b3d86 Mon Sep 17 00:00:00 2001 From: Connor Tsui Date: Tue, 4 Nov 2025 10:38:15 -0500 Subject: [PATCH 2/3] change module granularity of vectors Signed-off-by: Connor Tsui --- encodings/sequence/src/operator.rs | 3 +- .../src/arrays/bool/vtable/operator.rs | 2 +- vortex-array/src/arrays/null/mod.rs | 2 +- .../src/arrays/primitive/array/conversion.rs | 5 +- .../src/arrays/primitive/vtable/operator.rs | 2 +- .../src/arrays/struct_/vtable/operator.rs | 3 +- vortex-array/src/compute/arrays/arithmetic.rs | 2 +- .../src/compute/arrays/is_not_null.rs | 3 +- vortex-array/src/compute/arrays/is_null.rs | 3 +- vortex-array/src/compute/arrays/logical.rs | 2 +- vortex-compute/src/arithmetic/pvector.rs | 6 ++- .../src/arithmetic/pvector_checked.rs | 6 ++- vortex-compute/src/arrow/binaryview.rs | 2 +- vortex-compute/src/arrow/bool.rs | 2 +- vortex-compute/src/arrow/decimal.rs | 2 +- vortex-compute/src/arrow/fixed_size_list.rs | 2 +- vortex-compute/src/arrow/null.rs | 3 +- vortex-compute/src/arrow/primitive.rs | 3 +- vortex-compute/src/arrow/struct_.rs | 3 +- vortex-compute/src/comparison/bool.rs | 3 +- vortex-compute/src/comparison/pvector.rs | 4 +- vortex-compute/src/filter/bool.rs | 3 +- vortex-compute/src/logical/and.rs | 5 +- vortex-compute/src/logical/and_kleene.rs | 5 +- vortex-compute/src/logical/and_not.rs | 5 +- vortex-compute/src/logical/not.rs | 5 +- vortex-compute/src/logical/or.rs | 5 +- vortex-compute/src/logical/or_kleene.rs | 5 +- vortex-compute/src/mask/mod.rs | 13 +++-- vortex-vector/src/binaryview/types.rs | 3 +- vortex-vector/src/binaryview/vector.rs | 3 +- vortex-vector/src/binaryview/vector_mut.rs | 3 +- vortex-vector/src/bool/iter.rs | 3 +- vortex-vector/src/bool/vector.rs | 3 +- vortex-vector/src/bool/vector_mut.rs | 3 +- vortex-vector/src/decimal/generic.rs | 3 +- vortex-vector/src/decimal/generic_mut.rs | 3 +- vortex-vector/src/decimal/macros.rs | 39 ++++++++------ vortex-vector/src/decimal/vector.rs | 4 +- vortex-vector/src/decimal/vector_mut.rs | 4 +- vortex-vector/src/fixed_size_list/vector.rs | 6 ++- .../src/fixed_size_list/vector_mut.rs | 6 ++- vortex-vector/src/lib.rs | 22 +++----- vortex-vector/src/null/vector.rs | 3 +- vortex-vector/src/null/vector_mut.rs | 3 +- vortex-vector/src/ops.rs | 2 +- vortex-vector/src/primitive/generic.rs | 3 +- vortex-vector/src/primitive/generic_mut.rs | 3 +- .../src/primitive/generic_mut_impl.rs | 7 +-- vortex-vector/src/primitive/iter.rs | 3 +- vortex-vector/src/primitive/macros.rs | 52 +++++++++---------- vortex-vector/src/primitive/vector.rs | 3 +- vortex-vector/src/primitive/vector_mut.rs | 3 +- vortex-vector/src/private.rs | 7 +++ vortex-vector/src/struct_/vector.rs | 3 +- vortex-vector/src/struct_/vector_mut.rs | 8 ++- vortex-vector/src/vector.rs | 22 +++++--- vortex-vector/src/vector_mut.rs | 24 ++++++--- 58 files changed, 218 insertions(+), 142 deletions(-) diff --git a/encodings/sequence/src/operator.rs b/encodings/sequence/src/operator.rs index c444596b008..ffa18bf63b1 100644 --- a/encodings/sequence/src/operator.rs +++ b/encodings/sequence/src/operator.rs @@ -10,7 +10,8 @@ use vortex_array::vtable::OperatorVTable; use vortex_dtype::{NativePType, match_each_native_ptype}; use vortex_error::{VortexExpect, VortexResult}; use vortex_mask::AllOr; -use vortex_vector::{PVectorMut, Vector, VectorMutOps}; +use vortex_vector::primitive::PVectorMut; +use vortex_vector::{Vector, VectorMutOps}; use crate::{SequenceArray, SequenceVTable}; diff --git a/vortex-array/src/arrays/bool/vtable/operator.rs b/vortex-array/src/arrays/bool/vtable/operator.rs index ac004f717fc..f11ec27c5f9 100644 --- a/vortex-array/src/arrays/bool/vtable/operator.rs +++ b/vortex-array/src/arrays/bool/vtable/operator.rs @@ -3,7 +3,7 @@ use vortex_compute::filter::Filter; use vortex_error::VortexResult; -use vortex_vector::BoolVector; +use vortex_vector::bool::BoolVector; use crate::arrays::{BoolArray, BoolVTable, MaskedVTable}; use crate::execution::{BatchKernelRef, BindCtx, kernel}; diff --git a/vortex-array/src/arrays/null/mod.rs b/vortex-array/src/arrays/null/mod.rs index 0e08d97b6c3..460735aa344 100644 --- a/vortex-array/src/arrays/null/mod.rs +++ b/vortex-array/src/arrays/null/mod.rs @@ -9,7 +9,7 @@ use vortex_dtype::DType; use vortex_error::VortexResult; use vortex_mask::Mask; use vortex_scalar::Scalar; -use vortex_vector::NullVector; +use vortex_vector::null::NullVector; use crate::execution::{BatchKernelRef, BindCtx, kernel}; use crate::serde::ArrayChildren; diff --git a/vortex-array/src/arrays/primitive/array/conversion.rs b/vortex-array/src/arrays/primitive/array/conversion.rs index 489d2ee1270..70f5f737118 100644 --- a/vortex-array/src/arrays/primitive/array/conversion.rs +++ b/vortex-array/src/arrays/primitive/array/conversion.rs @@ -6,7 +6,8 @@ use vortex_buffer::{BitBufferMut, Buffer, BufferMut}; use vortex_dtype::{NativePType, Nullability}; use vortex_error::{VortexResult, vortex_ensure, vortex_panic}; -use vortex_vector::{PrimitiveVector, VectorOps, match_each_pvector}; +use vortex_vector::primitive::PrimitiveVector; +use vortex_vector::{VectorOps, match_each_pvector}; use crate::arrays::PrimitiveArray; use crate::validity::Validity; @@ -142,7 +143,7 @@ mod tests { use vortex_buffer::BufferMut; use vortex_dtype::{Nullability, PType}; use vortex_mask::MaskMut; - use vortex_vector::PVector; + use vortex_vector::primitive::PVector; use super::*; diff --git a/vortex-array/src/arrays/primitive/vtable/operator.rs b/vortex-array/src/arrays/primitive/vtable/operator.rs index 98860df437f..5285ae67e42 100644 --- a/vortex-array/src/arrays/primitive/vtable/operator.rs +++ b/vortex-array/src/arrays/primitive/vtable/operator.rs @@ -4,7 +4,7 @@ use vortex_compute::filter::Filter; use vortex_dtype::match_each_native_ptype; use vortex_error::VortexResult; -use vortex_vector::PVector; +use vortex_vector::primitive::PVector; use crate::arrays::{MaskedVTable, PrimitiveArray, PrimitiveVTable}; use crate::execution::{BatchKernelRef, BindCtx, kernel}; diff --git a/vortex-array/src/arrays/struct_/vtable/operator.rs b/vortex-array/src/arrays/struct_/vtable/operator.rs index c73f8e29b3c..2e1384b3c9d 100644 --- a/vortex-array/src/arrays/struct_/vtable/operator.rs +++ b/vortex-array/src/arrays/struct_/vtable/operator.rs @@ -4,7 +4,8 @@ use std::sync::Arc; use vortex_error::VortexResult; -use vortex_vector::{StructVector, Vector}; +use vortex_vector::Vector; +use vortex_vector::struct_::StructVector; use crate::ArrayRef; use crate::arrays::{StructArray, StructVTable}; diff --git a/vortex-array/src/compute/arrays/arithmetic.rs b/vortex-array/src/compute/arrays/arithmetic.rs index 8ae102c97d4..ee977cfb329 100644 --- a/vortex-array/src/compute/arrays/arithmetic.rs +++ b/vortex-array/src/compute/arrays/arithmetic.rs @@ -12,7 +12,7 @@ use vortex_compute::arithmetic::{ use vortex_dtype::{DType, NativePType, PTypeDowncastExt, match_each_native_ptype}; use vortex_error::{VortexExpect, VortexResult, vortex_err}; use vortex_scalar::{PValue, Scalar}; -use vortex_vector::PVector; +use vortex_vector::primitive::PVector; use crate::arrays::ConstantArray; use crate::execution::{BatchKernelRef, BindCtx, kernel}; diff --git a/vortex-array/src/compute/arrays/is_not_null.rs b/vortex-array/src/compute/arrays/is_not_null.rs index 7ea0453ffff..e22352a26eb 100644 --- a/vortex-array/src/compute/arrays/is_not_null.rs +++ b/vortex-array/src/compute/arrays/is_not_null.rs @@ -7,7 +7,8 @@ use vortex_dtype::DType; use vortex_dtype::Nullability::NonNullable; use vortex_error::VortexResult; use vortex_mask::Mask; -use vortex_vector::{BoolVector, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::bool::BoolVector; use crate::execution::{BatchKernelRef, BindCtx, kernel}; use crate::stats::{ArrayStats, StatsSetRef}; diff --git a/vortex-array/src/compute/arrays/is_null.rs b/vortex-array/src/compute/arrays/is_null.rs index 0a90ff36e79..da916897f61 100644 --- a/vortex-array/src/compute/arrays/is_null.rs +++ b/vortex-array/src/compute/arrays/is_null.rs @@ -8,7 +8,8 @@ use vortex_dtype::DType; use vortex_dtype::Nullability::NonNullable; use vortex_error::VortexResult; use vortex_mask::Mask; -use vortex_vector::{BoolVector, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::bool::BoolVector; use crate::execution::{BatchKernelRef, BindCtx, kernel}; use crate::stats::{ArrayStats, StatsSetRef}; diff --git a/vortex-array/src/compute/arrays/logical.rs b/vortex-array/src/compute/arrays/logical.rs index 29935d2d91d..da374782a0e 100644 --- a/vortex-array/src/compute/arrays/logical.rs +++ b/vortex-array/src/compute/arrays/logical.rs @@ -11,7 +11,7 @@ use vortex_compute::logical::{ }; use vortex_dtype::DType; use vortex_error::VortexResult; -use vortex_vector::BoolVector; +use vortex_vector::bool::BoolVector; use crate::execution::{BatchKernelRef, BindCtx, kernel}; use crate::serde::ArrayChildren; diff --git a/vortex-compute/src/arithmetic/pvector.rs b/vortex-compute/src/arithmetic/pvector.rs index e9196e67864..1238e5f14d8 100644 --- a/vortex-compute/src/arithmetic/pvector.rs +++ b/vortex-compute/src/arithmetic/pvector.rs @@ -5,7 +5,8 @@ use std::ops::BitAnd; use vortex_buffer::{Buffer, BufferMut}; use vortex_dtype::NativePType; -use vortex_vector::{PVector, PVectorMut, VectorMutOps, VectorOps}; +use vortex_vector::primitive::{PVector, PVectorMut}; +use vortex_vector::{VectorMutOps, VectorOps}; use crate::arithmetic::{Arithmetic, Operator}; @@ -125,7 +126,8 @@ where mod tests { use vortex_buffer::buffer; use vortex_mask::Mask; - use vortex_vector::{PVector, VectorOps}; + use vortex_vector::VectorOps; + use vortex_vector::primitive::PVector; use crate::arithmetic::{Arithmetic, WrappingAdd, WrappingMul, WrappingSub}; diff --git a/vortex-compute/src/arithmetic/pvector_checked.rs b/vortex-compute/src/arithmetic/pvector_checked.rs index 5aaca80b280..8a0d216dfd0 100644 --- a/vortex-compute/src/arithmetic/pvector_checked.rs +++ b/vortex-compute/src/arithmetic/pvector_checked.rs @@ -5,7 +5,8 @@ use std::ops::BitAnd; use vortex_buffer::{Buffer, BufferMut}; use vortex_dtype::NativePType; -use vortex_vector::{PVector, PVectorMut, VectorMutOps, VectorOps}; +use vortex_vector::primitive::{PVector, PVectorMut}; +use vortex_vector::{VectorMutOps, VectorOps}; use crate::arithmetic::CheckedArithmetic; @@ -122,7 +123,8 @@ where mod tests { use vortex_buffer::buffer; use vortex_mask::Mask; - use vortex_vector::{PVector, VectorOps}; + use vortex_vector::VectorOps; + use vortex_vector::primitive::PVector; use crate::arithmetic::{Add, CheckedArithmetic, Div, Mul, Sub}; diff --git a/vortex-compute/src/arrow/binaryview.rs b/vortex-compute/src/arrow/binaryview.rs index 92406767800..fb77ae42014 100644 --- a/vortex-compute/src/arrow/binaryview.rs +++ b/vortex-compute/src/arrow/binaryview.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use arrow_array::{ArrayRef, GenericByteViewArray}; use vortex_buffer::Buffer; use vortex_error::VortexResult; -use vortex_vector::{BinaryType, BinaryViewVector, StringType}; +use vortex_vector::binaryview::{BinaryType, BinaryViewVector, StringType}; use crate::arrow::IntoArrow; diff --git a/vortex-compute/src/arrow/bool.rs b/vortex-compute/src/arrow/bool.rs index ba35fcbf675..b4b21b17802 100644 --- a/vortex-compute/src/arrow/bool.rs +++ b/vortex-compute/src/arrow/bool.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use arrow_array::{ArrayRef, BooleanArray}; use vortex_error::VortexResult; -use vortex_vector::BoolVector; +use vortex_vector::bool::BoolVector; use crate::arrow::IntoArrow; diff --git a/vortex-compute/src/arrow/decimal.rs b/vortex-compute/src/arrow/decimal.rs index 5b1d3d020da..b663a604af8 100644 --- a/vortex-compute/src/arrow/decimal.rs +++ b/vortex-compute/src/arrow/decimal.rs @@ -8,7 +8,7 @@ use arrow_array::{ArrayRef, PrimitiveArray}; use vortex_buffer::Buffer; use vortex_dtype::i256; use vortex_error::VortexResult; -use vortex_vector::{DVector, DecimalVector}; +use vortex_vector::decimal::{DVector, DecimalVector}; use crate::arrow::IntoArrow; diff --git a/vortex-compute/src/arrow/fixed_size_list.rs b/vortex-compute/src/arrow/fixed_size_list.rs index 89813ea8b9f..d27b01b791e 100644 --- a/vortex-compute/src/arrow/fixed_size_list.rs +++ b/vortex-compute/src/arrow/fixed_size_list.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use arrow_array::{ArrayRef, FixedSizeListArray}; use arrow_schema::Field; use vortex_error::VortexResult; -use vortex_vector::FixedSizeListVector; +use vortex_vector::fixed_size_list::FixedSizeListVector; use crate::arrow::IntoArrow; diff --git a/vortex-compute/src/arrow/null.rs b/vortex-compute/src/arrow/null.rs index 2c934e29a94..5033c8d2d53 100644 --- a/vortex-compute/src/arrow/null.rs +++ b/vortex-compute/src/arrow/null.rs @@ -5,7 +5,8 @@ use std::sync::Arc; use arrow_array::{ArrayRef, NullArray}; use vortex_error::VortexResult; -use vortex_vector::{NullVector, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::null::NullVector; use crate::arrow::IntoArrow; diff --git a/vortex-compute/src/arrow/primitive.rs b/vortex-compute/src/arrow/primitive.rs index 4d03e7c5927..8ea785fa5a0 100644 --- a/vortex-compute/src/arrow/primitive.rs +++ b/vortex-compute/src/arrow/primitive.rs @@ -10,7 +10,8 @@ use arrow_array::types::{ use arrow_array::{ArrayRef, PrimitiveArray}; use vortex_dtype::half::f16; use vortex_error::VortexResult; -use vortex_vector::{PVector, PrimitiveVector, match_each_pvector}; +use vortex_vector::match_each_pvector; +use vortex_vector::primitive::{PVector, PrimitiveVector}; use crate::arrow::IntoArrow; diff --git a/vortex-compute/src/arrow/struct_.rs b/vortex-compute/src/arrow/struct_.rs index 872bb49930d..dbefe455a1c 100644 --- a/vortex-compute/src/arrow/struct_.rs +++ b/vortex-compute/src/arrow/struct_.rs @@ -6,7 +6,8 @@ use std::sync::Arc; use arrow_array::{ArrayRef, StructArray}; use arrow_schema::{Field, Fields}; use vortex_error::VortexResult; -use vortex_vector::{StructVector, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::struct_::StructVector; use crate::arrow::IntoArrow; diff --git a/vortex-compute/src/comparison/bool.rs b/vortex-compute/src/comparison/bool.rs index 0ce673b18f2..7197967b962 100644 --- a/vortex-compute/src/comparison/bool.rs +++ b/vortex-compute/src/comparison/bool.rs @@ -4,7 +4,8 @@ use std::ops::BitAnd; use vortex_buffer::{BitBuffer, BufferMut}; -use vortex_vector::{BoolVector, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::bool::BoolVector; use crate::comparison::{ Compare, Equal, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, NotEqual, diff --git a/vortex-compute/src/comparison/pvector.rs b/vortex-compute/src/comparison/pvector.rs index e8051c5f680..e6e1a8ffd1f 100644 --- a/vortex-compute/src/comparison/pvector.rs +++ b/vortex-compute/src/comparison/pvector.rs @@ -4,7 +4,9 @@ use std::ops::BitAnd; use vortex_dtype::NativePType; -use vortex_vector::{BoolVector, PVector, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::bool::BoolVector; +use vortex_vector::primitive::PVector; use crate::comparison::collection::ComparableCollectionAdapter; use crate::comparison::{Compare, ComparisonOperator}; diff --git a/vortex-compute/src/filter/bool.rs b/vortex-compute/src/filter/bool.rs index e0057147184..63ebb1bedb7 100644 --- a/vortex-compute/src/filter/bool.rs +++ b/vortex-compute/src/filter/bool.rs @@ -2,7 +2,8 @@ // SPDX-FileCopyrightText: Copyright the Vortex contributors use vortex_mask::Mask; -use vortex_vector::{BoolVector, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::bool::BoolVector; use crate::filter::Filter; diff --git a/vortex-compute/src/logical/and.rs b/vortex-compute/src/logical/and.rs index a5f1ec04e34..cec2db151b3 100644 --- a/vortex-compute/src/logical/and.rs +++ b/vortex-compute/src/logical/and.rs @@ -3,7 +3,8 @@ use std::ops::BitAnd; -use vortex_vector::{BoolVector, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::bool::BoolVector; use crate::logical::LogicalAnd; @@ -31,7 +32,7 @@ impl LogicalAnd<&BoolVector> for BoolVector { mod tests { use vortex_buffer::bitbuffer; use vortex_mask::Mask; - use vortex_vector::BoolVector; + use vortex_vector::bool::BoolVector; use super::*; diff --git a/vortex-compute/src/logical/and_kleene.rs b/vortex-compute/src/logical/and_kleene.rs index 18b0a3fd508..9a62148454e 100644 --- a/vortex-compute/src/logical/and_kleene.rs +++ b/vortex-compute/src/logical/and_kleene.rs @@ -5,7 +5,8 @@ use std::ops::{BitAnd, BitOr, Not}; use vortex_buffer::BitBuffer; use vortex_mask::Mask; -use vortex_vector::{BoolVector, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::bool::BoolVector; use crate::logical::LogicalAndKleene; @@ -106,7 +107,7 @@ impl LogicalAndKleene<&BoolVector> for BoolVector { mod tests { use vortex_buffer::bitbuffer; use vortex_mask::Mask; - use vortex_vector::BoolVector; + use vortex_vector::bool::BoolVector; use super::*; diff --git a/vortex-compute/src/logical/and_not.rs b/vortex-compute/src/logical/and_not.rs index 3e91b61be10..20cdb6aba9a 100644 --- a/vortex-compute/src/logical/and_not.rs +++ b/vortex-compute/src/logical/and_not.rs @@ -3,7 +3,8 @@ use std::ops::BitAnd; -use vortex_vector::{BoolVector, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::bool::BoolVector; use crate::logical::LogicalAndNot; @@ -31,7 +32,7 @@ impl LogicalAndNot<&BoolVector> for BoolVector { mod tests { use vortex_buffer::bitbuffer; use vortex_mask::Mask; - use vortex_vector::BoolVector; + use vortex_vector::bool::BoolVector; use super::*; diff --git a/vortex-compute/src/logical/not.rs b/vortex-compute/src/logical/not.rs index 5ae937387f4..ae8ef27f586 100644 --- a/vortex-compute/src/logical/not.rs +++ b/vortex-compute/src/logical/not.rs @@ -3,7 +3,8 @@ use std::ops::Not; -use vortex_vector::{BoolVector, BoolVectorMut, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::bool::{BoolVector, BoolVectorMut}; use crate::logical::LogicalNot; @@ -43,7 +44,7 @@ impl LogicalNot for BoolVectorMut { mod tests { use vortex_buffer::bitbuffer; use vortex_mask::Mask; - use vortex_vector::BoolVector; + use vortex_vector::bool::BoolVector; use super::*; diff --git a/vortex-compute/src/logical/or.rs b/vortex-compute/src/logical/or.rs index b88cc840c26..32444073703 100644 --- a/vortex-compute/src/logical/or.rs +++ b/vortex-compute/src/logical/or.rs @@ -3,7 +3,8 @@ use std::ops::{BitAnd, BitOr}; -use vortex_vector::{BoolVector, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::bool::BoolVector; use crate::logical::LogicalOr; @@ -31,7 +32,7 @@ impl LogicalOr<&BoolVector> for BoolVector { mod tests { use vortex_buffer::bitbuffer; use vortex_mask::Mask; - use vortex_vector::BoolVector; + use vortex_vector::bool::BoolVector; use super::*; diff --git a/vortex-compute/src/logical/or_kleene.rs b/vortex-compute/src/logical/or_kleene.rs index e077fe65ac0..39de88670e5 100644 --- a/vortex-compute/src/logical/or_kleene.rs +++ b/vortex-compute/src/logical/or_kleene.rs @@ -5,7 +5,8 @@ use std::ops::{BitAnd, BitOr, Not}; use vortex_buffer::BitBuffer; use vortex_mask::Mask; -use vortex_vector::{BoolVector, VectorOps}; +use vortex_vector::VectorOps; +use vortex_vector::bool::BoolVector; use crate::logical::LogicalOrKleene; @@ -106,7 +107,7 @@ impl LogicalOrKleene<&BoolVector> for BoolVector { mod tests { use vortex_buffer::bitbuffer; use vortex_mask::Mask; - use vortex_vector::BoolVector; + use vortex_vector::bool::BoolVector; use super::*; diff --git a/vortex-compute/src/mask/mod.rs b/vortex-compute/src/mask/mod.rs index a47c0c7442f..3fbf41fc874 100644 --- a/vortex-compute/src/mask/mod.rs +++ b/vortex-compute/src/mask/mod.rs @@ -7,11 +7,14 @@ use std::ops::BitAnd; use vortex_dtype::{NativeDecimalType, NativePType}; use vortex_mask::Mask; -use vortex_vector::{ - BinaryViewType, BinaryViewVector, BoolVector, DVector, DecimalVector, FixedSizeListVector, - NullVector, PVector, PrimitiveVector, StructVector, Vector, match_each_dvector, - match_each_pvector, match_each_vector, -}; +use vortex_vector::binaryview::{BinaryViewType, BinaryViewVector}; +use vortex_vector::bool::BoolVector; +use vortex_vector::decimal::{DVector, DecimalVector}; +use vortex_vector::fixed_size_list::FixedSizeListVector; +use vortex_vector::null::NullVector; +use vortex_vector::primitive::{PVector, PrimitiveVector}; +use vortex_vector::struct_::StructVector; +use vortex_vector::{Vector, match_each_dvector, match_each_pvector, match_each_vector}; /// Trait for masking the validity of an array or vector. pub trait MaskValidity { diff --git a/vortex-vector/src/binaryview/types.rs b/vortex-vector/src/binaryview/types.rs index 32b5539b73d..7dc1d0b2aa5 100644 --- a/vortex-vector/src/binaryview/types.rs +++ b/vortex-vector/src/binaryview/types.rs @@ -5,7 +5,8 @@ use std::fmt::Debug; -use crate::{BinaryViewVector, BinaryViewVectorMut, Vector, VectorMut}; +use crate::binaryview::{BinaryViewVector, BinaryViewVectorMut}; +use crate::{Vector, VectorMut}; impl From> for Vector { fn from(value: BinaryViewVector) -> Self { diff --git a/vortex-vector/src/binaryview/vector.rs b/vortex-vector/src/binaryview/vector.rs index 677821189ae..60886825652 100644 --- a/vortex-vector/src/binaryview/vector.rs +++ b/vortex-vector/src/binaryview/vector.rs @@ -203,7 +203,8 @@ impl VectorOps for BinaryViewVector { #[cfg(test)] mod tests { - use crate::{StringVectorMut, VectorMutOps, VectorOps}; + use crate::binaryview::StringVectorMut; + use crate::{VectorMutOps, VectorOps}; #[test] fn test_try_into_mut() { diff --git a/vortex-vector/src/binaryview/vector_mut.rs b/vortex-vector/src/binaryview/vector_mut.rs index e9f14c25cfa..e6363a597bd 100644 --- a/vortex-vector/src/binaryview/vector_mut.rs +++ b/vortex-vector/src/binaryview/vector_mut.rs @@ -228,7 +228,8 @@ mod tests { use vortex_mask::{Mask, MaskMut}; use crate::binaryview::view::BinaryView; - use crate::{StringVector, StringVectorMut, VectorMutOps, VectorOps}; + use crate::binaryview::{StringVector, StringVectorMut}; + use crate::{VectorMutOps, VectorOps}; #[test] fn test_basic() { diff --git a/vortex-vector/src/bool/iter.rs b/vortex-vector/src/bool/iter.rs index 7246258660d..735a38ea7af 100644 --- a/vortex-vector/src/bool/iter.rs +++ b/vortex-vector/src/bool/iter.rs @@ -6,7 +6,8 @@ use vortex_buffer::BitBufferMut; use vortex_mask::MaskMut; -use crate::{BoolVectorMut, VectorMutOps}; +use crate::VectorMutOps; +use crate::bool::BoolVectorMut; impl FromIterator> for BoolVectorMut { /// Creates a new [`BoolVectorMut`] from an iterator of `Option` values. diff --git a/vortex-vector/src/bool/vector.rs b/vortex-vector/src/bool/vector.rs index e292952aade..af9cd8974e7 100644 --- a/vortex-vector/src/bool/vector.rs +++ b/vortex-vector/src/bool/vector.rs @@ -7,7 +7,8 @@ use vortex_buffer::BitBuffer; use vortex_error::{VortexExpect, VortexResult, vortex_ensure}; use vortex_mask::Mask; -use crate::{BoolVectorMut, VectorOps}; +use crate::VectorOps; +use crate::bool::BoolVectorMut; /// An immutable vector of boolean values. /// diff --git a/vortex-vector/src/bool/vector_mut.rs b/vortex-vector/src/bool/vector_mut.rs index effbc5a7bd3..67ab329ee74 100644 --- a/vortex-vector/src/bool/vector_mut.rs +++ b/vortex-vector/src/bool/vector_mut.rs @@ -7,7 +7,8 @@ use vortex_buffer::BitBufferMut; use vortex_error::{VortexExpect, VortexResult, vortex_ensure}; use vortex_mask::MaskMut; -use crate::{BoolVector, VectorMutOps, VectorOps}; +use crate::bool::BoolVector; +use crate::{VectorMutOps, VectorOps}; /// A mutable vector of boolean values. /// diff --git a/vortex-vector/src/decimal/generic.rs b/vortex-vector/src/decimal/generic.rs index 3c8beaa3d65..2e16ec5fe5f 100644 --- a/vortex-vector/src/decimal/generic.rs +++ b/vortex-vector/src/decimal/generic.rs @@ -8,7 +8,8 @@ use vortex_dtype::{NativeDecimalType, PrecisionScale}; use vortex_error::{VortexExpect, VortexResult, vortex_bail}; use vortex_mask::Mask; -use crate::{DVectorMut, VectorOps}; +use crate::VectorOps; +use crate::decimal::DVectorMut; /// An immutable vector of generic decimal values. /// diff --git a/vortex-vector/src/decimal/generic_mut.rs b/vortex-vector/src/decimal/generic_mut.rs index 914ad1ea7a9..548cd9f60b0 100644 --- a/vortex-vector/src/decimal/generic_mut.rs +++ b/vortex-vector/src/decimal/generic_mut.rs @@ -8,7 +8,8 @@ use vortex_dtype::{DecimalDType, NativeDecimalType, PrecisionScale}; use vortex_error::{VortexExpect, VortexResult, vortex_bail}; use vortex_mask::MaskMut; -use crate::{DVector, VectorMutOps, VectorOps}; +use crate::decimal::DVector; +use crate::{VectorMutOps, VectorOps}; /// A mutable vector of decimal values with fixed precision and scale. /// diff --git a/vortex-vector/src/decimal/macros.rs b/vortex-vector/src/decimal/macros.rs index f95070df7e5..707d2335c8b 100644 --- a/vortex-vector/src/decimal/macros.rs +++ b/vortex-vector/src/decimal/macros.rs @@ -1,43 +1,50 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors -//! Helper macros for working with the different variants of [`crate::DecimalVector`] and -//! [`crate::DecimalVectorMut`]. +//! Helper macros for working with the different variants of [`DecimalVector`] and +//! [`DecimalVectorMut`]. +//! +//! [`DecimalVector`]: super::DecimalVector +//! [`DecimalVectorMut`]: super::DecimalVectorMut -/// Matches on all decimal type variants of [`crate::DecimalVector`] and executes the same code for +/// Matches on all decimal type variants of [`DecimalVector`] and executes the same code for /// each variant branch. /// /// This macro eliminates repetitive match statements when implementing operations that need to work /// uniformly across all decimal type variants (`D8`, `D16`, `D32`, `D64`, `D128`, `D256`). +/// +/// [`DecimalVector`]: super::DecimalVector #[macro_export] macro_rules! match_each_dvector { ($self:expr, | $vec:ident | $body:block) => {{ match $self { - $crate::DecimalVector::D8($vec) => $body, - $crate::DecimalVector::D16($vec) => $body, - $crate::DecimalVector::D32($vec) => $body, - $crate::DecimalVector::D64($vec) => $body, - $crate::DecimalVector::D128($vec) => $body, - $crate::DecimalVector::D256($vec) => $body, + $crate::decimal::DecimalVector::D8($vec) => $body, + $crate::decimal::DecimalVector::D16($vec) => $body, + $crate::decimal::DecimalVector::D32($vec) => $body, + $crate::decimal::DecimalVector::D64($vec) => $body, + $crate::decimal::DecimalVector::D128($vec) => $body, + $crate::decimal::DecimalVector::D256($vec) => $body, } }}; } -/// Matches on all decimal type variants of [`crate::DecimalVectorMut`] and executes the same code +/// Matches on all decimal type variants of [`DecimalVectorMut`] and executes the same code /// for each variant branch. /// /// This macro eliminates repetitive match statements when implementing mutable operations that need /// to work uniformly across all decimal type variants (`D8`, `D16`, `D32`, `D64`, `D128`, `D256`). +/// +/// [`DecimalVectorMut`]: super::DecimalVectorMut #[macro_export] macro_rules! match_each_dvector_mut { ($self:expr, | $vec:ident | $body:block) => {{ match $self { - $crate::DecimalVectorMut::D8($vec) => $body, - $crate::DecimalVectorMut::D16($vec) => $body, - $crate::DecimalVectorMut::D32($vec) => $body, - $crate::DecimalVectorMut::D64($vec) => $body, - $crate::DecimalVectorMut::D128($vec) => $body, - $crate::DecimalVectorMut::D256($vec) => $body, + $crate::decimal::DecimalVectorMut::D8($vec) => $body, + $crate::decimal::DecimalVectorMut::D16($vec) => $body, + $crate::decimal::DecimalVectorMut::D32($vec) => $body, + $crate::decimal::DecimalVectorMut::D64($vec) => $body, + $crate::decimal::DecimalVectorMut::D128($vec) => $body, + $crate::decimal::DecimalVectorMut::D256($vec) => $body, } }}; } diff --git a/vortex-vector/src/decimal/vector.rs b/vortex-vector/src/decimal/vector.rs index e9cc7cae918..c57041b46e6 100644 --- a/vortex-vector/src/decimal/vector.rs +++ b/vortex-vector/src/decimal/vector.rs @@ -7,8 +7,8 @@ use vortex_dtype::{DecimalTypeDowncast, DecimalTypeUpcast, NativeDecimalType, i2 use vortex_error::vortex_panic; use vortex_mask::Mask; -use crate::decimal::DVector; -use crate::{DecimalVectorMut, VectorOps, match_each_dvector}; +use crate::decimal::{DVector, DecimalVectorMut}; +use crate::{VectorOps, match_each_dvector}; /// An enum over all supported decimal mutable vector types. #[derive(Clone, Debug)] diff --git a/vortex-vector/src/decimal/vector_mut.rs b/vortex-vector/src/decimal/vector_mut.rs index cb97a620803..6581aa264c7 100644 --- a/vortex-vector/src/decimal/vector_mut.rs +++ b/vortex-vector/src/decimal/vector_mut.rs @@ -8,8 +8,8 @@ use vortex_dtype::{ }; use vortex_error::vortex_panic; -use crate::decimal::DVectorMut; -use crate::{DecimalVector, VectorMutOps, match_each_dvector_mut}; +use crate::decimal::{DVectorMut, DecimalVector}; +use crate::{VectorMutOps, match_each_dvector_mut}; /// An enum over all supported decimal mutable vector types. #[derive(Clone, Debug)] diff --git a/vortex-vector/src/fixed_size_list/vector.rs b/vortex-vector/src/fixed_size_list/vector.rs index 1608b74acd9..46c3fae3e11 100644 --- a/vortex-vector/src/fixed_size_list/vector.rs +++ b/vortex-vector/src/fixed_size_list/vector.rs @@ -8,7 +8,8 @@ use std::sync::Arc; use vortex_error::{VortexExpect, VortexResult, vortex_ensure}; use vortex_mask::Mask; -use crate::{FixedSizeListVectorMut, Vector, VectorOps}; +use crate::fixed_size_list::FixedSizeListVectorMut; +use crate::{Vector, VectorOps}; /// An immutable vector of fixed-size lists. /// @@ -196,7 +197,8 @@ mod tests { use vortex_mask::Mask; use super::*; - use crate::{PVectorMut, Vector, VectorMutOps}; + use crate::primitive::PVectorMut; + use crate::{Vector, VectorMutOps}; #[test] fn test_constructor_and_validation() { diff --git a/vortex-vector/src/fixed_size_list/vector_mut.rs b/vortex-vector/src/fixed_size_list/vector_mut.rs index dcc387324ca..966eaf2131e 100644 --- a/vortex-vector/src/fixed_size_list/vector_mut.rs +++ b/vortex-vector/src/fixed_size_list/vector_mut.rs @@ -9,7 +9,8 @@ use vortex_dtype::DType; use vortex_error::{VortexExpect, VortexResult, vortex_ensure}; use vortex_mask::MaskMut; -use crate::{FixedSizeListVector, VectorMut, VectorMutOps, match_vector_pair}; +use crate::fixed_size_list::FixedSizeListVector; +use crate::{VectorMut, VectorMutOps, match_vector_pair}; /// A mutable vector of fixed-size lists. /// @@ -258,7 +259,8 @@ mod tests { use vortex_mask::{Mask, MaskMut}; use super::*; - use crate::{PVectorMut, VectorOps}; + use crate::VectorOps; + use crate::primitive::PVectorMut; #[test] fn test_core_operations() { diff --git a/vortex-vector/src/lib.rs b/vortex-vector/src/lib.rs index 23d431a6afb..e5f27986961 100644 --- a/vortex-vector/src/lib.rs +++ b/vortex-vector/src/lib.rs @@ -10,21 +10,13 @@ #![deny(clippy::missing_panics_doc)] #![deny(clippy::missing_safety_doc)] -mod binaryview; -mod bool; -mod decimal; -mod fixed_size_list; -mod null; -mod primitive; -mod struct_; - -pub use binaryview::*; -pub use bool::*; -pub use decimal::*; -pub use fixed_size_list::*; -pub use null::*; -pub use primitive::*; -pub use struct_::*; +pub mod binaryview; +pub mod bool; +pub mod decimal; +pub mod fixed_size_list; +pub mod null; +pub mod primitive; +pub mod struct_; mod ops; mod vector; diff --git a/vortex-vector/src/null/vector.rs b/vortex-vector/src/null/vector.rs index fa58422983e..67b8a99fd8d 100644 --- a/vortex-vector/src/null/vector.rs +++ b/vortex-vector/src/null/vector.rs @@ -5,7 +5,8 @@ use vortex_mask::Mask; -use crate::{NullVectorMut, VectorOps}; +use crate::VectorOps; +use crate::null::NullVectorMut; /// An immutable vector of null values. /// diff --git a/vortex-vector/src/null/vector_mut.rs b/vortex-vector/src/null/vector_mut.rs index 5233b1d2243..29347974e5e 100644 --- a/vortex-vector/src/null/vector_mut.rs +++ b/vortex-vector/src/null/vector_mut.rs @@ -3,7 +3,8 @@ //! Definition and implementation of [`NullVectorMut`]. -use crate::{NullVector, VectorMutOps}; +use crate::VectorMutOps; +use crate::null::NullVector; /// A mutable vector of null values. /// diff --git a/vortex-vector/src/ops.rs b/vortex-vector/src/ops.rs index 98bfd17ed86..fa253f6cb23 100644 --- a/vortex-vector/src/ops.rs +++ b/vortex-vector/src/ops.rs @@ -74,7 +74,7 @@ pub trait VectorMutOps: private::Sealed + Into { /// # Panics /// /// Panics if the `other` vector has the wrong type (for example, a - /// [`StructVector`](crate::StructVector) might have incorrect fields). + /// [`StructVector`](crate::struct_::StructVector) might have incorrect fields). fn extend_from_vector(&mut self, other: &Self::Immutable); /// Appends `n` null elements to the vector. diff --git a/vortex-vector/src/primitive/generic.rs b/vortex-vector/src/primitive/generic.rs index 5277dc82de1..3819a8e38cb 100644 --- a/vortex-vector/src/primitive/generic.rs +++ b/vortex-vector/src/primitive/generic.rs @@ -8,7 +8,8 @@ use vortex_dtype::NativePType; use vortex_error::{VortexExpect, VortexResult, vortex_ensure}; use vortex_mask::Mask; -use crate::{PVectorMut, VectorOps}; +use crate::VectorOps; +use crate::primitive::PVectorMut; /// An immutable vector of generic primitive values. /// diff --git a/vortex-vector/src/primitive/generic_mut.rs b/vortex-vector/src/primitive/generic_mut.rs index 9897ad27751..106fec06f99 100644 --- a/vortex-vector/src/primitive/generic_mut.rs +++ b/vortex-vector/src/primitive/generic_mut.rs @@ -8,7 +8,8 @@ use vortex_dtype::NativePType; use vortex_error::{VortexExpect, VortexResult, vortex_ensure}; use vortex_mask::MaskMut; -use crate::{PVector, VectorMutOps, VectorOps}; +use crate::primitive::PVector; +use crate::{VectorMutOps, VectorOps}; /// A mutable vector of generic primitive values. /// diff --git a/vortex-vector/src/primitive/generic_mut_impl.rs b/vortex-vector/src/primitive/generic_mut_impl.rs index fdb09d1dd32..e636b1db863 100644 --- a/vortex-vector/src/primitive/generic_mut_impl.rs +++ b/vortex-vector/src/primitive/generic_mut_impl.rs @@ -7,7 +7,8 @@ use vortex_buffer::BufferMut; use vortex_dtype::NativePType; use vortex_mask::MaskMut; -use crate::{PVectorMut, VectorMutOps}; +use crate::VectorMutOps; +use crate::primitive::PVectorMut; /// Point operations for [`PVectorMut`]. impl PVectorMut { @@ -68,7 +69,7 @@ impl AsRef<[T]> for PVectorMut { /// Returns an immutable slice over the internal mutable buffer with elements of type `T`. /// /// Note that this slice may contain garbage data where the [`validity()`] mask from the frozen - /// [`PVector`](crate::PVector) type states that an element is invalid. + /// [`PVector`](crate::primitive::PVector) type states that an element is invalid. /// /// The caller should check the frozen [`validity()`] before performing any operations. /// @@ -83,7 +84,7 @@ impl AsMut<[T]> for PVectorMut { /// Returns a mutable slice over the internal mutable buffer with elements of type `T`. /// /// Note that this slice may contain garbage data where the [`validity()`] mask from the frozen - /// [`PVector`](crate::PVector) type states that an element is invalid. + /// [`PVector`](crate::primitive::PVector) type states that an element is invalid. /// /// The caller should check the frozen [`validity()`] before performing any operations. /// diff --git a/vortex-vector/src/primitive/iter.rs b/vortex-vector/src/primitive/iter.rs index c21fd88f79c..fa1f6d45cc7 100644 --- a/vortex-vector/src/primitive/iter.rs +++ b/vortex-vector/src/primitive/iter.rs @@ -5,7 +5,8 @@ use vortex_dtype::NativePType; -use crate::{PVectorMut, VectorMutOps}; +use crate::VectorMutOps; +use crate::primitive::PVectorMut; impl Extend> for PVectorMut { /// Extends the vector from an iterator of optional values. diff --git a/vortex-vector/src/primitive/macros.rs b/vortex-vector/src/primitive/macros.rs index 19ce4819a11..1779c43b0bf 100644 --- a/vortex-vector/src/primitive/macros.rs +++ b/vortex-vector/src/primitive/macros.rs @@ -4,8 +4,8 @@ //! Helper macros for working with the different variants of [`PrimitiveVector`] and //! [`PrimitiveVectorMut`]. //! -//! [`PrimitiveVector`]: crate::PrimitiveVector -//! [`PrimitiveVectorMut`]: crate::PrimitiveVectorMut +//! [`PrimitiveVector`]: crate::primitive::PrimitiveVector +//! [`PrimitiveVectorMut`]: crate::primitive::PrimitiveVectorMut /// Matches on all primitive type variants of [`PrimitiveVector`] and executes the same code for /// each variant branch. @@ -38,23 +38,23 @@ /// /// Note: The `len` method is already provided by the [`VectorOps`] trait implementation. /// -/// [`PrimitiveVector`]: crate::PrimitiveVector +/// [`PrimitiveVector`]: crate::primitive::PrimitiveVector /// [`VectorOps`]: crate::VectorOps #[macro_export] macro_rules! match_each_pvector { ($self:expr, | $vec:ident | $body:block) => {{ match $self { - $crate::PrimitiveVector::U8($vec) => $body, - $crate::PrimitiveVector::U16($vec) => $body, - $crate::PrimitiveVector::U32($vec) => $body, - $crate::PrimitiveVector::U64($vec) => $body, - $crate::PrimitiveVector::I8($vec) => $body, - $crate::PrimitiveVector::I16($vec) => $body, - $crate::PrimitiveVector::I32($vec) => $body, - $crate::PrimitiveVector::I64($vec) => $body, - $crate::PrimitiveVector::F16($vec) => $body, - $crate::PrimitiveVector::F32($vec) => $body, - $crate::PrimitiveVector::F64($vec) => $body, + $crate::primitive::PrimitiveVector::U8($vec) => $body, + $crate::primitive::PrimitiveVector::U16($vec) => $body, + $crate::primitive::PrimitiveVector::U32($vec) => $body, + $crate::primitive::PrimitiveVector::U64($vec) => $body, + $crate::primitive::PrimitiveVector::I8($vec) => $body, + $crate::primitive::PrimitiveVector::I16($vec) => $body, + $crate::primitive::PrimitiveVector::I32($vec) => $body, + $crate::primitive::PrimitiveVector::I64($vec) => $body, + $crate::primitive::PrimitiveVector::F16($vec) => $body, + $crate::primitive::PrimitiveVector::F32($vec) => $body, + $crate::primitive::PrimitiveVector::F64($vec) => $body, } }}; } @@ -88,23 +88,23 @@ macro_rules! match_each_pvector { /// /// Note: The `reserve` method is already provided by the [`VectorMutOps`] trait implementation. /// -/// [`PrimitiveVectorMut`]: crate::PrimitiveVectorMut +/// [`PrimitiveVectorMut`]: crate::primitive::PrimitiveVectorMut /// [`VectorMutOps`]: crate::VectorMutOps #[macro_export] macro_rules! match_each_pvector_mut { ($self:expr, | $vec:ident | $body:block) => {{ match $self { - $crate::PrimitiveVectorMut::U8($vec) => $body, - $crate::PrimitiveVectorMut::U16($vec) => $body, - $crate::PrimitiveVectorMut::U32($vec) => $body, - $crate::PrimitiveVectorMut::U64($vec) => $body, - $crate::PrimitiveVectorMut::I8($vec) => $body, - $crate::PrimitiveVectorMut::I16($vec) => $body, - $crate::PrimitiveVectorMut::I32($vec) => $body, - $crate::PrimitiveVectorMut::I64($vec) => $body, - $crate::PrimitiveVectorMut::F16($vec) => $body, - $crate::PrimitiveVectorMut::F32($vec) => $body, - $crate::PrimitiveVectorMut::F64($vec) => $body, + $crate::primitive::PrimitiveVectorMut::U8($vec) => $body, + $crate::primitive::PrimitiveVectorMut::U16($vec) => $body, + $crate::primitive::PrimitiveVectorMut::U32($vec) => $body, + $crate::primitive::PrimitiveVectorMut::U64($vec) => $body, + $crate::primitive::PrimitiveVectorMut::I8($vec) => $body, + $crate::primitive::PrimitiveVectorMut::I16($vec) => $body, + $crate::primitive::PrimitiveVectorMut::I32($vec) => $body, + $crate::primitive::PrimitiveVectorMut::I64($vec) => $body, + $crate::primitive::PrimitiveVectorMut::F16($vec) => $body, + $crate::primitive::PrimitiveVectorMut::F32($vec) => $body, + $crate::primitive::PrimitiveVectorMut::F64($vec) => $body, } }}; } diff --git a/vortex-vector/src/primitive/vector.rs b/vortex-vector/src/primitive/vector.rs index e076d02e7a6..d87daa95a3d 100644 --- a/vortex-vector/src/primitive/vector.rs +++ b/vortex-vector/src/primitive/vector.rs @@ -7,7 +7,8 @@ use vortex_dtype::half::f16; use vortex_dtype::{NativePType, PType, PTypeDowncast, PTypeUpcast}; use vortex_error::vortex_panic; -use crate::{PVector, PrimitiveVectorMut, VectorOps, match_each_pvector}; +use crate::primitive::{PVector, PrimitiveVectorMut}; +use crate::{VectorOps, match_each_pvector}; /// An immutable vector of primitive values. /// diff --git a/vortex-vector/src/primitive/vector_mut.rs b/vortex-vector/src/primitive/vector_mut.rs index f3bb4e6b3ec..ebe89fc8595 100644 --- a/vortex-vector/src/primitive/vector_mut.rs +++ b/vortex-vector/src/primitive/vector_mut.rs @@ -7,7 +7,8 @@ use vortex_dtype::half::f16; use vortex_dtype::{NativePType, PType, PTypeDowncast, PTypeUpcast}; use vortex_error::vortex_panic; -use crate::{PVectorMut, PrimitiveVector, VectorMutOps, match_each_pvector_mut}; +use crate::primitive::{PVectorMut, PrimitiveVector}; +use crate::{VectorMutOps, match_each_pvector_mut}; /// A mutable vector of primitive values. /// diff --git a/vortex-vector/src/private.rs b/vortex-vector/src/private.rs index 1add13cc0a0..5dec8c8a52b 100644 --- a/vortex-vector/src/private.rs +++ b/vortex-vector/src/private.rs @@ -10,6 +10,13 @@ use vortex_dtype::{NativeDecimalType, NativePType}; +use crate::binaryview::{BinaryViewType, BinaryViewVector, BinaryViewVectorMut}; +use crate::bool::{BoolVector, BoolVectorMut}; +use crate::decimal::{DVector, DVectorMut, DecimalVector, DecimalVectorMut}; +use crate::fixed_size_list::{FixedSizeListVector, FixedSizeListVectorMut}; +use crate::null::{NullVector, NullVectorMut}; +use crate::primitive::{PVector, PVectorMut, PrimitiveVector, PrimitiveVectorMut}; +use crate::struct_::{StructVector, StructVectorMut}; use crate::*; /// A private trait for sealing implementations of other traits. diff --git a/vortex-vector/src/struct_/vector.rs b/vortex-vector/src/struct_/vector.rs index 5ed22ce5212..33694a357aa 100644 --- a/vortex-vector/src/struct_/vector.rs +++ b/vortex-vector/src/struct_/vector.rs @@ -8,7 +8,8 @@ use std::sync::Arc; use vortex_error::{VortexExpect, VortexResult, vortex_ensure}; use vortex_mask::Mask; -use crate::{StructVectorMut, Vector, VectorMutOps, VectorOps}; +use crate::struct_::StructVectorMut; +use crate::{Vector, VectorMutOps, VectorOps}; /// An immutable vector of struct values. /// diff --git a/vortex-vector/src/struct_/vector_mut.rs b/vortex-vector/src/struct_/vector_mut.rs index 99141befe63..aeacb564c94 100644 --- a/vortex-vector/src/struct_/vector_mut.rs +++ b/vortex-vector/src/struct_/vector_mut.rs @@ -9,7 +9,8 @@ use vortex_dtype::StructFields; use vortex_error::{VortexExpect, VortexResult, vortex_ensure}; use vortex_mask::MaskMut; -use crate::{StructVector, Vector, VectorMut, VectorMutOps, VectorOps, match_vector_pair}; +use crate::struct_::StructVector; +use crate::{Vector, VectorMut, VectorMutOps, VectorOps, match_vector_pair}; /// A mutable vector of struct values (values with named fields). /// @@ -271,7 +272,10 @@ mod tests { use vortex_mask::{Mask, MaskMut}; use super::*; - use crate::{BoolVectorMut, NullVector, NullVectorMut, PVectorMut, VectorMut}; + use crate::VectorMut; + use crate::bool::BoolVectorMut; + use crate::null::{NullVector, NullVectorMut}; + use crate::primitive::PVectorMut; #[test] fn test_empty_fields() { diff --git a/vortex-vector/src/vector.rs b/vortex-vector/src/vector.rs index 430785696b5..58b1a161964 100644 --- a/vortex-vector/src/vector.rs +++ b/vortex-vector/src/vector.rs @@ -8,11 +8,14 @@ use vortex_error::vortex_panic; +use crate::binaryview::{BinaryVector, StringVector}; +use crate::bool::BoolVector; +use crate::decimal::DecimalVector; use crate::fixed_size_list::FixedSizeListVector; -use crate::{ - BinaryVector, BoolVector, DecimalVector, NullVector, PrimitiveVector, StringVector, - StructVector, VectorMut, VectorOps, match_each_vector, -}; +use crate::null::NullVector; +use crate::primitive::PrimitiveVector; +use crate::struct_::StructVector; +use crate::{VectorMut, VectorOps, match_each_vector}; /// An enum over all kinds of immutable vectors, which represent fully decompressed (canonical) /// array data. @@ -29,12 +32,19 @@ pub enum Vector { Null(NullVector), /// Boolean vectors. Bool(BoolVector), - /// Decimal + /// Decimal vectors. + /// + /// Note that [`DecimalVector`] is an enum over the different possible (generic) + /// [`DVector`](crate::decimal::DVector)s. + /// + /// See the [documentation](crate::decimal) for more information. Decimal(DecimalVector), /// Primitive vectors. /// /// Note that [`PrimitiveVector`] is an enum over the different possible (generic) - /// [`PVector`](crate::PVector)s. See the documentation for more information. + /// [`PVector`](crate::primitive::PVector)s. + /// + /// See the [documentation](crate::primitive) for more information. Primitive(PrimitiveVector), /// String vectors String(StringVector), diff --git a/vortex-vector/src/vector_mut.rs b/vortex-vector/src/vector_mut.rs index 2447bf24c82..f5b348f48eb 100644 --- a/vortex-vector/src/vector_mut.rs +++ b/vortex-vector/src/vector_mut.rs @@ -10,11 +10,13 @@ use vortex_dtype::DType; use vortex_error::vortex_panic; use crate::binaryview::{BinaryVectorMut, StringVectorMut}; +use crate::bool::BoolVectorMut; +use crate::decimal::DecimalVectorMut; use crate::fixed_size_list::FixedSizeListVectorMut; -use crate::{ - BoolVectorMut, DecimalVectorMut, NullVectorMut, PrimitiveVectorMut, StructVectorMut, Vector, - VectorMutOps, match_each_vector_mut, match_vector_pair, -}; +use crate::null::NullVectorMut; +use crate::primitive::PrimitiveVectorMut; +use crate::struct_::StructVectorMut; +use crate::{Vector, VectorMutOps, match_each_vector_mut, match_vector_pair}; /// An enum over all kinds of mutable vectors, which represent fully decompressed (canonical) array /// data. @@ -31,12 +33,19 @@ pub enum VectorMut { Null(NullVectorMut), /// Mutable Boolean vectors. Bool(BoolVectorMut), - /// Mutable Decimal vectors + /// Mutable Decimal vectors. + /// + /// Note that [`DecimalVectorMut`] is an enum over the different possible (generic) + /// [`DVectorMut`](crate::decimal::DVectorMut)s. + /// + /// See the [documentation](crate::decimal) for more information. Decimal(DecimalVectorMut), /// Mutable Primitive vectors. /// /// Note that [`PrimitiveVectorMut`] is an enum over the different possible (generic) - /// [`PVectorMut`](crate::PVectorMut)s. See the documentation for more information. + /// [`PVectorMut`](crate::primitive::PVectorMut)s. + /// + /// See the documentation for more information. Primitive(PrimitiveVectorMut), /// Mutable String vectors. String(StringVectorMut), @@ -234,8 +243,9 @@ mod tests { use vortex_dtype::{DecimalDType, Nullability, PType}; use super::*; + use crate::VectorOps; use crate::decimal::DecimalVectorMut; - use crate::{PVectorMut, VectorOps}; + use crate::primitive::PVectorMut; #[test] fn test_with_capacity() { From ffef1052ad526e6795aa7936479c915463c6c4d8 Mon Sep 17 00:00:00 2001 From: Connor Tsui Date: Tue, 4 Nov 2025 11:02:12 -0500 Subject: [PATCH 3/3] fix doc tests Signed-off-by: Connor Tsui --- vortex-vector/src/binaryview/vector_mut.rs | 3 ++- vortex-vector/src/bool/iter.rs | 8 +++++--- vortex-vector/src/bool/mod.rs | 9 +++++--- vortex-vector/src/decimal/mod.rs | 12 +++++++---- vortex-vector/src/fixed_size_list/mod.rs | 8 ++++++-- vortex-vector/src/macros.rs | 24 +++++++++++----------- vortex-vector/src/primitive/iter.rs | 8 +++++--- vortex-vector/src/primitive/macros.rs | 6 ++++-- vortex-vector/src/primitive/mod.rs | 15 +++++++++----- vortex-vector/src/struct_/mod.rs | 24 ++++++++++++++-------- 10 files changed, 73 insertions(+), 44 deletions(-) diff --git a/vortex-vector/src/binaryview/vector_mut.rs b/vortex-vector/src/binaryview/vector_mut.rs index e6363a597bd..df42ac8eadd 100644 --- a/vortex-vector/src/binaryview/vector_mut.rs +++ b/vortex-vector/src/binaryview/vector_mut.rs @@ -115,7 +115,8 @@ impl BinaryViewVectorMut { /// Append a repeated sequence of binary data to a vector. /// /// ``` - /// # use vortex_vector::{StringVectorMut, VectorMutOps}; + /// # use vortex_vector::binaryview::StringVectorMut; + /// # use vortex_vector::VectorMutOps; /// let mut strings = StringVectorMut::with_capacity(4); /// strings.append_values("inlined", 2); /// strings.append_nulls(1); diff --git a/vortex-vector/src/bool/iter.rs b/vortex-vector/src/bool/iter.rs index 735a38ea7af..21023c4d8fd 100644 --- a/vortex-vector/src/bool/iter.rs +++ b/vortex-vector/src/bool/iter.rs @@ -17,7 +17,8 @@ impl FromIterator> for BoolVectorMut { /// # Examples /// /// ``` - /// use vortex_vector::{BoolVectorMut, VectorMutOps}; + /// use vortex_vector::bool::BoolVectorMut; + /// use vortex_vector::VectorMutOps; /// /// let mut vec = BoolVectorMut::from_iter([Some(true), None, Some(false)]); /// assert_eq!(vec.len(), 3); @@ -61,7 +62,8 @@ impl FromIterator for BoolVectorMut { /// # Examples /// /// ``` - /// use vortex_vector::{BoolVectorMut, VectorMutOps}; + /// use vortex_vector::bool::BoolVectorMut; + /// use vortex_vector::VectorMutOps; /// /// let mut vec = BoolVectorMut::from_iter([true, false, false, true]); /// assert_eq!(vec.len(), 4); @@ -127,7 +129,7 @@ impl IntoIterator for BoolVectorMut { /// # Examples /// /// ``` - /// use vortex_vector::BoolVectorMut; + /// use vortex_vector::bool::BoolVectorMut; /// /// let vec = BoolVectorMut::from_iter([Some(true), None, Some(false), Some(true)]); /// let collected: Vec<_> = vec.into_iter().collect(); diff --git a/vortex-vector/src/bool/mod.rs b/vortex-vector/src/bool/mod.rs index aedde4c2e5f..06a752686ef 100644 --- a/vortex-vector/src/bool/mod.rs +++ b/vortex-vector/src/bool/mod.rs @@ -8,7 +8,8 @@ //! ## Extending and appending //! //! ``` -//! use vortex_vector::{BoolVectorMut, VectorMutOps}; +//! use vortex_vector::bool::BoolVectorMut; +//! use vortex_vector::VectorMutOps; //! //! let mut vec1 = BoolVectorMut::from_iter([true, false].map(Some)); //! let vec2 = BoolVectorMut::from_iter([true, true].map(Some)).freeze(); @@ -25,7 +26,8 @@ //! ## Splitting and unsplitting //! //! ``` -//! use vortex_vector::{BoolVectorMut, VectorMutOps}; +//! use vortex_vector::bool::BoolVectorMut; +//! use vortex_vector::VectorMutOps; //! //! let mut vec = BoolVectorMut::from_iter([true, false, true, false, true].map(Some)); //! @@ -42,7 +44,8 @@ //! ## Converting to immutable //! //! ``` -//! use vortex_vector::{BoolVectorMut, VectorMutOps, VectorOps}; +//! use vortex_vector::bool::BoolVectorMut; +//! use vortex_vector::{VectorMutOps, VectorOps}; //! //! let mut vec = BoolVectorMut::from_iter([true, false, true].map(Some)); //! diff --git a/vortex-vector/src/decimal/mod.rs b/vortex-vector/src/decimal/mod.rs index cbf7e2faa80..4f6766481a8 100644 --- a/vortex-vector/src/decimal/mod.rs +++ b/vortex-vector/src/decimal/mod.rs @@ -16,7 +16,8 @@ //! //! ``` //! use vortex_dtype::{DecimalDType, PrecisionScale}; -//! use vortex_vector::{DVectorMut, VectorMutOps}; +//! use vortex_vector::decimal::{DVectorMut}; +//! use vortex_vector::VectorMutOps; //! //! // Create a decimal vector with precision=9, scale=2 (e.g., up to 9999999.99). //! let decimal_dtype = DecimalDType::new(9, 2); @@ -50,7 +51,8 @@ //! use vortex_buffer::BufferMut; //! use vortex_dtype::{DecimalDType, PrecisionScale}; //! use vortex_mask::MaskMut; -//! use vortex_vector::{DVectorMut, VectorMutOps}; +//! use vortex_vector::decimal::DVectorMut; +//! use vortex_vector::VectorMutOps; //! //! // Create a decimal vector with nulls. //! let decimal_dtype = DecimalDType::new(5, 2); // Up to 999.99. @@ -79,7 +81,8 @@ //! //! ``` //! use vortex_dtype::DecimalDType; -//! use vortex_vector::{DVectorMut, VectorMutOps}; +//! use vortex_vector::decimal::DVectorMut; +//! use vortex_vector::VectorMutOps; //! //! // Create two decimal vectors with scale=3 (3 decimal places). //! let decimal_dtype = DecimalDType::new(10, 3); @@ -114,7 +117,8 @@ //! //! ``` //! use vortex_dtype::DecimalDType; -//! use vortex_vector::{DVectorMut, VectorMutOps, VectorOps}; +//! use vortex_vector::decimal::DVectorMut; +//! use vortex_vector::{VectorMutOps, VectorOps}; //! //! // Create a mutable decimal vector. //! let decimal_dtype = DecimalDType::new(18, 6); // High precision with 6 decimal places. diff --git a/vortex-vector/src/fixed_size_list/mod.rs b/vortex-vector/src/fixed_size_list/mod.rs index ba51a6d4827..6b68d185024 100644 --- a/vortex-vector/src/fixed_size_list/mod.rs +++ b/vortex-vector/src/fixed_size_list/mod.rs @@ -11,7 +11,9 @@ //! be null. //! //! ``` -//! use vortex_vector::{FixedSizeListVectorMut, PVectorMut, VectorMut, VectorMutOps}; +//! use vortex_vector::fixed_size_list::FixedSizeListVectorMut; +//! use vortex_vector::primitive::PVectorMut; +//! use vortex_vector::{VectorMut, VectorMutOps}; //! use vortex_mask::{Mask, MaskMut}; //! //! // Create elements with some null values. @@ -46,7 +48,9 @@ //! [`unsplit()`]: crate::VectorMutOps::unsplit //! //! ``` -//! use vortex_vector::{FixedSizeListVectorMut, PVectorMut, VectorMut, VectorMutOps}; +//! use vortex_vector::fixed_size_list::FixedSizeListVectorMut; +//! use vortex_vector::primitive::PVectorMut; +//! use vortex_vector::{VectorMut, VectorMutOps}; //! use vortex_mask::MaskMut; //! //! // Create a vector with 6 lists, each containing 2 integers. diff --git a/vortex-vector/src/macros.rs b/vortex-vector/src/macros.rs index cd417b1e30a..177ffd294c0 100644 --- a/vortex-vector/src/macros.rs +++ b/vortex-vector/src/macros.rs @@ -12,9 +12,10 @@ /// # Examples /// /// ``` -/// use vortex_vector::{ -/// Vector, BoolVectorMut, NullVector, VectorOps, VectorMutOps, match_each_vector -/// }; +/// use vortex_vector::Vector; +/// use vortex_vector::bool::BoolVectorMut; +/// use vortex_vector::null::NullVector; +/// use vortex_vector::{VectorOps, VectorMutOps, match_each_vector}; /// /// fn get_vector_length(vector: &Vector) -> usize { /// match_each_vector!(vector, |v| { v.len() }) @@ -59,9 +60,10 @@ macro_rules! match_each_vector { /// # Examples /// /// ``` -/// use vortex_vector::{ -/// VectorMut, BoolVectorMut, NullVectorMut, VectorMutOps, match_each_vector_mut -/// }; +/// use vortex_vector::VectorMut; +/// use vortex_vector::bool::BoolVectorMut; +/// use vortex_vector::null::NullVectorMut; +/// use vortex_vector::{VectorMutOps, match_each_vector_mut}; /// /// fn reserve_space(vector: &mut VectorMut, additional: usize) { /// match_each_vector_mut!(vector, |v| { v.reserve(additional) }) @@ -140,9 +142,8 @@ macro_rules! __match_vector_pair_arms { /// # Examples /// /// ``` -/// use vortex_vector::{ -/// BoolVector, BoolVectorMut, Vector, VectorMut, VectorMutOps, match_vector_pair -/// }; +/// use vortex_vector::{Vector, VectorMut, VectorMutOps, match_vector_pair}; +/// use vortex_vector::bool::{BoolVector, BoolVectorMut}; /// /// fn extend_vector(left: &mut VectorMut, right: &Vector) { /// match_vector_pair!(left, right, |a: VectorMut, b: Vector| { @@ -160,9 +161,8 @@ macro_rules! __match_vector_pair_arms { /// Note that the vectors can also be owned: /// /// ``` -/// use vortex_vector::{ -/// BoolVector, BoolVectorMut, Vector, VectorMut, VectorMutOps, match_vector_pair -/// }; +/// use vortex_vector::{Vector, VectorMut, VectorMutOps, match_vector_pair}; +/// use vortex_vector::bool::{BoolVector, BoolVectorMut}; /// /// fn extend_vector_owned(mut dest: VectorMut, src: Vector) -> VectorMut { /// match_vector_pair!(&mut dest, src, |a: VectorMut, b: Vector| { diff --git a/vortex-vector/src/primitive/iter.rs b/vortex-vector/src/primitive/iter.rs index fa1f6d45cc7..b879a6e7b26 100644 --- a/vortex-vector/src/primitive/iter.rs +++ b/vortex-vector/src/primitive/iter.rs @@ -16,7 +16,8 @@ impl Extend> for PVectorMut { /// # Examples /// /// ``` - /// use vortex_vector::{PVectorMut, VectorMutOps, VectorOps}; + /// use vortex_vector::primitive::PVectorMut; + /// use vortex_vector::{VectorMutOps, VectorOps}; /// /// let mut vec = PVectorMut::from_iter([Some(1i32), None]); /// vec.extend([Some(3), None, Some(5)]); @@ -93,7 +94,8 @@ impl FromIterator for PVectorMut { /// # Examples /// /// ``` - /// use vortex_vector::{PVectorMut, VectorMutOps}; + /// use vortex_vector::primitive::PVectorMut; + /// use vortex_vector::VectorMutOps; /// /// let mut vec = PVectorMut::from_iter([1i32, 2, 3, 4]); /// assert_eq!(vec.len(), 4); @@ -158,7 +160,7 @@ impl IntoIterator for PVectorMut { /// # Examples /// /// ``` - /// use vortex_vector::PVectorMut; + /// use vortex_vector::primitive::PVectorMut; /// /// let vec = PVectorMut::::from_iter([Some(1), None, Some(3), Some(4)]); /// let collected: Vec<_> = vec.into_iter().collect(); diff --git a/vortex-vector/src/primitive/macros.rs b/vortex-vector/src/primitive/macros.rs index 1779c43b0bf..4e670b7c4ed 100644 --- a/vortex-vector/src/primitive/macros.rs +++ b/vortex-vector/src/primitive/macros.rs @@ -17,7 +17,8 @@ /// # Examples /// /// ``` -/// use vortex_vector::{PrimitiveVector, PVectorMut, VectorOps, VectorMutOps, match_each_pvector}; +/// use vortex_vector::primitive::{PrimitiveVector, PVectorMut}; +/// use vortex_vector::{VectorOps, VectorMutOps, match_each_pvector}; /// /// fn get_primitive_len(vector: &PrimitiveVector) -> usize { /// match_each_pvector!(vector, |v| { v.len() }) @@ -69,7 +70,8 @@ macro_rules! match_each_pvector { /// # Examples /// /// ``` -/// use vortex_vector::{PrimitiveVectorMut, PVectorMut, VectorMutOps, match_each_pvector_mut}; +/// use vortex_vector::primitive::{PrimitiveVectorMut, PVectorMut}; +/// use vortex_vector::{VectorMutOps, match_each_pvector_mut}; /// /// fn reserve_primitive_space(vector: &mut PrimitiveVectorMut, additional: usize) { /// match_each_pvector_mut!(vector, |v| { v.reserve(additional) }) diff --git a/vortex-vector/src/primitive/mod.rs b/vortex-vector/src/primitive/mod.rs index 356c80d7be6..5420fdba5c0 100644 --- a/vortex-vector/src/primitive/mod.rs +++ b/vortex-vector/src/primitive/mod.rs @@ -16,7 +16,8 @@ //! ## Creating and building a vector //! //! ``` -//! use vortex_vector::{PVectorMut, VectorMutOps}; +//! use vortex_vector::primitive::PVectorMut; +//! use vortex_vector::VectorMutOps; //! //! // Create with initial capacity for i32 values. //! let mut vec = PVectorMut::::with_capacity(10); @@ -35,7 +36,8 @@ //! ## Extending and appending //! //! ``` -//! use vortex_vector::{PVectorMut, VectorMutOps}; +//! use vortex_vector::primitive::PVectorMut; +//! use vortex_vector::VectorMutOps; //! //! let mut vec1 = PVectorMut::::from_iter([1, 2].map(Some)); //! let vec2 = PVectorMut::::from_iter([3, 4].map(Some)).freeze(); @@ -52,7 +54,8 @@ //! ## Splitting and unsplitting //! //! ``` -//! use vortex_vector::{PVectorMut, VectorMutOps}; +//! use vortex_vector::primitive::PVectorMut; +//! use vortex_vector::VectorMutOps; //! //! let mut vec = PVectorMut::::from_iter([10, 20, 30, 40, 50].map(Some)); //! @@ -69,7 +72,8 @@ //! ## Working with nulls //! //! ``` -//! use vortex_vector::{PVectorMut, VectorMutOps}; +//! use vortex_vector::primitive::PVectorMut; +//! use vortex_vector::VectorMutOps; //! //! // Create a vector with some null values. //! let mut vec = PVectorMut::::from_iter([Some(100), None, Some(200), None]); @@ -83,7 +87,8 @@ //! ## Converting to immutable //! //! ``` -//! use vortex_vector::{PVectorMut, VectorMutOps, VectorOps}; +//! use vortex_vector::primitive::PVectorMut; +//! use vortex_vector::{VectorMutOps, VectorOps}; //! //! let mut vec = PVectorMut::::from_iter([1.0, 2.0, 3.0].map(Some)); //! diff --git a/vortex-vector/src/struct_/mod.rs b/vortex-vector/src/struct_/mod.rs index cba8cd6c630..bbfd86121d8 100644 --- a/vortex-vector/src/struct_/mod.rs +++ b/vortex-vector/src/struct_/mod.rs @@ -8,9 +8,11 @@ //! ## Creating a [`StructVector`] and [`StructVectorMut`] //! //! ``` -//! use vortex_vector::{ -//! BoolVectorMut, NullVectorMut, PVectorMut, StructVectorMut, VectorMut, VectorMutOps, -//! }; +//! use vortex_vector::bool::BoolVectorMut; +//! use vortex_vector::null::NullVectorMut; +//! use vortex_vector::primitive::PVectorMut; +//! use vortex_vector::struct_::StructVectorMut; +//! use vortex_vector::{VectorMut, VectorMutOps}; //! use vortex_mask::MaskMut; //! //! // Create a struct with three fields: nulls, booleans, and integers. @@ -30,9 +32,11 @@ //! [`unsplit()`]: crate::VectorMutOps::unsplit //! //! ``` -//! use vortex_vector::{ -//! BoolVectorMut, NullVectorMut, PVectorMut, StructVectorMut, VectorMut, VectorMutOps, -//! }; +//! use vortex_vector::bool::BoolVectorMut; +//! use vortex_vector::null::NullVectorMut; +//! use vortex_vector::primitive::PVectorMut; +//! use vortex_vector::struct_::StructVectorMut; +//! use vortex_vector::{VectorMut, VectorMutOps}; //! use vortex_mask::MaskMut; //! //! let fields = Box::new([ @@ -56,9 +60,11 @@ //! ## Accessing field values //! //! ``` -//! use vortex_vector::{ -//! BoolVectorMut, NullVectorMut, PVectorMut, StructVectorMut, VectorMut, VectorMutOps, -//! }; +//! use vortex_vector::bool::BoolVectorMut; +//! use vortex_vector::null::NullVectorMut; +//! use vortex_vector::primitive::PVectorMut; +//! use vortex_vector::struct_::StructVectorMut; +//! use vortex_vector::{VectorMut, VectorMutOps}; //! use vortex_mask::MaskMut; //! use vortex_dtype::PTypeDowncast; //!