rank_float

Function rank_float 

Source
pub fn rank_float<T: Float + Copy>(window: FloatAVT<'_, T>) -> IntegerArray<i32>
Expand description

Computes standard SQL ROW_NUMBER() ranking for floating-point data with IEEE 754 compliance.

Assigns sequential rank values based on sorted floating-point order, implementing ROW_NUMBER() semantics with proper handling of special floating-point values (NaN, infinity) according to IEEE 754 comparison standards.

§Parameters

  • window - Float array view containing values for ranking

§Returns

Returns an IntegerArray<i32> containing:

  • Rank values from 1 to n for valid, non-NaN elements
  • Zero values for null or NaN elements
  • Null mask indicating positions with valid ranks

§Floating-Point Ranking

  • IEEE 754 ordering: Uses IEEE 754 compliant comparison operations
  • NaN handling: NaN values are excluded from ranking (receive rank 0)
  • Infinity treatment: Positive/negative infinity participate in ranking
  • Precision preservation: Maintains full floating-point comparison precision

§Ranking Semantics

  • ROW_NUMBER() style: Each non-NaN element receives unique sequential rank
  • Ascending order: Smaller floating-point values receive lower ranks
  • Tie breaking: Floating-point ties broken by original array position
  • Special value exclusion: NaN and null values excluded from rank assignment

§Applications

  • Statistical ranking: Ranking continuous numerical data
  • Scientific analysis: Ordered ranking of experimental measurements
  • Financial analysis: Ranking performance metrics and indicators
  • Data preprocessing: Establishing ordinality for regression analysis

§Examples

use minarrow::FloatArray;
use simd_kernels::kernels::window::rank_float;

let arr = FloatArray::<f64>::from_slice(&[3.14, 2.71, 1.41, f64::NAN]);
let result = rank_float((&arr, 0, arr.len()));
// Output: [3, 2, 1, 0] - NaN excluded, others ranked by value