Module numeric

Source
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 Numeric through its string representation.

Structs§

InvalidNumericMaxScaleError
The error returned when constructing a NumericMaxScale from an invalid value.
NumericMaxScale
The max_scale of a ScalarType::Numeric.
PackedNumeric
An encoded packed variant of Numeric.
ProtoNumericMaxScale
ProtoOptionalNumericMaxScale
Helper struct for representing Option<NumericMaxScale>.

Constants§

NUMERIC_AGG_MAX_PRECISION
The maximum number of digits expressable in a NumericAgg value.
NUMERIC_AGG_WIDTH
The number of internal decimal units in a NumericAgg value.
NUMERIC_AGG_WIDTH_USIZE
The value of NUMERIC_AGG_WIDTH as a u8.
NUMERIC_DATUM_MAX_PRECISION
The maximum number of digits expressable in a Numeric value.
NUMERIC_DATUM_WIDTH
The number of internal decimal units in a Numeric value.
NUMERIC_DATUM_WIDTH_USIZE
The value of NUMERIC_DATUM_WIDTH as a u8.

Statics§

CX_AGG 🔒
CX_DATUM 🔒
U128_SPLITTER_AGG 🔒
U128_SPLITTER_DATUM 🔒

Traits§

Dec
Traits to generalize converting Decimal values to and from their coefficients’ two’s complements.
DecimalLike
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 by n in 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 Numeric values are:
negate_twos_complement_le 🔒
Using negative binary numbers can require more digits of precision than Numeric offers, 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 Numeric into its big endian two’s complement representation.
numeric_to_twos_complement_inner 🔒
numeric_to_twos_complement_wide
Converts an Numeric into a big endian two’s complement representation where the encoded value has NUMERIC_AGG_MAX_PRECISION digits and a scale of NUMERIC_DATUM_MAX_PRECISION.
rescale
Rescale n as an OrderedDecimal with the described scale, or error if:
rescale_within_max_precision 🔒
Rescale’s n to fit within Numeric’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.
NumericAgg
A double-width version of Numeric for use in aggregations.