Struct FixedSizeBinaryArray
pub struct FixedSizeBinaryArray {
data_type: DataType,
value_data: Buffer,
nulls: Option<NullBuffer>,
len: usize,
value_length: i32,
}Expand description
An array of fixed-size binary values
Each element in a FixedSizeBinaryArray has value_length bytes, where
value_length is defined by the schema.
This array type is useful for storing fixed-length values such as 16-byte
UUIDs (value_length = 16).
§Layout
Values in a FixedSizeBinaryArray are stored contiguously in a single
buffer. The byte offset for the i-th element can be calculated as
i * value_length.
Nulls are stored in a standard optional Arrow NullBuffer.
For example, a 100-value FixedSizeBinaryArray with value_length = 12
is shown below.
┌──────────────────────────────────────────┐
│ Computed byte offsets │
│ ┌──────────────────────┐ ┌────┐ │
│ │┌────────────────────┐│ │ │ │
│ 0 ││value 0 (12 bytes) ││ │ 1 │ │
│ │├────────────────────┤│ │ │ │
│ 12 ││value 1 (12 bytes) ││ │ 0 │ │
│ │├────────────────────┤│ │ │ │
│ 24 ││value 2 (12 bytes) ││ │ 1 │ │
│ │└────────────────────┘│ │ │ │
│ │ ... │ │... │ │
│ │┌───────────────────┐ │ │ │ │
│ 1188 ││value 99 (12 bytes)│ │ │ 1 │ │
│ │└───────────────────┘ │ │ │ │
│ └──────────────────────┘ └────┘ │
│ value_data nulls │
└──────────────────────────────────────────┘§Examples
Create an array from an iterable argument of byte slices.
use arrow_array::{Array, FixedSizeBinaryArray};
let input_arg = vec![ vec![1, 2], vec![3, 4], vec![5, 6] ];
let arr = FixedSizeBinaryArray::try_from_iter(input_arg.into_iter()).unwrap();
assert_eq!(3, arr.len());
Create an array from an iterable argument of sparse byte slices.
Sparsity means that the input argument can contain None items.
use arrow_array::{Array, FixedSizeBinaryArray};
let input_arg = vec![ None, Some(vec![7, 8]), Some(vec![9, 10]), None, Some(vec![13, 14]) ];
let arr = FixedSizeBinaryArray::try_from_sparse_iter_with_size(input_arg.into_iter(), 2).unwrap();
assert_eq!(5, arr.len())
Fields§
§data_type: DataType§value_data: Buffer§nulls: Option<NullBuffer>§len: usize§value_length: i32Implementations§
§impl FixedSizeBinaryArray
impl FixedSizeBinaryArray
pub fn new(
value_length: i32,
values: Buffer,
nulls: Option<NullBuffer>,
) -> FixedSizeBinaryArray
pub fn new( value_length: i32, values: Buffer, nulls: Option<NullBuffer>, ) -> FixedSizeBinaryArray
Create a new FixedSizeBinaryArray with value_length bytes per element, panicking on
failure
§Panics
Panics if Self::try_new returns an error
pub fn new_scalar(value: impl AsRef<[u8]>) -> Scalar<FixedSizeBinaryArray>
pub fn new_scalar(value: impl AsRef<[u8]>) -> Scalar<FixedSizeBinaryArray>
Create a new Scalar from value
pub fn try_new(
value_length: i32,
values: Buffer,
nulls: Option<NullBuffer>,
) -> Result<FixedSizeBinaryArray, ArrowError>
pub fn try_new( value_length: i32, values: Buffer, nulls: Option<NullBuffer>, ) -> Result<FixedSizeBinaryArray, ArrowError>
Create a new FixedSizeBinaryArray from the provided parts, returning an error on failure
Creating an array with value_length == 0 will try to get the length from the null
buffer. If no null buffer is provided, the resulting array will have length zero.
§Errors
value_length < 0values.len() / value_length != nulls.len()value_length == 0 && values.len() != 0len * value_length > i32::MAX
pub fn new_null(value_length: i32, len: usize) -> FixedSizeBinaryArray
pub fn new_null(value_length: i32, len: usize) -> FixedSizeBinaryArray
Create a new FixedSizeBinaryArray of length len where all values are null
§Panics
Panics if
value_length < 0value_length * lenwould overflowusizevalue_length * len > i32::MAXvalue_length * len * 8would overflowusize
pub fn into_parts(self) -> (i32, Buffer, Option<NullBuffer>)
pub fn into_parts(self) -> (i32, Buffer, Option<NullBuffer>)
Deconstruct this array into its constituent parts
pub unsafe fn value_unchecked(&self, i: usize) -> &[u8] ⓘ
pub unsafe fn value_unchecked(&self, i: usize) -> &[u8] ⓘ
pub fn value_offset(&self, i: usize) -> i32
pub fn value_offset(&self, i: usize) -> i32
Returns the offset for the element at index i.
Note this doesn’t do any bound checking, for performance reason.
pub fn value_length(&self) -> i32
pub fn value_length(&self) -> i32
Returns the length for an element.
All elements have the same length as the array is a fixed size.
pub fn values(&self) -> &Buffer
pub fn values(&self) -> &Buffer
Returns the values of this array.
Unlike Self::value_data this returns the Buffer
allowing for zero-copy cloning.
pub fn value_data(&self) -> &[u8] ⓘ
pub fn value_data(&self) -> &[u8] ⓘ
Returns the raw value data.
pub fn slice(&self, offset: usize, len: usize) -> FixedSizeBinaryArray
pub fn slice(&self, offset: usize, len: usize) -> FixedSizeBinaryArray
Returns a zero-copy slice of this array with the indicated offset and length.
pub fn try_from_sparse_iter<T, U>(
iter: T,
) -> Result<FixedSizeBinaryArray, ArrowError>
👎Deprecated since 28.0.0: This function will fail if the iterator produces only None values; prefer try_from_sparse_iter_with_size
pub fn try_from_sparse_iter<T, U>( iter: T, ) -> Result<FixedSizeBinaryArray, ArrowError>
This function will fail if the iterator produces only None values; prefer try_from_sparse_iter_with_size
Create an array from an iterable argument of sparse byte slices.
Sparsity means that items returned by the iterator are optional, i.e input argument can
contain None items.
§Examples
use arrow_array::FixedSizeBinaryArray;
let input_arg = vec![
None,
Some(vec![7, 8]),
Some(vec![9, 10]),
None,
Some(vec![13, 14]),
None,
];
let array = FixedSizeBinaryArray::try_from_sparse_iter(input_arg.into_iter()).unwrap();§Errors
Returns error if argument has length zero, or sizes of nested slices don’t match.
pub fn try_from_sparse_iter_with_size<T, U>(
iter: T,
value_length: i32,
) -> Result<FixedSizeBinaryArray, ArrowError>
pub fn try_from_sparse_iter_with_size<T, U>( iter: T, value_length: i32, ) -> Result<FixedSizeBinaryArray, ArrowError>
Create an array from an iterable argument of sparse byte slices.
Sparsity means that items returned by the iterator are optional, i.e input argument can
contain None items. In cases where the iterator returns only None values, this
also takes a value_length parameter to ensure that a valid
FixedSizeBinaryArray is still created.
§Examples
use arrow_array::FixedSizeBinaryArray;
let input_arg = vec![
None,
Some(vec![7, 8]),
Some(vec![9, 10]),
None,
Some(vec![13, 14]),
None,
];
let array = FixedSizeBinaryArray::try_from_sparse_iter_with_size(input_arg.into_iter(), 2).unwrap();§Errors
Returns error if argument has length zero, or sizes of nested slices don’t match.
pub fn try_from_iter<T, U>(iter: T) -> Result<FixedSizeBinaryArray, ArrowError>
pub fn try_from_iter<T, U>(iter: T) -> Result<FixedSizeBinaryArray, ArrowError>
Create an array from an iterable argument of byte slices.
§Examples
use arrow_array::FixedSizeBinaryArray;
let input_arg = vec![
vec![1, 2],
vec![3, 4],
vec![5, 6],
];
let array = FixedSizeBinaryArray::try_from_iter(input_arg.into_iter()).unwrap();§Errors
Returns error if argument has length zero, or sizes of nested slices don’t match.
pub fn iter(&self) -> ArrayIter<&FixedSizeBinaryArray> ⓘ
pub fn iter(&self) -> ArrayIter<&FixedSizeBinaryArray> ⓘ
constructs a new iterator
Trait Implementations§
§impl Array for FixedSizeBinaryArray
SAFETY: Correctly implements the contract of Arrow Arrays
impl Array for FixedSizeBinaryArray
SAFETY: Correctly implements the contract of Arrow Arrays
§fn slice(&self, offset: usize, length: usize) -> Arc<dyn Array> ⓘ
fn slice(&self, offset: usize, length: usize) -> Arc<dyn Array> ⓘ
§fn shrink_to_fit(&mut self)
fn shrink_to_fit(&mut self)
§fn offset(&self) -> usize
fn offset(&self) -> usize
0. Read more§fn nulls(&self) -> Option<&NullBuffer>
fn nulls(&self) -> Option<&NullBuffer>
§fn logical_null_count(&self) -> usize
fn logical_null_count(&self) -> usize
§fn get_buffer_memory_size(&self) -> usize
fn get_buffer_memory_size(&self) -> usize
§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.§fn claim(&self, pool: &dyn MemoryPool)
fn claim(&self, pool: &dyn MemoryPool)
§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 more§fn null_count(&self) -> usize
fn null_count(&self) -> usize
§fn is_nullable(&self) -> bool
fn is_nullable(&self) -> bool
false if the array is guaranteed to not contain any logical nulls Read more§impl<'a> ArrayAccessor for &'a FixedSizeBinaryArray
impl<'a> ArrayAccessor for &'a FixedSizeBinaryArray
§fn value(
&self,
index: usize,
) -> <&'a FixedSizeBinaryArray as ArrayAccessor>::Item
fn value( &self, index: usize, ) -> <&'a FixedSizeBinaryArray as ArrayAccessor>::Item
i Read more§unsafe fn value_unchecked(
&self,
index: usize,
) -> <&'a FixedSizeBinaryArray as ArrayAccessor>::Item
unsafe fn value_unchecked( &self, index: usize, ) -> <&'a FixedSizeBinaryArray as ArrayAccessor>::Item
i Read more§impl<'a> BinaryArrayType<'a> for &'a FixedSizeBinaryArray
impl<'a> BinaryArrayType<'a> for &'a FixedSizeBinaryArray
§fn iter(&self) -> ArrayIter<&'a FixedSizeBinaryArray> ⓘ
fn iter(&self) -> ArrayIter<&'a FixedSizeBinaryArray> ⓘ
§impl Clone for FixedSizeBinaryArray
impl Clone for FixedSizeBinaryArray
§fn clone(&self) -> FixedSizeBinaryArray
fn clone(&self) -> FixedSizeBinaryArray
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for FixedSizeBinaryArray
impl Debug for FixedSizeBinaryArray
§impl DisplayIndex for &FixedSizeBinaryArray
impl DisplayIndex for &FixedSizeBinaryArray
§impl From<ArrayData> for FixedSizeBinaryArray
impl From<ArrayData> for FixedSizeBinaryArray
§fn from(data: ArrayData) -> FixedSizeBinaryArray
fn from(data: ArrayData) -> FixedSizeBinaryArray
§impl From<FixedSizeBinaryArray> for ArrayData
impl From<FixedSizeBinaryArray> for ArrayData
§fn from(array: FixedSizeBinaryArray) -> ArrayData
fn from(array: FixedSizeBinaryArray) -> ArrayData
§impl From<FixedSizeListArray> for FixedSizeBinaryArray
Creates a FixedSizeBinaryArray from FixedSizeList<u8> array
impl From<FixedSizeListArray> for FixedSizeBinaryArray
Creates a FixedSizeBinaryArray from FixedSizeList<u8> array
§fn from(v: FixedSizeListArray) -> FixedSizeBinaryArray
fn from(v: FixedSizeListArray) -> FixedSizeBinaryArray
§impl From<Vec<&[u8]>> for FixedSizeBinaryArray
impl From<Vec<&[u8]>> for FixedSizeBinaryArray
§fn from(v: Vec<&[u8]>) -> FixedSizeBinaryArray
fn from(v: Vec<&[u8]>) -> FixedSizeBinaryArray
§impl<'a> IntoIterator for &'a FixedSizeBinaryArray
impl<'a> IntoIterator for &'a FixedSizeBinaryArray
§type IntoIter = ArrayIter<&'a FixedSizeBinaryArray>
type IntoIter = ArrayIter<&'a FixedSizeBinaryArray>
§fn into_iter(self) -> <&'a FixedSizeBinaryArray as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a FixedSizeBinaryArray as IntoIterator>::IntoIter
§impl PartialEq for FixedSizeBinaryArray
impl PartialEq for FixedSizeBinaryArray
§fn eq(&self, other: &FixedSizeBinaryArray) -> bool
fn eq(&self, other: &FixedSizeBinaryArray) -> bool
self and other values to be equal, and is used by ==.