pub trait Array:
Debug
+ Send
+ Sync
+ Sized
+ 'static
+ Into<ArrayImpl>
+ EstimateSize {
type RefItem<'a>: ScalarRef<'a, ScalarType = Self::OwnedItem>
where Self: 'a;
type OwnedItem: Clone + Debug + EstimateSize + for<'a> Scalar<ScalarRefType<'a> = Self::RefItem<'a>>;
type Builder: ArrayBuilder<ArrayType = Self>;
Show 18 methods
// Required methods
unsafe fn raw_value_at_unchecked(&self, idx: usize) -> Self::RefItem<'_>;
fn len(&self) -> usize;
fn to_protobuf(&self) -> PbArray;
fn null_bitmap(&self) -> &Bitmap;
fn into_null_bitmap(self) -> Bitmap;
fn set_bitmap(&mut self, bitmap: Bitmap);
fn data_type(&self) -> DataType;
// Provided methods
fn value_at(&self, idx: usize) -> Option<Self::RefItem<'_>> { ... }
unsafe fn value_at_unchecked(&self, idx: usize) -> Option<Self::RefItem<'_>> { ... }
fn iter(&self) -> ArrayIterator<'_, Self> ⓘ { ... }
fn raw_iter(&self) -> impl ExactSizeIterator<Item = Self::RefItem<'_>> { ... }
fn is_null(&self, idx: usize) -> bool { ... }
unsafe fn is_null_unchecked(&self, idx: usize) -> bool { ... }
fn hash_at<H: Hasher>(&self, idx: usize, state: &mut H) { ... }
fn hash_vec<H: Hasher>(&self, hashers: &mut [H], vis: &Bitmap) { ... }
fn is_empty(&self) -> bool { ... }
fn create_builder(&self, capacity: usize) -> Self::Builder { ... }
fn into_ref(self) -> ArrayRef { ... }
}
Expand description
A trait over all array.
Array
must be built with an ArrayBuilder
. The array trait provides several
unified interface on an array, like len
, value_at
and iter
.
The Builder
associated type is the builder for this array.
The Iter
associated type is the iterator of this array. And the RefItem
is
the item you could retrieve from this array.
For example, PrimitiveArray
could return an Option<u32>
, and Utf8Array
will
return an Option<&str>
.
In some cases, we will need to store owned data. For example, when aggregating min
and max, we need to store current maximum in the aggregator. In this case, we
could use A::OwnedItem
in aggregator struct.
Required Associated Types§
sourcetype RefItem<'a>: ScalarRef<'a, ScalarType = Self::OwnedItem>
where
Self: 'a
type RefItem<'a>: ScalarRef<'a, ScalarType = Self::OwnedItem> where Self: 'a
A reference to item in array, as well as return type of value_at
, which is
reciprocal to Self::OwnedItem
.
sourcetype OwnedItem: Clone + Debug + EstimateSize + for<'a> Scalar<ScalarRefType<'a> = Self::RefItem<'a>>
type OwnedItem: Clone + Debug + EstimateSize + for<'a> Scalar<ScalarRefType<'a> = Self::RefItem<'a>>
Owned type of item in array, which is reciprocal to Self::RefItem
.
sourcetype Builder: ArrayBuilder<ArrayType = Self>
type Builder: ArrayBuilder<ArrayType = Self>
Corresponding builder of this array, which is reciprocal to Array
.
Required Methods§
sourceunsafe fn raw_value_at_unchecked(&self, idx: usize) -> Self::RefItem<'_>
unsafe fn raw_value_at_unchecked(&self, idx: usize) -> Self::RefItem<'_>
Retrieve a reference to value regardless of whether it is null without checking the index boundary.
The returned value for NULL values is the default value.
§Safety
Index must be within the bounds.
sourcefn to_protobuf(&self) -> PbArray
fn to_protobuf(&self) -> PbArray
Serialize to protobuf
sourcefn null_bitmap(&self) -> &Bitmap
fn null_bitmap(&self) -> &Bitmap
Get the null Bitmap
from Array
.
sourcefn into_null_bitmap(self) -> Bitmap
fn into_null_bitmap(self) -> Bitmap
Get the owned null Bitmap
from Array
.
fn set_bitmap(&mut self, bitmap: Bitmap)
fn data_type(&self) -> DataType
Provided Methods§
sourceunsafe fn value_at_unchecked(&self, idx: usize) -> Option<Self::RefItem<'_>>
unsafe fn value_at_unchecked(&self, idx: usize) -> Option<Self::RefItem<'_>>
§Safety
Retrieve a reference to value without checking the index boundary.
sourcefn iter(&self) -> ArrayIterator<'_, Self> ⓘ
fn iter(&self) -> ArrayIterator<'_, Self> ⓘ
Get iterator of current array.
sourcefn raw_iter(&self) -> impl ExactSizeIterator<Item = Self::RefItem<'_>>
fn raw_iter(&self) -> impl ExactSizeIterator<Item = Self::RefItem<'_>>
Get raw iterator of current array.
The raw iterator simply iterates values without checking the null bitmap. The returned value for NULL values is undefined.
sourceunsafe fn is_null_unchecked(&self, idx: usize) -> bool
unsafe fn is_null_unchecked(&self, idx: usize) -> bool
§Safety
The unchecked version of is_null
, ignore index out of bound check. It is
the caller’s responsibility to ensure the index is valid.
sourcefn hash_at<H: Hasher>(&self, idx: usize, state: &mut H)
fn hash_at<H: Hasher>(&self, idx: usize, state: &mut H)
Feed the value at idx
into the given Hasher
.