pub trait View:
MaskedArray
+ Into<Array>
+ Clone{
type BufferT: Default + PartialEq + Clone + Copy;
// Provided methods
fn as_slice(&self) -> &[Self::BufferT] { ... }
fn slice(
&self,
offset: usize,
len: usize,
) -> (&[Self::BufferT], usize, usize) { ... }
fn view(self, offset: usize, len: usize) -> ArrayV { ... }
fn view_tuple(self, offset: usize, len: usize) -> (Array, usize, usize) { ... }
}Expand description
§View trait
Zero-copy, windowed access to array data with multiple abstraction levels.
§Description
The View trait provides a unified interface for creating logical subviews
into arrays without duplicating their underlying buffers. It is implemented by
all MaskedArray types and supports three main access patterns:
- Native slice access – direct
&[T]or&[u8]for fixed- and variable-width data. - ArrayView – an
Arc-cloned, type-aware view with safe windowing and typed accessors. - TupleView – a minimal
(&Array, offset, length)form for maximum performance.
§Purpose
This trait indirectly supports pipelines, joins, and analytics that need read-only subsets of arrays without the cost of copying or reallocating.
§Ownership Semantics
- When called on an
Arc-wrapped array (e.g.,Array),.view()consumes theArc. Clone theArcfirst if you need to retain the original. - When called on a direct array variant,
.view()consumes ownership. Wrap inArrayfirst if you need continued access.
§Behaviour
- Views enforce logical offset/length constraints.
- Access methods such as
.num(),.text(),.dt(),.bool()return typed view variants. - Always zero-copy: only offset and length metadata change, not the backing buffers.
§Compared to Apache Arrow
Arrow arrays are lightweight views over reference-counted buffers
(the view + buffers are separate types). In MinArrow, an Array
already owns an Arc to its inner buffers; a View (e.g., ArrayV)
simply adds window (offset/length) metadata on top of that same Arc’d data.
In both designs there’s effectively one layer of ref counting; the key
difference is that Apache Arrow bakes “view-ness” into the array type itself,
whereas MinArrow keeps arrays concrete and layers windowing as a separate view.
Required Associated Types§
Provided Methods§
Sourcefn view(self, offset: usize, len: usize) -> ArrayV
fn view(self, offset: usize, len: usize) -> ArrayV
Returns a zero-copy, windowed view (ArrayView) into this array.
§Ownership Semantics
- For
Arc-wrapped arrays (e.g.,Array), this method consumes theArc. If you need to retain access to the original array after callingview, clone theArcat the call site (cheap pointer clone). - For direct array variants (e.g.,
IntegerArray<u64>), callingviewconsumes ownership. If continued access to the original is required, promote the variant into anArc(orArray) first.
§Behaviour
- The returned
ArrayViewenforces the window (offset,length) and provides safe, zero-copy access. - The backing array remains accessible via
&Arraywithin the view. - Type-specific accessors (
.num(),.str(),.bool(),.dt()) are available onArrayViewfor ergonomic, typed access.
§Implementation Notes
- Unlike
Apache Arrow, where arrays are trait-based views over reference-counted buffers,MinArrowuses a concreteArraystruct which already holds a zero-copyArcreference to its inner array data. ArrayViewtherefore provides a windowed zero-copy view into a specific region of this array.
§Parameters
offset: The logical start index for the window.len: The logical length of the window.
§Returns
An ArrayView representing the specified logical window.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl View for Arc<CategoricalArray<u8>>
Available on crate features default_categorical_8 and views only.
impl View for Arc<CategoricalArray<u8>>
default_categorical_8 and views only.Implementors§
Source§impl View for CategoricalArray<u8>
Available on crate features default_categorical_8 and views only.
impl View for CategoricalArray<u8>
default_categorical_8 and views only.Source§impl View for IntegerArray<i32>
Available on crate feature views only.
impl View for IntegerArray<i32>
views only.Source§impl View for IntegerArray<i64>
Available on crate feature views only.
impl View for IntegerArray<i64>
views only.Source§impl View for IntegerArray<u32>
Available on crate feature views only.
impl View for IntegerArray<u32>
views only.Source§impl View for IntegerArray<u64>
Available on crate feature views only.
impl View for IntegerArray<u64>
views only.