Skip to content

Commit 288795e

Browse files
committed
Add functionality to BooleanBufferBuilder
1 parent d3ac924 commit 288795e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

arrow/src/array/builder.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,24 @@ impl BooleanBufferBuilder {
297297
Self { buffer, len: 0 }
298298
}
299299

300+
#[inline]
301+
pub fn new_from_buffer(buffer: MutableBuffer, len: usize) -> BooleanBufferBuilder {
302+
assert_eq!(len.div_ceil(8), buffer.len());
303+
Self { buffer, len }
304+
}
305+
300306
#[inline]
301307
pub fn len(&self) -> usize {
302308
self.len
303309
}
304310

311+
// TODO: Remove, and don't use the elem-by-elem peek_evaluate function.
312+
#[inline]
313+
pub fn get_bit(&self, index: usize) -> bool {
314+
bit_util::get_bit(self.buffer.as_ref(), index)
315+
}
316+
317+
// TODO: Probably, make set_bit be branchless
305318
#[inline]
306319
pub fn set_bit(&mut self, index: usize, v: bool) {
307320
if v {
@@ -382,6 +395,12 @@ impl BooleanBufferBuilder {
382395
self.len = 0;
383396
buf.into()
384397
}
398+
399+
#[inline]
400+
/// Builds the [Buffer] without resetting the builder.
401+
pub fn finish_cloned(&self) -> Buffer {
402+
Buffer::from_slice_ref(&self.buffer.as_slice())
403+
}
385404
}
386405

387406
impl From<BooleanBufferBuilder> for Buffer {

0 commit comments

Comments
 (0)