pub struct GenericByteViewArray<T: ByteViewType + ?Sized> { /* private fields */ }
Expand description
Variable-size Binary View Layout: An array of variable length bytes view arrays.
Different than crate::GenericByteArray
as it stores both an offset and length
meaning that take / filter operations can be implemented without copying the underlying data.
See StringViewArray
for storing utf8 encoded string data and
BinaryViewArray
for storing bytes.
A GenericByteViewArray
stores variable length byte strings. An array of
N
elements is stored as N
fixed length “views” and a variable number
of variable length “buffers”.
Each view is a u128
value layout is different depending on the
length of the string stored at that location:
┌──────┬────────────────────────┐
│length│ string value │
Strings (len <= 12) │ │ (padded with 0) │
└──────┴────────────────────────┘
0 31 127
┌───────┬───────┬───────┬───────┐
│length │prefix │ buf │offset │
Strings (len > 12) │ │ │ index │ │
└───────┴───────┴───────┴───────┘
0 31 63 95 127
-
Strings with length <= 12 are stored directly in the view.
-
Strings with length > 12: The first four bytes are stored inline in the view and the entire string is stored in one of the buffers.
Unlike GenericByteArray
, there are no constraints on the offsets other
than they must point into a valid buffer. However, they can be out of order,
non continuous and overlapping.
For example, in the following diagram, the strings “FishWasInTownToday” and “CrumpleFacedFish” are both longer than 12 bytes and thus are stored in a separate buffer while the string “LavaMonster” is stored inlined in the view. In this case, the same bytes for “Fish” are used to store both strings.
┌───┐
┌──────┬──────┬──────┬──────┐ offset │...│
"FishWasInTownTodayYay" │ 21 │ Fish │ 0 │ 115 │─ ─ 103 │Mr.│
└──────┴──────┴──────┴──────┘ │ ┌ ─ ─ ─ ─ ▶ │Cru│
┌──────┬──────┬──────┬──────┐ │mpl│
"CrumpleFacedFish" │ 16 │ Crum │ 0 │ 103 │─ ─│─ ─ ─ ┘ │eFa│
└──────┴──────┴──────┴──────┘ │ced│
┌──────┬────────────────────┐ └ ─ ─ ─ ─ ─ ─ ─ ─ ▶│Fis│
"LavaMonster" │ 11 │ LavaMonster\0 │ │hWa│
└──────┴────────────────────┘ offset │sIn│
115 │Tow│
│nTo│
│day│
u128 "views" │Yay│
buffer 0 │...│
└───┘
Implementations§
Source§impl<T: ByteViewType + ?Sized> GenericByteViewArray<T>
impl<T: ByteViewType + ?Sized> GenericByteViewArray<T>
Sourcepub fn new(
views: ScalarBuffer<u128>,
buffers: Vec<Buffer>,
nulls: Option<NullBuffer>,
) -> Self
pub fn new( views: ScalarBuffer<u128>, buffers: Vec<Buffer>, nulls: Option<NullBuffer>, ) -> Self
Create a new GenericByteViewArray
from the provided parts, panicking on failure
§Panics
Panics if GenericByteViewArray::try_new
returns an error
Sourcepub fn try_new(
views: ScalarBuffer<u128>,
buffers: Vec<Buffer>,
nulls: Option<NullBuffer>,
) -> Result<Self, ArrowError>
pub fn try_new( views: ScalarBuffer<u128>, buffers: Vec<Buffer>, nulls: Option<NullBuffer>, ) -> Result<Self, ArrowError>
Create a new GenericByteViewArray
from the provided parts, returning an error on failure
§Errors
views.len() != nulls.len()
- ByteViewType::validate fails
Sourcepub unsafe fn new_unchecked(
views: ScalarBuffer<u128>,
buffers: Vec<Buffer>,
nulls: Option<NullBuffer>,
) -> Self
pub unsafe fn new_unchecked( views: ScalarBuffer<u128>, buffers: Vec<Buffer>, nulls: Option<NullBuffer>, ) -> Self
Create a new GenericByteViewArray
from the provided parts, without validation
§Safety
Safe if Self::try_new
would not error
Sourcepub fn new_null(len: usize) -> Self
pub fn new_null(len: usize) -> Self
Create a new GenericByteViewArray
of length len
where all values are null
Sourcepub fn from_iter_values<Ptr, I>(iter: I) -> Self
pub fn from_iter_values<Ptr, I>(iter: I) -> Self
Creates a GenericByteViewArray
based on an iterator of values without nulls
Sourcepub fn into_parts(self) -> (ScalarBuffer<u128>, Vec<Buffer>, Option<NullBuffer>)
pub fn into_parts(self) -> (ScalarBuffer<u128>, Vec<Buffer>, Option<NullBuffer>)
Deconstruct this array into its constituent parts
Sourcepub fn views(&self) -> &ScalarBuffer<u128>
pub fn views(&self) -> &ScalarBuffer<u128>
Returns the views buffer
Sourcepub fn data_buffers(&self) -> &[Buffer]
pub fn data_buffers(&self) -> &[Buffer]
Returns the buffers storing string data
Sourcepub unsafe fn value_unchecked(&self, idx: usize) -> &T::Native
pub unsafe fn value_unchecked(&self, idx: usize) -> &T::Native
Returns the element at index i
§Safety
Caller is responsible for ensuring that the index is within the bounds of the array
Trait Implementations§
Source§impl<T: ByteViewType + ?Sized> Array for GenericByteViewArray<T>
impl<T: ByteViewType + ?Sized> Array for GenericByteViewArray<T>
Source§fn slice(&self, offset: usize, length: usize) -> ArrayRef
fn slice(&self, offset: usize, length: usize) -> ArrayRef
Source§fn offset(&self) -> usize
fn offset(&self) -> usize
0
. Read moreSource§fn nulls(&self) -> Option<&NullBuffer>
fn nulls(&self) -> Option<&NullBuffer>
Source§fn get_buffer_memory_size(&self) -> usize
fn get_buffer_memory_size(&self) -> usize
Source§fn get_array_memory_size(&self) -> usize
fn get_array_memory_size(&self) -> usize
get_buffer_memory_size()
and
includes the overhead of the data structures that contain the pointers to the various buffers.Source§fn logical_nulls(&self) -> Option<NullBuffer>
fn logical_nulls(&self) -> Option<NullBuffer>
NullBuffer
that represents the logical
null values of this array, if any. Read moreSource§fn null_count(&self) -> usize
fn null_count(&self) -> usize
Source§fn is_nullable(&self) -> bool
fn is_nullable(&self) -> bool
false
if the array is guaranteed to not contain any logical nulls Read moreSource§impl<'a, T: ByteViewType + ?Sized> ArrayAccessor for &'a GenericByteViewArray<T>
impl<'a, T: ByteViewType + ?Sized> ArrayAccessor for &'a GenericByteViewArray<T>
Source§impl<T: ByteViewType + ?Sized> Clone for GenericByteViewArray<T>
impl<T: ByteViewType + ?Sized> Clone for GenericByteViewArray<T>
Source§impl<T: ByteViewType + ?Sized> Debug for GenericByteViewArray<T>
impl<T: ByteViewType + ?Sized> Debug for GenericByteViewArray<T>
Source§impl<T: ByteViewType + ?Sized> From<ArrayData> for GenericByteViewArray<T>
impl<T: ByteViewType + ?Sized> From<ArrayData> for GenericByteViewArray<T>
Source§impl<T: ByteViewType + ?Sized> From<GenericByteViewArray<T>> for ArrayData
impl<T: ByteViewType + ?Sized> From<GenericByteViewArray<T>> for ArrayData
Source§fn from(array: GenericByteViewArray<T>) -> Self
fn from(array: GenericByteViewArray<T>) -> Self
Source§impl<Ptr, T: ByteViewType + ?Sized> FromIterator<Option<Ptr>> for GenericByteViewArray<T>
impl<Ptr, T: ByteViewType + ?Sized> FromIterator<Option<Ptr>> for GenericByteViewArray<T>
Source§impl<'a, T: ByteViewType + ?Sized> IntoIterator for &'a GenericByteViewArray<T>
impl<'a, T: ByteViewType + ?Sized> IntoIterator for &'a GenericByteViewArray<T>
Auto Trait Implementations§
impl<T> Freeze for GenericByteViewArray<T>where
T: ?Sized,
impl<T> RefUnwindSafe for GenericByteViewArray<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for GenericByteViewArray<T>where
T: ?Sized,
impl<T> Sync for GenericByteViewArray<T>where
T: ?Sized,
impl<T> Unpin for GenericByteViewArray<T>
impl<T> UnwindSafe for GenericByteViewArray<T>where
T: UnwindSafe + ?Sized,
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)