haohuaijin commented on code in PR #9823:
URL: https://github.com/apache/arrow-rs/pull/9823#discussion_r3506960490
##########
arrow-array/src/array/boolean_array.rs:
##########
@@ -560,6 +560,45 @@ impl BooleanArray {
}
}
+ /// Returns a new [`BooleanArray`] of the same length where only the first
+ /// `n` non-null `true` positions remain `true`; any `true` positions
+ /// beyond the first `n` are replaced with `false`. The null buffer is
+ /// preserved unchanged.
+ ///
+ /// If this array has at most `n` non-null `true` values, `self` is
+ /// returned unchanged.
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// # use arrow_array::BooleanArray;
+ /// let a = BooleanArray::from(vec![true, false, true, true, false, true]);
+ /// // Keep only the first 2 `true` positions; later trues become false.
+ /// let r = a.take_n_true(2);
+ /// assert_eq!(r, BooleanArray::from(vec![true, false, true, false, false,
false]));
+ /// ```
+ pub fn take_n_true(self, n: usize) -> BooleanArray {
+ let len = self.len();
Review Comment:
create a issue to track https://github.com/apache/arrow-rs/issues/10251
--
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]