Struct arrow::array::DecimalArray
source · [−]pub struct DecimalArray<T>where
T: DecimalType,{ /* private fields */ }
Expand description
A generic Array
for fixed width decimal numbers
See Decimal128Array
and Decimal256Array
Implementations
sourceimpl<T> DecimalArray<T>where
T: DecimalType,
impl<T> DecimalArray<T>where
T: DecimalType,
pub const VALUE_LENGTH: i32 = T::BYTE_LENGTH as i32
pub const MAX_PRECISION: u8 = T::MAX_PRECISION
pub const MAX_SCALE: u8 = T::MAX_SCALE
pub fn data(&self) -> &ArrayData
sourcepub fn precision(&self) -> u8
pub fn precision(&self) -> u8
Return the precision (total digits) that can be stored by this array
sourcepub fn scale(&self) -> u8
pub fn scale(&self) -> u8
Return the scale (digits after the decimal) that can be stored by this array
sourcepub unsafe fn value_unchecked(&self, i: usize) -> Decimal<T>
pub unsafe fn value_unchecked(&self, i: usize) -> Decimal<T>
Returns the element at index i
.
Safety
Caller is responsible for ensuring that the index is within the bounds of the array
sourcepub 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.
sourcepub 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.
sourcepub fn value_data(&self) -> Buffer
pub fn value_data(&self) -> Buffer
Returns a clone of the value data buffer
pub fn value_offset_at(&self, i: usize) -> i32
pub fn value_as_string(&self, row: usize) -> String
sourcepub fn from_fixed_size_binary_array(
v: FixedSizeBinaryArray,
precision: u8,
scale: u8
) -> DecimalArray<T>
pub fn from_fixed_size_binary_array(
v: FixedSizeBinaryArray,
precision: u8,
scale: u8
) -> DecimalArray<T>
Build a decimal array from FixedSizeBinaryArray
.
NB: This function does not validate that each value is in the permissible range for a decimal
sourcepub fn from_fixed_size_list_array(
v: FixedSizeListArray,
precision: u8,
scale: u8
) -> DecimalArray<T>
👎Deprecated: please use from_fixed_size_binary_array
instead
pub fn from_fixed_size_list_array(
v: FixedSizeListArray,
precision: u8,
scale: u8
) -> DecimalArray<T>
from_fixed_size_binary_array
insteadBuild a decimal array from FixedSizeListArray
.
NB: This function does not validate that each value is in the permissible range for a decimal.
sourcepub const fn default_type() -> DataType
pub const fn default_type() -> DataType
The default precision and scale used when not specified.
sourcepub fn with_precision_and_scale(
self,
precision: u8,
scale: u8
) -> Result<DecimalArray<T>, ArrowError>where
DecimalArray<T>: Sized,
pub fn with_precision_and_scale(
self,
precision: u8,
scale: u8
) -> Result<DecimalArray<T>, ArrowError>where
DecimalArray<T>: Sized,
Returns a Decimal array with the same data as self, with the specified precision.
Returns an Error if:
precision
is larger thanSelf::MAX_PRECISION
scale
is larger thanSelf::MAX_SCALE
;scale
is >precision
sourceimpl DecimalArray<Decimal128Type>
impl DecimalArray<Decimal128Type>
sourcepub fn from_iter_values<I>(iter: I) -> DecimalArray<Decimal128Type>where
I: IntoIterator<Item = i128>,
pub fn from_iter_values<I>(iter: I) -> DecimalArray<Decimal128Type>where
I: IntoIterator<Item = i128>,
Creates a Decimal128Array with default precision and scale,
based on an iterator of i128
values without nulls
sourceimpl<'a, T> DecimalArray<T>where
T: DecimalType,
impl<'a, T> DecimalArray<T>where
T: DecimalType,
sourcepub fn iter(&'a self) -> ArrayIter<&'a DecimalArray<T>>ⓘNotable traits for ArrayIter<T>impl<T> Iterator for ArrayIter<T>where
T: ArrayAccessor, type Item = Option<<T as ArrayAccessor>::Item>;
pub fn iter(&'a self) -> ArrayIter<&'a DecimalArray<T>>ⓘNotable traits for ArrayIter<T>impl<T> Iterator for ArrayIter<T>where
T: ArrayAccessor, type Item = Option<<T as ArrayAccessor>::Item>;
T: ArrayAccessor, type Item = Option<<T as ArrayAccessor>::Item>;
constructs a new iterator
Trait Implementations
sourceimpl<T> Array for DecimalArray<T>where
T: DecimalType,
impl<T> Array for DecimalArray<T>where
T: DecimalType,
sourcefn data_ref(&self) -> &ArrayData
fn data_ref(&self) -> &ArrayData
sourcefn slice(&self, offset: usize, length: usize) -> Arc<dyn Array + 'static>
fn slice(&self, offset: usize, length: usize) -> Arc<dyn Array + 'static>
sourcefn offset(&self) -> usize
fn offset(&self) -> usize
0
. Read moresourcefn 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 moresourcefn 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 moresourcefn null_count(&self) -> usize
fn null_count(&self) -> usize
sourcefn get_buffer_memory_size(&self) -> usize
fn get_buffer_memory_size(&self) -> usize
sourcefn 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. Read moresourceimpl<'a, T> ArrayAccessor for &'a DecimalArray<T>where
T: DecimalType,
impl<'a, T> ArrayAccessor for &'a DecimalArray<T>where
T: DecimalType,
type Item = Decimal<T>
sourcefn value(&self, index: usize) -> <&'a DecimalArray<T> as ArrayAccessor>::Item
fn value(&self, index: usize) -> <&'a DecimalArray<T> as ArrayAccessor>::Item
i
Read moresourceunsafe fn value_unchecked(
&self,
index: usize
) -> <&'a DecimalArray<T> as ArrayAccessor>::Item
unsafe fn value_unchecked(
&self,
index: usize
) -> <&'a DecimalArray<T> as ArrayAccessor>::Item
i
Read more