Struct arrow_array::array::DecimalArray
source · [−]pub struct DecimalArray<T: DecimalType> { /* private fields */ }
Expand description
A generic Array
for fixed width decimal numbers
See Decimal128Array
and Decimal256Array
Implementations
sourceimpl<T: DecimalType> DecimalArray<T>
impl<T: DecimalType> DecimalArray<T>
pub const VALUE_LENGTH: 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
) -> Self
pub fn from_fixed_size_binary_array(
v: FixedSizeBinaryArray,
precision: u8,
scale: u8
) -> Self
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
) -> Self
👎Deprecated: please use from_fixed_size_binary_array
instead
pub fn from_fixed_size_list_array(
v: FixedSizeListArray,
precision: u8,
scale: u8
) -> Self
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<Self, ArrowError>where
Self: Sized,
pub fn with_precision_and_scale(
self,
precision: u8,
scale: u8
) -> Result<Self, ArrowError>where
Self: 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: IntoIterator<Item = i128>>(iter: I) -> Self
pub fn from_iter_values<I: IntoIterator<Item = i128>>(iter: I) -> Self
Creates a Decimal128Array with default precision and scale,
based on an iterator of i128
values without nulls
sourceimpl<'a, T: DecimalType> DecimalArray<T>
impl<'a, T: DecimalType> DecimalArray<T>
sourcepub fn iter(&'a self) -> DecimalIter<'a, T>
pub fn iter(&'a self) -> DecimalIter<'a, T>
constructs a new iterator
Trait Implementations
sourceimpl<T: DecimalType> Array for DecimalArray<T>
impl<T: DecimalType> Array for DecimalArray<T>
sourcefn data_ref(&self) -> &ArrayData
fn data_ref(&self) -> &ArrayData
sourcefn slice(&self, offset: usize, length: usize) -> ArrayRef
fn slice(&self, offset: usize, length: usize) -> ArrayRef
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 more