Skip to main content

Module compute

Module compute 

Source
Expand description

Operations that run on the values of a Widen instead of on a widened copy.

An operation runs on the values only where it gives the canonical result. Decoding a value is a strictly increasing, one-to-one map that keeps validity, so comparisons, sortedness, constancy and extrema carry over from the values, and every value in a result widens exactly to the logical dtype.

Most of these operations decide from dtypes and constants alone. The arithmetic kernel also needs the min and max of each operand, which come from cached statistics or from one scan of the operand. That scan is the one hidden cost in this module.

AggregateFnSession::default registers the aggregate kernel, not the Widen encoding’s initialize, because the kernel session runs initialize on a temporary session and drops its aggregate registry.

Functions§

cast_keeping_nullability
Casts the integer array array to ptype, keeping its nullability.
constant_fits_values
Returns whether the dtype range of values holds constant.
constant_in_values_dtype
Returns constant, which must fit the type of values, as a constant array of that type with the nullability of constant.
ptype_holding_both_values
Returns the wider of the value types of two Widen arrays, or None when a value type is not primitive.
ptype_holding_values_and_scalar
Returns the type that the values of array widen to so that they also hold scalar: the type of the values, or the smallest wider type of the logical signedness that holds scalar.
wrap_values
Returns values when it has dtype, and a Widen of dtype over values otherwise.