Struct arrow_array::array::GenericByteArray
source · pub struct GenericByteArray<T: ByteArrayType> { /* private fields */ }
Expand description
Generic struct for variable-size byte arrays
See StringArray
and LargeStringArray
for storing utf8 encoded string data
See BinaryArray
and LargeBinaryArray
for storing arbitrary bytes
Implementations§
source§impl<OffsetSize: OffsetSizeTrait> GenericByteArray<GenericBinaryType<OffsetSize>>
impl<OffsetSize: OffsetSizeTrait> GenericByteArray<GenericBinaryType<OffsetSize>>
sourcepub const fn get_data_type() -> DataType
👎Deprecated: please use Self::DATA_TYPE
instead
pub const fn get_data_type() -> DataType
Self::DATA_TYPE
insteadGet the data type of the array.
sourcepub fn from_vec(v: Vec<&[u8]>) -> Self
pub fn from_vec(v: Vec<&[u8]>) -> Self
Creates a GenericBinaryArray from a vector of byte slices
See also Self::from_iter_values
sourcepub fn from_opt_vec(v: Vec<Option<&[u8]>>) -> Self
pub fn from_opt_vec(v: Vec<Option<&[u8]>>) -> Self
Creates a GenericBinaryArray from a vector of Optional (null) byte slices
sourcepub fn from_iter_values<Ptr, I>(iter: I) -> Selfwhere
Ptr: AsRef<[u8]>,
I: IntoIterator<Item = Ptr>,
pub fn from_iter_values<Ptr, I>(iter: I) -> Selfwhere Ptr: AsRef<[u8]>, I: IntoIterator<Item = Ptr>,
Creates a GenericBinaryArray
based on an iterator of values without nulls
sourcepub fn take_iter<'a>(
&'a self,
indexes: impl Iterator<Item = Option<usize>> + 'a
) -> impl Iterator<Item = Option<&[u8]>> + 'a
pub fn take_iter<'a>( &'a self, indexes: impl Iterator<Item = Option<usize>> + 'a ) -> impl Iterator<Item = Option<&[u8]>> + 'a
Returns an iterator that returns the values of array.value(i)
for an iterator with each element i
sourcepub unsafe fn take_iter_unchecked<'a>(
&'a self,
indexes: impl Iterator<Item = Option<usize>> + 'a
) -> impl Iterator<Item = Option<&[u8]>> + 'a
pub unsafe fn take_iter_unchecked<'a>( &'a self, indexes: impl Iterator<Item = Option<usize>> + 'a ) -> impl Iterator<Item = Option<&[u8]>> + 'a
Returns an iterator that returns the values of array.value(i)
for an iterator with each element i
Safety
caller must ensure that the indexes in the iterator are less than the array.len()
source§impl<T: ByteArrayType> GenericByteArray<T>
impl<T: ByteArrayType> GenericByteArray<T>
sourcepub fn value_length(&self, i: usize) -> T::Offset
pub fn value_length(&self, i: usize) -> T::Offset
sourcepub fn value_data(&self) -> &[u8] ⓘ
pub fn value_data(&self) -> &[u8] ⓘ
Returns the raw value data
sourcepub fn value_offsets(&self) -> &[T::Offset]
pub fn value_offsets(&self) -> &[T::Offset]
Returns the offset values in the offsets buffer
sourcepub unsafe fn value_unchecked(&self, i: usize) -> &T::Native
pub unsafe fn value_unchecked(&self, i: 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
sourcepub fn into_builder(self) -> Result<GenericByteBuilder<T>, Self>
pub fn into_builder(self) -> Result<GenericByteBuilder<T>, Self>
Returns GenericByteBuilder
of this byte array for mutating its values if the underlying
offset and data buffers are not shared by others.
source§impl<OffsetSize: OffsetSizeTrait> GenericByteArray<GenericStringType<OffsetSize>>
impl<OffsetSize: OffsetSizeTrait> GenericByteArray<GenericStringType<OffsetSize>>
sourcepub const fn get_data_type() -> DataType
👎Deprecated: please use Self::DATA_TYPE
instead
pub const fn get_data_type() -> DataType
Self::DATA_TYPE
insteadGet the data type of the array.
sourcepub fn num_chars(&self, i: usize) -> usize
pub fn num_chars(&self, i: usize) -> usize
Returns the number of Unicode Scalar Value
in the string at index i
.
Performance
This function has O(n)
time complexity where n
is the string length.
If you can make sure that all chars in the string are in the range U+0x0000
~ U+0x007F
,
please use the function value_length
which has O(1) time complexity.
sourcepub fn from_iter_values<Ptr, I>(iter: I) -> Selfwhere
Ptr: AsRef<str>,
I: IntoIterator<Item = Ptr>,
pub fn from_iter_values<Ptr, I>(iter: I) -> Selfwhere Ptr: AsRef<str>, I: IntoIterator<Item = Ptr>,
Creates a GenericStringArray
based on an iterator of values without nulls
sourcepub fn take_iter<'a>(
&'a self,
indexes: impl Iterator<Item = Option<usize>> + 'a
) -> impl Iterator<Item = Option<&str>> + 'a
pub fn take_iter<'a>( &'a self, indexes: impl Iterator<Item = Option<usize>> + 'a ) -> impl Iterator<Item = Option<&str>> + 'a
Returns an iterator that returns the values of array.value(i)
for an iterator with each element i
sourcepub unsafe fn take_iter_unchecked<'a>(
&'a self,
indexes: impl Iterator<Item = Option<usize>> + 'a
) -> impl Iterator<Item = Option<&str>> + 'a
pub unsafe fn take_iter_unchecked<'a>( &'a self, indexes: impl Iterator<Item = Option<usize>> + 'a ) -> impl Iterator<Item = Option<&str>> + 'a
Returns an iterator that returns the values of array.value(i)
for an iterator with each element i
Safety
caller must ensure that the indexes in the iterator are less than the array.len()
sourcepub fn try_from_binary(
v: GenericBinaryArray<OffsetSize>
) -> Result<Self, ArrowError>
pub fn try_from_binary( v: GenericBinaryArray<OffsetSize> ) -> Result<Self, ArrowError>
Fallibly creates a GenericStringArray
from a GenericBinaryArray
returning
an error if GenericBinaryArray
contains invalid UTF-8 data
Trait Implementations§
source§impl<T: ByteArrayType> Array for GenericByteArray<T>
impl<T: ByteArrayType> Array for GenericByteArray<T>
source§fn data_ref(&self) -> &ArrayData
fn data_ref(&self) -> &ArrayData
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 is_null(&self, index: usize) -> bool
fn is_null(&self, index: usize) -> bool
index
is null.
When using this function on a slice, the index is relative to the slice. Read moresource§fn is_valid(&self, index: usize) -> bool
fn is_valid(&self, index: usize) -> bool
index
is not null.
When using this function on a slice, the index is relative to the slice. Read moresource§fn null_count(&self) -> usize
fn null_count(&self) -> usize
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.