File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -288,7 +288,8 @@ impl MutableBuffer {
288288 self . len
289289 }
290290
291- /// Returns the total capacity in this buffer.
291+ /// Returns the total capacity in this buffer, in bytes.
292+ ///
292293 /// The invariant `buffer.len() <= buffer.capacity()` is always upheld.
293294 #[ inline]
294295 pub const fn capacity ( & self ) -> usize {
Original file line number Diff line number Diff line change @@ -83,7 +83,24 @@ impl BooleanBufferBuilder {
8383 self . len == 0
8484 }
8585
86- /// Returns the capacity of the buffer
86+ /// Returns the capacity of the buffer, in bits (not bytes)
87+ ///
88+ /// Note this
89+ ///
90+ /// # Example
91+ /// ```
92+ /// # use arrow_buffer::builder::BooleanBufferBuilder;
93+ /// // empty requires 0 bytes
94+ /// let b = BooleanBufferBuilder::new(0);
95+ /// assert_eq!(0, b.capacity());
96+ /// // Creating space for 1 bit results in 64 bytes (space for 512 bits)
97+ /// // (64 is the minimum allocation size for 64 bit architectures)
98+ /// let mut b = BooleanBufferBuilder::new(1);
99+ /// assert_eq!(512, b.capacity());
100+ /// // 1000 bits requires 128 bytes (space for 1024 bits)
101+ /// b.append_n(1000, true);
102+ /// assert_eq!(1024, b.capacity());
103+ /// ```
87104 #[ inline]
88105 pub fn capacity ( & self ) -> usize {
89106 self . buffer . capacity ( ) * 8
Original file line number Diff line number Diff line change @@ -217,7 +217,7 @@ impl NullBufferBuilder {
217217 self . bitmap_builder . as_mut ( ) . map ( |b| b. as_slice_mut ( ) )
218218 }
219219
220- /// Return the allocated size of this builder, in bytes , useful for memory accounting.
220+ /// Return the allocated size of this builder, in bits , useful for memory accounting.
221221 pub fn allocated_size ( & self ) -> usize {
222222 self . bitmap_builder
223223 . as_ref ( )
You can’t perform that action at this time.
0 commit comments