Skip to content

Commit

Permalink
feat: BoolMetadata stores bit offset in 8 bits instead of 64 (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
danking authored Oct 1, 2024
1 parent c95f037 commit 70d75b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pyvortex/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl PyArray {
/// metadata: PrimitiveMetadata { validity: Array }
/// buffer: 32 B
/// validity: vortex.bool(0x02)(bool, len=4) nbytes=1 B (3.03%)
/// metadata: BoolMetadata { validity: NonNullable, bit_offset: 0 }
/// metadata: BoolMetadata { validity: NonNullable, first_byte_bit_offset: 0 }
/// buffer: 1 B
/// <BLANKLINE>
///
Expand All @@ -217,7 +217,7 @@ impl PyArray {
/// metadata: BitPackedMetadata { validity: Array, bit_width: 2, offset: 0, length: 4, has_patches: false }
/// buffer: 256 B
/// validity: vortex.bool(0x02)(bool, len=4) nbytes=1 B (100.00%)
/// metadata: BoolMetadata { validity: NonNullable, bit_offset: 0 }
/// metadata: BoolMetadata { validity: NonNullable, first_byte_bit_offset: 0 }
/// buffer: 1 B
/// <BLANKLINE>
///
Expand Down
10 changes: 5 additions & 5 deletions vortex-array/src/array/bool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl_encoding!("vortex.bool", ids::BOOL, Bool);
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct BoolMetadata {
validity: ValidityMetadata,
bit_offset: usize,
first_byte_bit_offset: u8,
}

impl BoolArray {
Expand All @@ -35,7 +35,7 @@ impl BoolArray {
pub fn boolean_buffer(&self) -> BooleanBuffer {
BooleanBuffer::new(
self.buffer().clone().into_arrow(),
self.metadata().bit_offset,
self.metadata().first_byte_bit_offset as usize,
self.len(),
)
}
Expand All @@ -51,8 +51,8 @@ impl BoolArray {
pub fn try_new(buffer: BooleanBuffer, validity: Validity) -> VortexResult<Self> {
let buffer_len = buffer.len();
let buffer_offset = buffer.offset();
let last_byte_bit_offset = buffer_offset % 8;
let buffer_byte_offset = buffer_offset - last_byte_bit_offset;
let first_byte_bit_offset = (buffer_offset % 8) as u8;
let buffer_byte_offset = buffer_offset - (first_byte_bit_offset as usize);

let inner = buffer
.into_inner()
Expand All @@ -64,7 +64,7 @@ impl BoolArray {
buffer_len,
BoolMetadata {
validity: validity.to_metadata(buffer_len)?,
bit_offset: last_byte_bit_offset,
first_byte_bit_offset,
},
Some(Buffer::from(inner)),
validity.into_array().into_iter().collect_vec().into(),
Expand Down

0 comments on commit 70d75b4

Please sign in to comment.