From 5f764ddca8e303d311914a48b56115dbd5a05d23 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Fri, 24 Jan 2025 15:07:03 -0500 Subject: [PATCH 1/2] Minor: Clarify NullBufferBuilder::new capacity parameter --- arrow-buffer/src/builder/boolean.rs | 6 +++++- arrow-buffer/src/builder/null.rs | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arrow-buffer/src/builder/boolean.rs b/arrow-buffer/src/builder/boolean.rs index 67b306dd8ce..0424e128d2d 100644 --- a/arrow-buffer/src/builder/boolean.rs +++ b/arrow-buffer/src/builder/boolean.rs @@ -32,7 +32,11 @@ pub struct BooleanBufferBuilder { } impl BooleanBufferBuilder { - /// Creates a new `BooleanBufferBuilder` + /// Creates a new `BooleanBufferBuilder` with sufficient space for + /// `capacity` bits (not bytes). + /// + /// The capacity is rounded up to the nearest multiple of 8 for the + /// allocation. #[inline] pub fn new(capacity: usize) -> Self { let byte_capacity = bit_util::ceil(capacity, 8); diff --git a/arrow-buffer/src/builder/null.rs b/arrow-buffer/src/builder/null.rs index 0ad62eacf4a..5369d1d0a5c 100644 --- a/arrow-buffer/src/builder/null.rs +++ b/arrow-buffer/src/builder/null.rs @@ -54,7 +54,10 @@ pub struct NullBufferBuilder { impl NullBufferBuilder { /// Creates a new empty builder. - /// `capacity` is the number of bits in the null buffer. + /// + /// Note that this method does not allocate any memory, regardless of the + /// `capacity` parameter. If an allocation is required, `capacity` is the + /// size in bits (not bytes) that will be allocated. pub fn new(capacity: usize) -> Self { Self { bitmap_builder: None, From ec43fea9aa00334007cffb71b1728b7033b316ec Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Fri, 24 Jan 2025 15:52:51 -0500 Subject: [PATCH 2/2] Update arrow-buffer/src/builder/null.rs Co-authored-by: Jeffrey Vo --- arrow-buffer/src/builder/null.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arrow-buffer/src/builder/null.rs b/arrow-buffer/src/builder/null.rs index 5369d1d0a5c..f88868db8a3 100644 --- a/arrow-buffer/src/builder/null.rs +++ b/arrow-buffer/src/builder/null.rs @@ -57,7 +57,7 @@ impl NullBufferBuilder { /// /// Note that this method does not allocate any memory, regardless of the /// `capacity` parameter. If an allocation is required, `capacity` is the - /// size in bits (not bytes) that will be allocated. + /// size in bits (not bytes) that will be allocated at minimum. pub fn new(capacity: usize) -> Self { Self { bitmap_builder: None,