pub struct FixedSizeBinaryArray { /* private fields */ }Expand description
A column of size-byte blobs with an optional validity bitmap.
Implementations§
Source§impl FixedSizeBinaryArray
impl FixedSizeBinaryArray
Sourcepub fn try_new(
size: i32,
values: Buffer,
validity: Option<Bitmap>,
) -> Result<Self>
pub fn try_new( size: i32, values: Buffer, validity: Option<Bitmap>, ) -> Result<Self>
Builds an array from a flat value buffer.
§Errors
DataError::InvalidFixedSizewhensizeis not positive.DataError::BufferLengthNotMultiplewhen the buffer is not a whole number of slots.DataError::ValidityLengthMismatchwhen the bitmap length is wrong.
use astrs_data::array::{Array, FixedSizeBinaryArray};
use astrs_data::Buffer;
let array = FixedSizeBinaryArray::try_new(2, Buffer::from_slice(b"abcd"), None)?;
assert_eq!(array.len(), 2);
assert_eq!(array.get(0), Some(&b"ab"[..]));Sourcepub fn try_from_values<V: AsRef<[u8]>>(
size: i32,
values: impl IntoIterator<Item = V>,
) -> Result<Self>
pub fn try_from_values<V: AsRef<[u8]>>( size: i32, values: impl IntoIterator<Item = V>, ) -> Result<Self>
Builds an array from equally sized slices.
§Errors
DataError::InvalidFixedSizewhensizeis not positive.DataError::ChildLengthMismatchwhen a value has the wrong length.
Sourcepub fn try_from_opt_iter<V: AsRef<[u8]>>(
size: i32,
values: impl IntoIterator<Item = Option<V>>,
) -> Result<Self>
pub fn try_from_opt_iter<V: AsRef<[u8]>>( size: i32, values: impl IntoIterator<Item = Option<V>>, ) -> Result<Self>
Builds an array from optional equally sized slices, null slots holding
size zero bytes.
§Errors
DataError::InvalidFixedSizewhensizeis not positive.DataError::ChildLengthMismatchwhen a value has the wrong length.
use astrs_data::array::{Array, FixedSizeBinaryArray};
let array = FixedSizeBinaryArray::try_from_opt_iter(2, [Some(&b"ab"[..]), None])?;
assert_eq!(array.null_count(), 1);
assert!(FixedSizeBinaryArray::try_from_values(2, [&b"abc"[..]]).is_err());Sourcepub const fn value_size(&self) -> usize
pub const fn value_size(&self) -> usize
Bytes per slot.
Sourcepub const fn value_data(&self) -> &Buffer
pub const fn value_data(&self) -> &Buffer
The flat value buffer, len * size bytes.
Sourcepub fn value(&self, index: usize) -> Option<&[u8]>
pub fn value(&self, index: usize) -> Option<&[u8]>
The raw slot bytes at index, ignoring validity.
Returns None only when index is out of range.
Sourcepub fn get(&self, index: usize) -> Option<&[u8]>
pub fn get(&self, index: usize) -> Option<&[u8]>
The logical value at index: None when the slot is null or out of
range.
Sourcepub fn slice(&self, offset: usize, len: usize) -> Self
pub fn slice(&self, offset: usize, len: usize) -> Self
A zero-copy sub-range, clamped to the array (the crate-wide slicing convention).
Sourcepub fn try_slice(&self, offset: usize, len: usize) -> Result<Self>
pub fn try_slice(&self, offset: usize, len: usize) -> Result<Self>
Checked FixedSizeBinaryArray::slice.
§Errors
DataError::SliceOutOfBounds when the window leaves the array.
Sourcepub fn with_validity(&self, validity: Option<Bitmap>) -> Result<Self>
pub fn with_validity(&self, validity: Option<Bitmap>) -> Result<Self>
Returns a copy with a different validity bitmap.
§Errors
DataError::ValidityLengthMismatch when the bitmap length is wrong.
Trait Implementations§
Source§impl Array for FixedSizeBinaryArray
impl Array for FixedSizeBinaryArray
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Erased self, for
ArrayExt::downcast.Source§fn validity(&self) -> Option<&Bitmap>
fn validity(&self) -> Option<&Bitmap>
The validity bitmap, or
None when every slot is valid. Read moreSource§fn buffer_memory_size(&self) -> usize
fn buffer_memory_size(&self) -> usize
Bytes of buffer memory this array pins, including shared allocations it
only partly covers. Read more
Source§fn null_count(&self) -> usize
fn null_count(&self) -> usize
Number of null slots.
Source§impl<'a> ArrayAccessor for &'a FixedSizeBinaryArray
impl<'a> ArrayAccessor for &'a FixedSizeBinaryArray
Source§impl Clone for FixedSizeBinaryArray
impl Clone for FixedSizeBinaryArray
Source§impl Debug for FixedSizeBinaryArray
impl Debug for FixedSizeBinaryArray
impl Eq for FixedSizeBinaryArray
Source§impl<'a> IntoIterator for &'a FixedSizeBinaryArray
impl<'a> IntoIterator for &'a FixedSizeBinaryArray
Auto Trait Implementations§
impl !Freeze for FixedSizeBinaryArray
impl RefUnwindSafe for FixedSizeBinaryArray
impl Send for FixedSizeBinaryArray
impl Sync for FixedSizeBinaryArray
impl Unpin for FixedSizeBinaryArray
impl UnsafeUnpin for FixedSizeBinaryArray
impl UnwindSafe for FixedSizeBinaryArray
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<A> IntoArrayRef for Awhere
A: Array,
impl<A> IntoArrayRef for Awhere
A: Array,
Source§fn into_array_ref(self) -> ArrayRef
fn into_array_ref(self) -> ArrayRef
Moves
self into a shared, dynamically typed column.