Skip to main content

Module float_semantics

Module float_semantics 

Source
Expand description

Float semantics for DataFusion.

Arrow’s comparison kernels work on the bit pattern of a float, i.e. IEEE 754 totalOrder. DataFusion deviates from that in one respect: +0.0 and -0.0 are equal, hash the same and fall into the same group. See normalize_float, normalize_floats and ScalarValue::normalize. Ordering still follows totalOrder, so compare_floats sorts -0.0 before +0.0.

Every comparison, hash or grouping boundary should be built from these helpers rather than inspecting float bits itself:

Traits§

FloatSemantics
The floating point types the functions in this module are defined for: f16, f32 and f64.

Functions§

compare_floats
Compares two values in the order DataFusion sorts them.
float_gt
Whether left sorts after right, the same as compare_floats(left, right).is_gt().
float_lt
Whether left sorts before right, the same as compare_floats(left, right).is_lt().
has_float_leaf
Whether data_type is a float or contains a float at any depth of its nested children.
hash_input
The value that DataFusion hashes in place of a float. Values that DataFusion treats as equal hash the same, so this is the value normalize_float returns.
normalize_float
-0.0 becomes 0.0, so two values that DataFusion treats as equal also have the same bits. All other values, including NaN payloads, are kept as they are.
normalize_floats
Applies normalize_float to every float in array, including floats nested inside lists, structs, maps, unions, dictionaries and run-end encoded arrays. Arrays without floats are returned unchanged.