Skip to main content

Array

Trait Array 

Source
pub trait Array:
    Debug
    + Send
    + Sync
    + Sealed
    + 'static {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn data_type(&self) -> &DataType;
    fn len(&self) -> usize;
    fn validity(&self) -> Option<&Bitmap>;
    fn slice(&self, offset: usize, len: usize) -> ArrayRef;
    fn buffer_memory_size(&self) -> usize;
    fn equals(&self, other: &dyn Array) -> bool;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn null_count(&self) -> usize { ... }
    fn is_null(&self, index: usize) -> bool { ... }
    fn is_valid(&self, index: usize) -> bool { ... }
    fn children(&self) -> Vec<&ArrayRef> ⓘ { ... }
}
Expand description

The behaviour every array family provides.

Sealed: the implementor set is fixed by this crate (see array_kinds).

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Erased self, for ArrayExt::downcast.

Source

fn data_type(&self) -> &DataType

The array’s layout.

Source

fn len(&self) -> usize

Number of logical slots.

Source

fn validity(&self) -> Option<&Bitmap>

The validity bitmap, or None when every slot is valid.

Arrow calls this the null buffer; here 1 means valid, matching the bit convention in crate::buffer::bitmap.

Source

fn slice(&self, offset: usize, len: usize) -> ArrayRef

A zero-copy sub-range.

Clamping is the crate-wide convention: offset beyond the end yields an empty array, and len beyond the end is truncated. Nothing panics. Use try_slice when an out-of-range request is a bug worth reporting.

use astrs_data::array::{Array, Int32Array};

let values = Int32Array::from_values([1, 2, 3, 4]);
assert_eq!(Array::slice(&values, 1, 2).len(), 2);
assert_eq!(Array::slice(&values, 3, 99).len(), 1);
assert_eq!(Array::slice(&values, 99, 1).len(), 0);
Source

fn buffer_memory_size(&self) -> usize

Bytes of buffer memory this array pins, including shared allocations it only partly covers.

Used by the daemon’s memory accounting and by stage 2 to size an IPC body before encoding.

Source

fn equals(&self, other: &dyn Array) -> bool

Structural equality against another array, used by the PartialEq implementation on dyn Array.

Implementors downcast and compare their own representation, so a sliced array equals an unsliced one with the same logical values.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true when the array has no slots.

Source

fn null_count(&self) -> usize

Number of null slots.

Source

fn is_null(&self, index: usize) -> bool

Returns true when slot index is null. Out-of-range indices are reported as null.

Source

fn is_valid(&self, index: usize) -> bool

Returns true when slot index holds a value.

Source

fn children(&self) -> Vec<&ArrayRef> ⓘ

The child arrays this array owns, in field order. Empty for leaf types.

Trait Implementations§

Source§

impl ArrayExt for dyn Array

Source§

fn downcast<A: Array>(&self) -> Option<&A>

Downcasts to a concrete array type, or None on a type mismatch.
Source§

fn try_downcast<A: Array>(&self) -> Result<&A>

Downcasts to a concrete array type. Read more
Source§

impl PartialEq for dyn Array

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<dyn Array> for ArrayRef

Source§

fn eq(&self, other: &dyn Array) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§