Skip to content

Commit cc18d0f

Browse files
authored
Minor: improve the documentation of NullBuffer and BooleanBuffer (#6974)
1 parent 12a1235 commit cc18d0f

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

arrow-buffer/src/buffer/boolean.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ use crate::{
2525
use std::ops::{BitAnd, BitOr, BitXor, Not};
2626

2727
/// A slice-able [`Buffer`] containing bit-packed booleans
28+
///
29+
/// `BooleanBuffer`s can be creating using [`BooleanBufferBuilder`]
30+
///
31+
/// # See Also
32+
///
33+
/// * [`NullBuffer`] for representing null values in Arrow arrays
34+
///
35+
/// [`NullBuffer`]: crate::NullBuffer
2836
#[derive(Debug, Clone, Eq)]
2937
pub struct BooleanBuffer {
3038
buffer: Buffer,

arrow-buffer/src/buffer/null.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ use crate::bit_iterator::{BitIndexIterator, BitIterator, BitSliceIterator};
1919
use crate::buffer::BooleanBuffer;
2020
use crate::{Buffer, MutableBuffer};
2121

22-
/// A [`BooleanBuffer`] used to encode validity for arrow arrays
22+
/// A [`BooleanBuffer`] used to encode validity for Arrow arrays
2323
///
24-
/// As per the [Arrow specification], array validity is encoded in a packed bitmask with a
24+
/// In the [Arrow specification], array validity is encoded in a packed bitmask with a
2525
/// `true` value indicating the corresponding slot is not null, and `false` indicating
2626
/// that it is null.
2727
///
28+
/// `NullBuffer`s can be creating using [`NullBufferBuilder`]
29+
///
2830
/// [Arrow specification]: https://arrow.apache.org/docs/format/Columnar.html#validity-bitmaps
31+
/// [`NullBufferBuilder`]: crate::NullBufferBuilder
2932
#[derive(Debug, Clone, Eq, PartialEq)]
3033
pub struct NullBuffer {
3134
buffer: BooleanBuffer,
@@ -49,7 +52,8 @@ impl NullBuffer {
4952

5053
/// Create a new [`NullBuffer`] of length `len` where all values are valid
5154
///
52-
/// Note: it is more efficient to not set the null buffer if it is known to be all valid
55+
/// Note: it is more efficient to not set the null buffer if it is known to
56+
/// be all valid (aka all values are not null)
5357
pub fn new_valid(len: usize) -> Self {
5458
Self {
5559
buffer: BooleanBuffer::new_set(len),

arrow-buffer/src/builder/boolean.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ use crate::{bit_mask, bit_util, BooleanBuffer, Buffer, MutableBuffer};
1919
use std::ops::Range;
2020

2121
/// Builder for [`BooleanBuffer`]
22+
///
23+
/// # See Also
24+
///
25+
/// * [`NullBuffer`] for building [`BooleanBuffer`]s for representing nulls
26+
///
27+
/// [`NullBuffer`]: crate::NullBuffer
2228
#[derive(Debug)]
2329
pub struct BooleanBufferBuilder {
2430
buffer: MutableBuffer,

arrow-buffer/src/builder/null.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@
1717

1818
use crate::{BooleanBufferBuilder, MutableBuffer, NullBuffer};
1919

20-
/// Builder for creating the null bit buffer.
20+
/// Builder for creating [`NullBuffer`]
21+
///
22+
/// # Performance
2123
///
2224
/// This builder only materializes the buffer when we append `false`.
2325
/// If you only append `true`s to the builder, what you get will be
2426
/// `None` when calling [`finish`](#method.finish).
25-
/// This optimization is **very** important for the performance.
27+
///
28+
/// This optimization is **very** important for the performance as it avoids
29+
/// allocating memory for the null buffer when there are no nulls.
2630
#[derive(Debug)]
2731
pub struct NullBufferBuilder {
2832
bitmap_builder: Option<BooleanBufferBuilder>,

0 commit comments

Comments
 (0)