From 283fb4b4d0cc183c3c4d435fc79f983ece223825 Mon Sep 17 00:00:00 2001 From: tison Date: Fri, 29 Nov 2024 19:52:04 +0800 Subject: [PATCH] chore: enrich panic context when BooleanBuffer fails to create (#6810) * chore: enrich panic context when BooleanBuffer fails to create * Merge main branch --- arrow-buffer/src/buffer/boolean.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arrow-buffer/src/buffer/boolean.rs b/arrow-buffer/src/buffer/boolean.rs index d9d2ea04e35a..564c1c42d3af 100644 --- a/arrow-buffer/src/buffer/boolean.rs +++ b/arrow-buffer/src/buffer/boolean.rs @@ -52,8 +52,12 @@ impl BooleanBuffer { /// This method will panic if `buffer` is not large enough pub fn new(buffer: Buffer, offset: usize, len: usize) -> Self { let total_len = offset.saturating_add(len); - let bit_len = buffer.len().saturating_mul(8); - assert!(total_len <= bit_len); + let buffer_len = buffer.len(); + let bit_len = buffer_len.saturating_mul(8); + assert!( + total_len <= bit_len, + "buffer not large enough (offset: {offset}, len: {len}, buffer_len: {buffer_len})" + ); Self { buffer, offset,