Skip to content

Commit

Permalink
chore: enrich panic context when BooleanBuffer fails to create (#6810)
Browse files Browse the repository at this point in the history
* chore: enrich panic context when BooleanBuffer fails to create

* Merge main branch
  • Loading branch information
tisonkun authored Nov 29, 2024
1 parent c8fda9a commit 283fb4b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arrow-buffer/src/buffer/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 283fb4b

Please sign in to comment.