Skip to content

Commit ef7d753

Browse files
shuozelShuozeli
andauthored
fix: NullBufferBuilder::allocated_size should return Size in Bytes (#7122)
Co-authored-by: Shuoze Li <[email protected]>
1 parent 78c9df9 commit ef7d753

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arrow-buffer/src/builder/null.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ 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 bits, useful for memory accounting.
220+
/// Return the allocated size of this builder, in bytes, useful for memory accounting.
221221
pub fn allocated_size(&self) -> usize {
222222
self.bitmap_builder
223223
.as_ref()
224-
.map(|b| b.capacity())
224+
.map(|b| b.capacity() / 8)
225225
.unwrap_or(0)
226226
}
227227
}
@@ -250,7 +250,7 @@ mod tests {
250250
builder.append_n_nulls(2);
251251
builder.append_n_non_nulls(2);
252252
assert_eq!(6, builder.len());
253-
assert_eq!(512, builder.allocated_size());
253+
assert_eq!(64, builder.allocated_size());
254254

255255
let buf = builder.finish().unwrap();
256256
assert_eq!(&[0b110010_u8], buf.validity());
@@ -263,7 +263,7 @@ mod tests {
263263
builder.append_n_nulls(2);
264264
builder.append_slice(&[false, false, false]);
265265
assert_eq!(6, builder.len());
266-
assert_eq!(512, builder.allocated_size());
266+
assert_eq!(64, builder.allocated_size());
267267

268268
let buf = builder.finish().unwrap();
269269
assert_eq!(&[0b0_u8], buf.validity());
@@ -327,7 +327,7 @@ mod tests {
327327
builder.append_null();
328328
builder.append_non_null();
329329
assert_eq!(builder.as_slice().unwrap(), &[0xFF, 0b10111111]);
330-
assert_eq!(builder.allocated_size(), 512);
330+
assert_eq!(builder.allocated_size(), 64);
331331
}
332332

333333
#[test]

0 commit comments

Comments
 (0)