Cintu07 commented on code in PR #10984:
URL: https://github.com/apache/arrow-rs/pull/10984#discussion_r3937575438
##########
arrow-buffer/src/buffer/mutable.rs:
##########
@@ -1761,4 +1784,30 @@ mod tests {
buf.push(1u8);
buf.reserve(usize::MAX);
}
+ #[test]
+ #[cfg_attr(miri, ignore)] // miri interprets the allocation and runs out
of memory itself
+ fn try_collect_bool_reports_a_len_it_cannot_reserve() {
+ // 2^60 bits is 2^54 u64 words, which is 128 PiB of backing storage.
+ // collect_bool reserves that before calling f, so it aborts the
process.
+ let mut calls = 0usize;
+ let result = MutableBuffer::try_collect_bool(1usize << 60, |_| {
+ calls += 1;
+ true
+ });
+ assert!(matches!(
+ result,
+ Err(MutableBufferError::AllocationError(_))
+ ));
+ assert_eq!(calls, 0, "f must not run when the reservation fails");
+ }
+
+ #[test]
+ fn try_collect_bool_matches_collect_bool_for_sizes_that_fit() {
Review Comment:
dropped this one too in b58729e.
--
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]