Struct arrow_array::decimal::Decimal
source · [−]pub struct Decimal<T: DecimalType> { /* private fields */ }
Expand description
Decimal
is the generic representation of a single decimal value
See Decimal128
and Decimal256
for the value types of Decimal128Array
and Decimal256Array
respectively
Implementations
sourceimpl<T: DecimalType> Decimal<T>
impl<T: DecimalType> Decimal<T>
pub const MAX_PRECISION: u8 = T::MAX_PRECISION
pub const MAX_SCALE: u8 = T::MAX_SCALE
pub const TYPE_CONSTRUCTOR: fn(_: u8, _: u8) -> DataType = T::TYPE_CONSTRUCTOR
pub const DEFAULT_TYPE: DataType = T::DEFAULT_TYPE
sourcepub fn try_new_from_bytes(
precision: u8,
scale: u8,
bytes: &T::Native
) -> Result<Self, ArrowError>where
Self: Sized,
pub fn try_new_from_bytes(
precision: u8,
scale: u8,
bytes: &T::Native
) -> Result<Self, ArrowError>where
Self: Sized,
Tries to create a decimal value from precision, scale and bytes. The bytes should be stored in little-endian order.
Safety: This method doesn’t validate if the decimal value represented by the bytes can be fitted into the specified precision.
sourcepub fn new(precision: u8, scale: u8, bytes: &T::Native) -> Self
pub fn new(precision: u8, scale: u8, bytes: &T::Native) -> Self
Creates a decimal value from precision, scale, and bytes.
Safety:
This method doesn’t check if the precision and scale are valid.
Use try_new_from_bytes
for safe constructor.
sourceimpl Decimal<Decimal128Type>
impl Decimal<Decimal128Type>
sourceimpl Decimal<Decimal256Type>
impl Decimal<Decimal256Type>
sourcepub fn from_big_int(
num: &BigInt,
precision: u8,
scale: u8
) -> Result<Decimal256, ArrowError>
pub fn from_big_int(
num: &BigInt,
precision: u8,
scale: u8
) -> Result<Decimal256, ArrowError>
Constructs a Decimal256
value from a BigInt
.
sourcepub fn to_big_int(self) -> BigInt
pub fn to_big_int(self) -> BigInt
Constructs a BigInt
from this Decimal256
value.
Trait Implementations
sourceimpl<T: DecimalType> Clone for Decimal<T>
impl<T: DecimalType> Clone for Decimal<T>
Manually implement to avoid T: Debug
bound
sourceimpl<T: DecimalType> Debug for Decimal<T>
impl<T: DecimalType> Debug for Decimal<T>
Manually implement to avoid T: Debug
bound
sourceimpl From<Decimal<Decimal128Type>> for i128
impl From<Decimal<Decimal128Type>> for i128
sourcefn from(decimal: Decimal128) -> Self
fn from(decimal: Decimal128) -> Self
sourceimpl<T: DecimalType> Ord for Decimal<T>
impl<T: DecimalType> Ord for Decimal<T>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl<T: DecimalType> PartialEq<Decimal<T>> for Decimal<T>
impl<T: DecimalType> PartialEq<Decimal<T>> for Decimal<T>
sourceimpl<T: DecimalType> PartialOrd<Decimal<T>> for Decimal<T>
impl<T: DecimalType> PartialOrd<Decimal<T>> for Decimal<T>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more