Jimexist commented on a change in pull request #585:
URL: https://github.com/apache/arrow-rs/pull/585#discussion_r674016802
##########
File path: arrow/src/compute/kernels/partition.rs
##########
@@ -73,6 +73,25 @@ impl<'a> LexicographicalPartitionIterator<'a> {
}
}
+/// Exponential search is to remedy for the case when array size and
cardinality are both large
+/// see <https://en.wikipedia.org/wiki/Exponential_search>
+#[inline]
+fn exponential_search(
+ indices: &[usize],
+ target: &usize,
+ comparator: &LexicographicalComparator<'_>,
+) -> usize {
+ let mut bound = 1;
+ while bound < indices.len()
+ && comparator.compare(&indices[bound], target) != Ordering::Greater
+ {
+ bound *= 2;
+ }
+ (bound / 2)
Review comment:
invariant:
`indices[bound / 2] <= target < indices[min(indices.len(), bound)]` where
`<=` and `<` are defined by the `comparator`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]