Skip to content

Commit

Permalink
Minor: Clarify documentaiton on NullBufferBuilder::allocated_size
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Feb 6, 2025
1 parent 7302888 commit 7ea8bda
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion arrow-buffer/src/buffer/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ impl MutableBuffer {
self.len
}

/// Returns the total capacity in this buffer.
/// Returns the total capacity in this buffer, in bytes.
///
/// The invariant `buffer.len() <= buffer.capacity()` is always upheld.
#[inline]
pub const fn capacity(&self) -> usize {
Expand Down
18 changes: 17 additions & 1 deletion arrow-buffer/src/builder/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,23 @@ impl BooleanBufferBuilder {
self.len == 0
}

/// Returns the capacity of the buffer
/// Returns the capacity of the buffer, in bits (not bytes)
///
/// Note this
///
/// # Example
/// ```
/// # use arrow_buffer::builder::BooleanBufferBuilder;
/// // empty requires 0 bytes
/// let b = BooleanBufferBuilder::new(0);
/// assert_eq!(0, b.capacity());
/// // Creating space for 1 bit results in 64 bytes (space for 512 bits)
/// let mut b = BooleanBufferBuilder::new(1);
/// assert_eq!(512, b.capacity());
/// // 1000 bits requires 128 bytes (space for 1024 bits)
/// b.append_n(1000, true);
/// assert_eq!(1024, b.capacity());
/// ```
#[inline]
pub fn capacity(&self) -> usize {
self.buffer.capacity() * 8
Expand Down
2 changes: 1 addition & 1 deletion arrow-buffer/src/builder/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl NullBufferBuilder {
self.bitmap_builder.as_mut().map(|b| b.as_slice_mut())
}

/// Return the allocated size of this builder, in bytes, useful for memory accounting.
/// Return the allocated size of this builder, in bits, useful for memory accounting.
pub fn allocated_size(&self) -> usize {
self.bitmap_builder
.as_ref()
Expand Down

0 comments on commit 7ea8bda

Please sign in to comment.