pub struct SuperArray { /* private fields */ }Expand description
§SuperArray
Higher-order container for multiple immutable FieldArray segments.
§Description
- Stores an ordered sequence of
FieldArraychunks, each with identical field metadata. - Equivalent to Apache Arrow’s
ChunkedArraywhen sent over FFI, where it is treated as a single logical column. - It can also serve as an unbounded or continuously growing collection of segments, making it useful for streaming ingestion and partitioned storage.
- Chunk lengths may vary without restriction.
§Example
// Create from multiple chunks with matching metadata
let sa = SuperArray::from_chunks(vec![fa("col", &[1, 2], 0), fa("col", &[3], 0)]);
assert_eq!(sa.len(), 3); // total rows across chunks
assert_eq!(sa.n_chunks(), 2); // number of chunks
assert_eq!(sa.field().name, "col");Implementations§
Source§impl SuperArray
impl SuperArray
Sourcepub fn from_field_array_chunks(chunks: Vec<FieldArray>) -> Self
pub fn from_field_array_chunks(chunks: Vec<FieldArray>) -> Self
Constructs a ChunkedArray from FieldArray chunks.
Panics if chunks is empty or metadata/type/nullable mismatch is found.
Examples found in repository?
357fn test_super_array_broadcasting() {
358 #[cfg(feature = "chunked")]
359 {
360 println!("┌─ Test 11: SuperArray (Chunked) Broadcasting");
361 println!("│ Operation: SuperArray{{[1,2],[3,4]}} * SuperArray{{[2,2],[2,2]}}");
362 println!("│ Expected: SuperArray{{[2,4],[6,8]}}");
363
364 // Create chunked arrays (multiple field array chunks)
365 let chunk1_a = Array::from_int32(IntegerArray::from_slice(&vec64![1, 2]));
366 let chunk2_a = Array::from_int32(IntegerArray::from_slice(&vec64![3, 4]));
367 let fa1 = minarrow::FieldArray::from_arr("chunk1", chunk1_a);
368 let fa2 = minarrow::FieldArray::from_arr("chunk1", chunk2_a);
369 let super_arr1 = SuperArray::from_field_array_chunks(vec![fa1, fa2]);
370
371 let chunk1_b = Array::from_int32(IntegerArray::from_slice(&vec64![2, 2]));
372 let chunk2_b = Array::from_int32(IntegerArray::from_slice(&vec64![2, 2]));
373 let fa3 = minarrow::FieldArray::from_arr("chunk1", chunk1_b);
374 let fa4 = minarrow::FieldArray::from_arr("chunk1", chunk2_b);
375 let super_arr2 = SuperArray::from_field_array_chunks(vec![fa3, fa4]);
376
377 match Value::SuperArray(Arc::new(super_arr1)) * Value::SuperArray(Arc::new(super_arr2)) {
378 Ok(Value::SuperArray(result)) => {
379 println!("│ Result with {} chunks:", result.len());
380 for i in 0..result.len() {
381 if let Some(fa) = result.chunk(i) {
382 if let Array::NumericArray(NumericArray::Int32(arr)) = &fa.array {
383 println!("│ Chunk {}: {:?}", i, arr.data.as_slice());
384 }
385 }
386 }
387 println!("└─ ✓ Passed\n");
388 }
389 Ok(other) => println!("└─ ✗ Error: Unexpected result type {:?}\n", other),
390 Err(e) => println!("└─ ✗ Error: {:?}\n", e),
391 }
392 }
393
394 #[cfg(not(feature = "chunked"))]
395 {
396 println!("┌─ Test 11: SuperArray (Chunked) Broadcasting");
397 println!("└─ ⊘ Skipped (chunked feature not enabled)\n");
398 }
399}Sourcepub fn from_chunks(chunks: Vec<FieldArray>) -> Self
pub fn from_chunks(chunks: Vec<FieldArray>) -> Self
Construct from Vec<FieldArray>.
Sourcepub fn from_slices(slices: &[ArrayV], field: Arc<Field>) -> Self
pub fn from_slices(slices: &[ArrayV], field: Arc<Field>) -> Self
Materialises a ChunkedArray from an existing slice of ArrayView tuples,
using the provided field metadata (applied to all slices).
Panics if the slice list is empty, or if any slice’s type or nullability does not match the provided field.
Sourcepub fn slice(&self, offset: usize, len: usize) -> SuperArrayV
pub fn slice(&self, offset: usize, len: usize) -> SuperArrayV
Returns a zero-copy view of this chunked array over the window [offset..offset+len).
If the chunks are fragmented in memory, access patterns may result in degraded cache locality and reduced SIMD optimisation.
Sourcepub fn copy_to_array(&self) -> Array
pub fn copy_to_array(&self) -> Array
Materialises a contiguous Array holding all rows.
Sourcepub fn field(&self) -> &Field
pub fn field(&self) -> &Field
Returns the field metadata from the first chunk (guaranteed by constructor).
Sourcepub fn arrow_type(&self) -> ArrowType
pub fn arrow_type(&self) -> ArrowType
Returns the Arrow physical type.
Sourcepub fn is_nullable(&self) -> bool
pub fn is_nullable(&self) -> bool
Returns the nullability flag.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns total logical length (sum of all chunk lengths).
Examples found in repository?
357fn test_super_array_broadcasting() {
358 #[cfg(feature = "chunked")]
359 {
360 println!("┌─ Test 11: SuperArray (Chunked) Broadcasting");
361 println!("│ Operation: SuperArray{{[1,2],[3,4]}} * SuperArray{{[2,2],[2,2]}}");
362 println!("│ Expected: SuperArray{{[2,4],[6,8]}}");
363
364 // Create chunked arrays (multiple field array chunks)
365 let chunk1_a = Array::from_int32(IntegerArray::from_slice(&vec64![1, 2]));
366 let chunk2_a = Array::from_int32(IntegerArray::from_slice(&vec64![3, 4]));
367 let fa1 = minarrow::FieldArray::from_arr("chunk1", chunk1_a);
368 let fa2 = minarrow::FieldArray::from_arr("chunk1", chunk2_a);
369 let super_arr1 = SuperArray::from_field_array_chunks(vec![fa1, fa2]);
370
371 let chunk1_b = Array::from_int32(IntegerArray::from_slice(&vec64![2, 2]));
372 let chunk2_b = Array::from_int32(IntegerArray::from_slice(&vec64![2, 2]));
373 let fa3 = minarrow::FieldArray::from_arr("chunk1", chunk1_b);
374 let fa4 = minarrow::FieldArray::from_arr("chunk1", chunk2_b);
375 let super_arr2 = SuperArray::from_field_array_chunks(vec![fa3, fa4]);
376
377 match Value::SuperArray(Arc::new(super_arr1)) * Value::SuperArray(Arc::new(super_arr2)) {
378 Ok(Value::SuperArray(result)) => {
379 println!("│ Result with {} chunks:", result.len());
380 for i in 0..result.len() {
381 if let Some(fa) = result.chunk(i) {
382 if let Array::NumericArray(NumericArray::Int32(arr)) = &fa.array {
383 println!("│ Chunk {}: {:?}", i, arr.data.as_slice());
384 }
385 }
386 }
387 println!("└─ ✓ Passed\n");
388 }
389 Ok(other) => println!("└─ ✗ Error: Unexpected result type {:?}\n", other),
390 Err(e) => println!("└─ ✗ Error: {:?}\n", e),
391 }
392 }
393
394 #[cfg(not(feature = "chunked"))]
395 {
396 println!("┌─ Test 11: SuperArray (Chunked) Broadcasting");
397 println!("└─ ⊘ Skipped (chunked feature not enabled)\n");
398 }
399}Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the array has no chunks or all chunks are empty.
Sourcepub fn chunks(&self) -> &[FieldArray]
pub fn chunks(&self) -> &[FieldArray]
Returns a read-only reference to all underlying chunks.
Sourcepub fn chunks_mut(&mut self) -> &mut [FieldArray]
pub fn chunks_mut(&mut self) -> &mut [FieldArray]
Returns a mutable reference to the underlying chunks.
Sourcepub fn chunk(&self, idx: usize) -> Option<&FieldArray>
pub fn chunk(&self, idx: usize) -> Option<&FieldArray>
Returns a reference to a specific chunk, if it exists.
Examples found in repository?
357fn test_super_array_broadcasting() {
358 #[cfg(feature = "chunked")]
359 {
360 println!("┌─ Test 11: SuperArray (Chunked) Broadcasting");
361 println!("│ Operation: SuperArray{{[1,2],[3,4]}} * SuperArray{{[2,2],[2,2]}}");
362 println!("│ Expected: SuperArray{{[2,4],[6,8]}}");
363
364 // Create chunked arrays (multiple field array chunks)
365 let chunk1_a = Array::from_int32(IntegerArray::from_slice(&vec64![1, 2]));
366 let chunk2_a = Array::from_int32(IntegerArray::from_slice(&vec64![3, 4]));
367 let fa1 = minarrow::FieldArray::from_arr("chunk1", chunk1_a);
368 let fa2 = minarrow::FieldArray::from_arr("chunk1", chunk2_a);
369 let super_arr1 = SuperArray::from_field_array_chunks(vec![fa1, fa2]);
370
371 let chunk1_b = Array::from_int32(IntegerArray::from_slice(&vec64![2, 2]));
372 let chunk2_b = Array::from_int32(IntegerArray::from_slice(&vec64![2, 2]));
373 let fa3 = minarrow::FieldArray::from_arr("chunk1", chunk1_b);
374 let fa4 = minarrow::FieldArray::from_arr("chunk1", chunk2_b);
375 let super_arr2 = SuperArray::from_field_array_chunks(vec![fa3, fa4]);
376
377 match Value::SuperArray(Arc::new(super_arr1)) * Value::SuperArray(Arc::new(super_arr2)) {
378 Ok(Value::SuperArray(result)) => {
379 println!("│ Result with {} chunks:", result.len());
380 for i in 0..result.len() {
381 if let Some(fa) = result.chunk(i) {
382 if let Array::NumericArray(NumericArray::Int32(arr)) = &fa.array {
383 println!("│ Chunk {}: {:?}", i, arr.data.as_slice());
384 }
385 }
386 }
387 println!("└─ ✓ Passed\n");
388 }
389 Ok(other) => println!("└─ ✗ Error: Unexpected result type {:?}\n", other),
390 Err(e) => println!("└─ ✗ Error: {:?}\n", e),
391 }
392 }
393
394 #[cfg(not(feature = "chunked"))]
395 {
396 println!("┌─ Test 11: SuperArray (Chunked) Broadcasting");
397 println!("└─ ⊘ Skipped (chunked feature not enabled)\n");
398 }
399}Sourcepub fn push(&mut self, chunk: FieldArray)
pub fn push(&mut self, chunk: FieldArray)
Validates and appends a new chunk.
§Panics
If the chunk does not match the expected type or nullability.
Trait Implementations§
Source§impl Add for SuperArray
Available on crate feature chunked only.
impl Add for SuperArray
chunked only.Source§impl ByteSize for SuperArray
Available on crate feature chunked only.
impl ByteSize for SuperArray
chunked only.Source§impl Clone for SuperArray
impl Clone for SuperArray
Source§fn clone(&self) -> SuperArray
fn clone(&self) -> SuperArray
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Concatenate for SuperArray
impl Concatenate for SuperArray
Source§fn concat(self, other: Self) -> Result<Self, MinarrowError>
fn concat(self, other: Self) -> Result<Self, MinarrowError>
Concatenates two SuperArrays by appending all chunks from other to self.
§Requirements
- Both SuperArrays must have the same field metadata (name, type, nullability)
§Returns
A new SuperArray containing all chunks from self followed by all chunks from other
§Errors
IncompatibleTypeErrorif field metadata doesn’t match
Source§impl Debug for SuperArray
impl Debug for SuperArray
Source§impl Default for SuperArray
impl Default for SuperArray
Source§impl Display for SuperArray
impl Display for SuperArray
Source§impl Div for SuperArray
Available on crate feature chunked only.
impl Div for SuperArray
chunked only.Source§impl From<FieldArray> for SuperArray
impl From<FieldArray> for SuperArray
Source§fn from(field_array: FieldArray) -> Self
fn from(field_array: FieldArray) -> Self
Source§impl From<SuperArray> for SuperArrayV
SuperArray -> SuperArrayV conversion
impl From<SuperArray> for SuperArrayV
SuperArray -> SuperArrayV conversion
Source§fn from(super_array: SuperArray) -> Self
fn from(super_array: SuperArray) -> Self
Source§impl From<SuperArray> for Value
Available on crate feature chunked only.
impl From<SuperArray> for Value
chunked only.Source§fn from(v: SuperArray) -> Self
fn from(v: SuperArray) -> Self
Source§impl FromIterator<FieldArray> for SuperArray
impl FromIterator<FieldArray> for SuperArray
Source§fn from_iter<T: IntoIterator<Item = FieldArray>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = FieldArray>>(iter: T) -> Self
Source§impl Mul for SuperArray
Available on crate feature chunked only.
impl Mul for SuperArray
chunked only.Source§impl PartialEq for SuperArray
impl PartialEq for SuperArray
Source§impl Rem for SuperArray
Available on crate feature chunked only.
impl Rem for SuperArray
chunked only.Source§impl Shape for SuperArray
impl Shape for SuperArray
Source§impl Sub for SuperArray
Available on crate feature chunked only.
impl Sub for SuperArray
chunked only.Source§impl TryFrom<Value> for SuperArray
Available on crate feature chunked only.
impl TryFrom<Value> for SuperArray
chunked only.impl StructuralPartialEq for SuperArray
Auto Trait Implementations§
impl Freeze for SuperArray
impl RefUnwindSafe for SuperArray
impl Send for SuperArray
impl Sync for SuperArray
impl Unpin for SuperArray
impl UnwindSafe for SuperArray
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CustomValue for T
impl<T> CustomValue for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.