Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions datafusion/common/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,20 +769,6 @@ pub fn set_difference<T: Borrow<usize>, S: Borrow<usize>>(
.collect()
}

/// Checks whether the given index sequence is monotonically non-decreasing.
pub fn is_sorted<T: Borrow<usize>>(sequence: impl IntoIterator<Item = T>) -> bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alamb @buraksenn Why are we removing a public API method without deprecating it first?

https://docs.rs/datafusion-common/latest/datafusion_common/utils/fn.is_sorted.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry -- that was a mistake. I can make a PR to put it back in w/ deprecated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alamb

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// TODO: Remove this function when `is_sorted` graduates from Rust nightly.
let mut previous = 0;
for item in sequence.into_iter() {
let current = *item.borrow();
if current < previous {
return false;
}
previous = current;
}
true
}

/// Find indices of each element in `targets` inside `items`. If one of the
/// elements is absent in `items`, returns an error.
pub fn find_indices<T: PartialEq, S: Borrow<T>>(
Expand Down Expand Up @@ -1171,18 +1157,6 @@ mod tests {
assert_eq!(set_difference([3, 4, 0], [4, 1, 2]), vec![3, 0]);
}

#[test]
fn test_is_sorted() {
assert!(is_sorted::<usize>([]));
assert!(is_sorted([0]));
assert!(is_sorted([0, 3, 4]));
assert!(is_sorted([0, 1, 2]));
assert!(is_sorted([0, 1, 4]));
assert!(is_sorted([0usize; 0]));
assert!(is_sorted([1, 2]));
assert!(!is_sorted([3, 2]));
}

#[test]
fn test_find_indices() -> Result<()> {
assert_eq!(find_indices(&[0, 3, 4], [0, 3, 4])?, vec![0, 1, 2]);
Expand Down