Skip to content

Commit 2361dba

Browse files
committed
truncate
1 parent 0cf1ff6 commit 2361dba

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

arrow-buffer/src/buffer/boolean.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ impl BooleanBuffer {
181181
/// let result = BooleanBuffer::from_bitwise_unary_op(
182182
/// &input, 0, 12, |a| !a
183183
/// );
184-
/// // Note, values are padded
185-
/// assert_eq!(result.values(), &[0b00110011u8, 0b11110101u8, 255, 255, 255, 255, 255, 255]);
184+
/// assert_eq!(result.values(), &[0b00110011u8, 0b01000101u8]);
186185
/// ```
187186
pub fn from_bitwise_unary_op<F>(
188187
src: impl AsRef<[u8]>,
@@ -221,11 +220,13 @@ impl BooleanBuffer {
221220
iter.chain(Some(read_u64(remainder))).map(&mut op).collect()
222221
};
223222

223+
let mut buf = MutableBuffer::from(vec_u64s);
224+
224225
// TODO - this is not ideal as it removes the u64 aligment without reducing the allocated size
225226
// but various operations expect the output buffer to be the number of output bits
226-
vec_u64s.truncate(ceil(len_in_bits, 8));
227+
buf.truncate(ceil(len_in_bits, 8));
227228

228-
BooleanBuffer::new(Buffer::from(vec_u64s), start_bit, len_in_bits)
229+
BooleanBuffer::new(buf.into_buffer(), start_bit, len_in_bits)
229230
}
230231

231232
/// Create a new [`BooleanBuffer`] by applying the bitwise operation `op` to

0 commit comments

Comments
 (0)