Skip to content

Commit

Permalink
chore(arrow-ord): move can_rank to the rank file (#6910)
Browse files Browse the repository at this point in the history
  • Loading branch information
rluvaton authored Dec 26, 2024
1 parent 10cf03c commit 63899b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
9 changes: 9 additions & 0 deletions arrow-ord/src/rank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ use arrow_buffer::NullBuffer;
use arrow_schema::{ArrowError, DataType, SortOptions};
use std::cmp::Ordering;

/// Whether `arrow_ord::rank` can rank an array of given data type.
pub(crate) fn can_rank(data_type: &DataType) -> bool {
data_type.is_primitive()
|| matches!(
data_type,
DataType::Utf8 | DataType::LargeUtf8 | DataType::Binary | DataType::LargeBinary
)
}

/// Assigns a rank to each value in `array` based on its position in the sorted order
///
/// Where values are equal, they will be assigned the highest of their ranks,
Expand Down
11 changes: 1 addition & 10 deletions arrow-ord/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use arrow_select::take::take;
use std::cmp::Ordering;
use std::sync::Arc;

use crate::rank::rank;
use crate::rank::{can_rank, rank};
pub use arrow_schema::SortOptions;

/// Sort the `ArrayRef` using `SortOptions`.
Expand Down Expand Up @@ -190,15 +190,6 @@ fn partition_validity(array: &dyn Array) -> (Vec<u32>, Vec<u32>) {
}
}

/// Whether `arrow_ord::rank` can rank an array of given data type.
fn can_rank(data_type: &DataType) -> bool {
data_type.is_primitive()
|| matches!(
data_type,
DataType::Utf8 | DataType::LargeUtf8 | DataType::Binary | DataType::LargeBinary
)
}

/// Whether `sort_to_indices` can sort an array of given data type.
fn can_sort_to_indices(data_type: &DataType) -> bool {
data_type.is_primitive()
Expand Down

0 comments on commit 63899b7

Please sign in to comment.