Function arrow::array::build_compare

source ·
pub fn build_compare(
    left: &dyn Array,
    right: &dyn Array
) -> Result<Box<dyn Fn(usize, usize) -> Ordering + Sync + Send>, ArrowError>
Expand description

returns a comparison function that compares two values at two different positions between the two arrays. The arrays’ types must be equal.

§Example

use arrow_array::Int32Array;
use arrow_ord::ord::build_compare;

let array1 = Int32Array::from(vec![1, 2]);
let array2 = Int32Array::from(vec![3, 4]);

let cmp = build_compare(&array1, &array2).unwrap();

// 1 (index 0 of array1) is smaller than 4 (index 1 of array2)
assert_eq!(std::cmp::Ordering::Less, cmp(0, 1));