pub struct OffsetBuffer<I: OffsetSizeTrait> {
pub offsets: Vec<I>,
pub values: Vec<u8>,
}Expand description
A buffer of variable-sized byte arrays that can be converted into
a corresponding [ArrayRef]
Fields§
§offsets: Vec<I>§values: Vec<u8>Implementations§
Source§impl<I: OffsetSizeTrait> OffsetBuffer<I>
impl<I: OffsetSizeTrait> OffsetBuffer<I>
pub fn is_empty(&self) -> bool
Sourcepub fn try_push(&mut self, data: &[u8], validate_utf8: bool) -> Result<()>
pub fn try_push(&mut self, data: &[u8], validate_utf8: bool) -> Result<()>
If validate_utf8 this verifies that the first character of data is
the start of a UTF-8 codepoint
Note: This does not verify that the entirety of data is valid
UTF-8. This should be done by calling Self::check_valid_utf8 after
all data has been written
Sourcepub fn extend_from_dictionary<K: ArrowNativeType, V: ArrowNativeType>(
&mut self,
keys: &[K],
dict_offsets: &[V],
dict_values: &[u8],
) -> Result<()>
pub fn extend_from_dictionary<K: ArrowNativeType, V: ArrowNativeType>( &mut self, keys: &[K], dict_offsets: &[V], dict_values: &[u8], ) -> Result<()>
Extends this buffer with a list of keys
For each value key in keys this will insert
&dict_values[dict_offsets[key]..dict_offsets[key+1]]
Note: This will validate offsets are valid
Sourcepub fn check_valid_utf8(&self, start_offset: usize) -> Result<()>
pub fn check_valid_utf8(&self, start_offset: usize) -> Result<()>
Validates that &self.values[start_offset..] is a valid UTF-8 sequence
This MUST be combined with validating that the offsets start on a character boundary, otherwise it would be possible for the values array to be a valid UTF-8 sequence, but not the individual string slices it contains
Self::try_push can perform this validation check on insertion
Sourcepub fn into_array(
self,
null_buffer: Option<Buffer>,
data_type: ArrowType,
) -> ArrayRef
pub fn into_array( self, null_buffer: Option<Buffer>, data_type: ArrowType, ) -> ArrayRef
Converts this into an [ArrayRef] with the provided data_type and null_buffer
Trait Implementations§
Source§impl<I: Debug + OffsetSizeTrait> Debug for OffsetBuffer<I>
impl<I: Debug + OffsetSizeTrait> Debug for OffsetBuffer<I>
Source§impl<I: OffsetSizeTrait> Default for OffsetBuffer<I>
impl<I: OffsetSizeTrait> Default for OffsetBuffer<I>
Source§impl<I: OffsetSizeTrait> ValuesBuffer for OffsetBuffer<I>
impl<I: OffsetSizeTrait> ValuesBuffer for OffsetBuffer<I>
Source§fn pad_nulls(
&mut self,
read_offset: usize,
values_read: usize,
levels_read: usize,
valid_mask: &[u8],
)
fn pad_nulls( &mut self, read_offset: usize, values_read: usize, levels_read: usize, valid_mask: &[u8], )
ValuesBuffer. Read more