This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 63899b7ad9 chore(arrow-ord): move `can_rank` to the `rank` file (#6910)
63899b7ad9 is described below
commit 63899b7ad9d093e86acc6c98604aa66431102993
Author: Raz Luvaton <[email protected]>
AuthorDate: Thu Dec 26 16:49:36 2024 +0200
chore(arrow-ord): move `can_rank` to the `rank` file (#6910)
---
arrow-ord/src/rank.rs | 9 +++++++++
arrow-ord/src/sort.rs | 11 +----------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/arrow-ord/src/rank.rs b/arrow-ord/src/rank.rs
index ecc693bab4..e61cebef38 100644
--- a/arrow-ord/src/rank.rs
+++ b/arrow-ord/src/rank.rs
@@ -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,
diff --git a/arrow-ord/src/sort.rs b/arrow-ord/src/sort.rs
index 60fc4a9185..51a6659e63 100644
--- a/arrow-ord/src/sort.rs
+++ b/arrow-ord/src/sort.rs
@@ -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`.
@@ -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()