Struct arrow::array::Decimal128Array
source · [−]pub struct Decimal128Array { /* private fields */ }
Expand description
Decimal128Array
stores fixed width decimal numbers,
with a fixed precision and scale.
Examples
use arrow::array::{Array, BasicDecimalArray, Decimal128Array};
use arrow::datatypes::DataType;
// Create a DecimalArray with the default precision and scale
let decimal_array: Decimal128Array = vec![
Some(8_887_000_000),
None,
Some(-8_887_000_000),
]
.into_iter().collect();
// set precision and scale so values are interpreted
// as `8887.000000`, `Null`, and `-8887.000000`
let decimal_array = decimal_array
.with_precision_and_scale(23, 6)
.unwrap();
assert_eq!(&DataType::Decimal(23, 6), decimal_array.data_type());
assert_eq!(8_887_000_000_i128, decimal_array.value(0).as_i128());
assert_eq!("8887.000000", decimal_array.value_as_string(0));
assert_eq!(3, decimal_array.len());
assert_eq!(1, decimal_array.null_count());
assert_eq!(32, decimal_array.value_offset(2));
assert_eq!(16, decimal_array.value_length());
assert_eq!(23, decimal_array.precision());
assert_eq!(6, decimal_array.scale());
Implementations
sourceimpl Decimal128Array
impl Decimal128Array
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
sourcepub fn with_precision_and_scale(
self,
precision: usize,
scale: usize
) -> Result<Self>
pub fn with_precision_and_scale(
self,
precision: usize,
scale: usize
) -> Result<Self>
Returns a Decimal128Array with the same data as self, with the specified precision.
Returns an Error if:
precision
is larger thanDECIMAL_MAX_PRECISION
scale
is larger thanDECIMAL_MAX_SCALE
;scale
is >precision
sourcepub fn default_type() -> DataType
pub fn default_type() -> DataType
The default precision and scale used when not specified.
sourceimpl<'a> Decimal128Array
impl<'a> Decimal128Array
sourcepub fn iter(&'a self) -> DecimalIter<'a>ⓘNotable traits for DecimalIter<'a>impl<'a> Iterator for DecimalIter<'a> type Item = Option<i128>;
pub fn iter(&'a self) -> DecimalIter<'a>ⓘNotable traits for DecimalIter<'a>impl<'a> Iterator for DecimalIter<'a> type Item = Option<i128>;
constructs a new iterator
Trait Implementations
sourceimpl Array for Decimal128Array
impl Array for Decimal128Array
sourcefn data_ref(&self) -> &ArrayData
fn data_ref(&self) -> &ArrayData
Returns a reference-counted pointer to the underlying data of this array.
sourcefn slice(&self, offset: usize, length: usize) -> ArrayRef
fn slice(&self, offset: usize, length: usize) -> ArrayRef
Returns a zero-copy slice of this array with the indicated offset and length. Read more
sourcefn offset(&self) -> usize
fn offset(&self) -> usize
Returns the offset into the underlying data used by this array(-slice).
Note that the underlying data can be shared by many arrays.
This defaults to 0
. Read more
sourcefn is_null(&self, index: usize) -> bool
fn is_null(&self, index: usize) -> bool
Returns whether the element at index
is null.
When using this function on a slice, the index is relative to the slice. Read more
sourcefn is_valid(&self, index: usize) -> bool
fn is_valid(&self, index: usize) -> bool
Returns whether the element at index
is not null.
When using this function on a slice, the index is relative to the slice. Read more
sourcefn null_count(&self) -> usize
fn null_count(&self) -> usize
Returns the total number of null values in this array. Read more
sourcefn get_buffer_memory_size(&self) -> usize
fn get_buffer_memory_size(&self) -> usize
Returns the total number of bytes of memory pointed to by this array. The buffers store bytes in the Arrow memory format, and include the data as well as the validity map. Read more
sourcefn get_array_memory_size(&self) -> usize
fn get_array_memory_size(&self) -> usize
Returns the total number of bytes of memory occupied physically by this array.
This value will always be greater than returned by get_buffer_memory_size()
and
includes the overhead of the data structures that contain the pointers to the various buffers. Read more
sourcefn to_raw(&self) -> Result<(*const FFI_ArrowArray, *const FFI_ArrowSchema)>
fn to_raw(&self) -> Result<(*const FFI_ArrowArray, *const FFI_ArrowSchema)>
returns two pointers that represent this array in the C Data Interface (FFI)
sourceimpl BasicDecimalArray<Decimal128, Decimal128Array> for Decimal128Array
impl BasicDecimalArray<Decimal128, Decimal128Array> for Decimal128Array
const VALUE_LENGTH: i32 = 16i32
fn data(&self) -> &ArrayData
sourcefn precision(&self) -> usize
fn precision(&self) -> usize
Return the precision (total digits) that can be stored by this array
sourcefn scale(&self) -> usize
fn scale(&self) -> usize
Return the scale (digits after the decimal) that can be stored by this array
sourcefn value_offset(&self, i: usize) -> i32
fn value_offset(&self, i: usize) -> i32
Returns the offset for the element at index i
. Read more
sourcefn value_length(&self) -> i32
fn value_length(&self) -> i32
Returns the length for an element. Read more
sourcefn value_data(&self) -> Buffer
fn value_data(&self) -> Buffer
Returns a clone of the value data buffer
fn value_offset_at(&self, i: usize) -> i32
fn value_as_string(&self, row: usize) -> String
sourcefn from_fixed_size_binary_array(
v: FixedSizeBinaryArray,
precision: usize,
scale: usize
) -> U
fn from_fixed_size_binary_array(
v: FixedSizeBinaryArray,
precision: usize,
scale: usize
) -> U
Build a decimal array from FixedSizeBinaryArray
. Read more
sourcefn from_fixed_size_list_array(
v: FixedSizeListArray,
precision: usize,
scale: usize
) -> U
fn from_fixed_size_list_array(
v: FixedSizeListArray,
precision: usize,
scale: usize
) -> U
please use from_fixed_size_binary_array
instead
Build a decimal array from FixedSizeListArray
. Read more
sourceimpl Debug for Decimal128Array
impl Debug for Decimal128Array
sourceimpl From<ArrayData> for Decimal128Array
impl From<ArrayData> for Decimal128Array
sourceimpl From<Decimal128Array> for ArrayData
impl From<Decimal128Array> for ArrayData
sourcefn from(array: Decimal128Array) -> Self
fn from(array: Decimal128Array) -> Self
Converts to this type from the input type.
sourceimpl<Ptr: Borrow<Option<i128>>> FromIterator<Ptr> for Decimal128Array
impl<Ptr: Borrow<Option<i128>>> FromIterator<Ptr> for Decimal128Array
sourcefn from_iter<I: IntoIterator<Item = Ptr>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = Ptr>>(iter: I) -> Self
Creates a value from an iterator. Read more
sourceimpl<'a> IntoIterator for &'a Decimal128Array
impl<'a> IntoIterator for &'a Decimal128Array
sourceimpl JsonEqual for Decimal128Array
impl JsonEqual for Decimal128Array
sourcefn equals_json(&self, json: &[&Value]) -> bool
fn equals_json(&self, json: &[&Value]) -> bool
Checks whether arrow array equals to json array.
sourcefn equals_json_values(&self, json: &[Value]) -> bool
fn equals_json_values(&self, json: &[Value]) -> bool
Checks whether arrow array equals to json array.
sourceimpl PartialEq<Decimal128Array> for Decimal128Array
impl PartialEq<Decimal128Array> for Decimal128Array
sourceimpl PartialEq<Decimal128Array> for Value
impl PartialEq<Decimal128Array> for Value
Auto Trait Implementations
impl RefUnwindSafe for Decimal128Array
impl Send for Decimal128Array
impl Sync for Decimal128Array
impl Unpin for Decimal128Array
impl UnwindSafe for Decimal128Array
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more