Expand description
Functions related to Materialize’s numeric type, which is largely a wrapper
around rust-dec.
Modules§
- str_
serde - Module to simplify serde’ing a
Numericthrough its string representation.
Structs§
- Invalid
Numeric MaxScale Error - The error returned when constructing a
NumericMaxScalefrom an invalid value. - Numeric
MaxScale - The
max_scaleof aSqlScalarType::Numeric. - Packed
Numeric - An encoded packed variant of
Numeric. - Proto
Numeric MaxScale - Proto
Optional Numeric MaxScale - Helper struct for representing
Option<NumericMaxScale>.
Constants§
- NUMERIC_
AGG_ MAX_ PRECISION - The maximum number of digits expressable in a
NumericAggvalue. - NUMERIC_
AGG_ WIDTH - The number of internal decimal units in a
NumericAggvalue. - NUMERIC_
AGG_ WIDTH_ USIZE - The value of
NUMERIC_AGG_WIDTHas au8. - NUMERIC_
DATUM_ MAX_ PRECISION - The maximum number of digits expressable in a
Numericvalue. - NUMERIC_
DATUM_ WIDTH - The number of internal decimal units in a
Numericvalue. - NUMERIC_
DATUM_ WIDTH_ USIZE - The value of
NUMERIC_DATUM_WIDTHas au8.
Statics§
Traits§
- Dec
- Traits to generalize converting
Decimalvalues to and from their coefficients’ two’s complements. - Decimal
Like - A type that can represent Real Numbers. Useful for interoperability between Numeric and floating point.
Functions§
- cx_agg
- Returns a new context appropriate for operating on numeric aggregates.
- cx_
datum - Returns a new context appropriate for operating on numeric datums.
- get_
precision - Returns
n’s precision, i.e. the total number of digits represented bynin standard notation not including a zero in the “one’s place” in (-1,1). - get_
scale - Returns
n’s scale, i.e. the number of digits used after the decimal point. - munge_
numeric - Ensures
Numericvalues are: - negate_
twos_ 🔒complement_ le - Using negative binary numbers can require more digits of precision than
Numericoffers, so we need to have the option to swap bytes’ signs at the byte- rather than the library-level. - numeric_
to_ twos_ complement_ be - Converts an
Numericinto its big endian two’s complement representation. - numeric_
to_ 🔒twos_ complement_ inner - numeric_
to_ twos_ complement_ wide - Converts an
Numericinto a big endian two’s complement representation where the encoded value hasNUMERIC_AGG_MAX_PRECISIONdigits and a scale ofNUMERIC_DATUM_MAX_PRECISION. - rescale
- Rescale
nas anOrderedDecimalwith the described scale, or error if: - rescale_
within_ 🔒max_ precision - Rescale’s
nto fit withinNumeric’s max precision or error if not possible. - twos_
complement_ be_ to_ numeric - twos_
complement_ be_ to_ numeric_ inner - Parses a buffer of two’s complement digits in big-endian order and converts
them to
Decimal<N>. - twos_
complement_ 🔒be_ to_ u128
Type Aliases§
- Numeric
- A numeric value.
- Numeric
Agg - A double-width version of
Numericfor use in aggregations.