Skip to content

Commit

Permalink
new new impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed Sep 1, 2024
1 parent 12720dc commit 3ed3847
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::{
collections::VecDeque,
fmt::{self, Debug},
iter,
ops::{Index, IndexMut, Shl},
ops::{Index, IndexMut},
};

use arrow::{
Expand Down Expand Up @@ -484,30 +484,29 @@ impl BlockedGroupIndex {
}

pub struct BlockedGroupIndexBuilder {
block_id_mask: u64,
block_offset_mask: u64,
id_shift: u64,
}

impl BlockedGroupIndexBuilder {
pub fn new(is_blocked: bool) -> Self {
if is_blocked {
Self {
block_id_mask: BLOCKED_GROUP_INDEX_ID_MASK,
block_offset_mask: BLOCKED_GROUP_INDEX_OFFSET_MASK,
block_offset_mask: 0x00000000ffffffff,
id_shift: 32,
}
} else {
Self {
block_id_mask: FLAT_GROUP_INDEX_ID_MASK,
block_offset_mask: FLAT_GROUP_INDEX_OFFSET_MASK,
block_offset_mask: u64::MAX,
id_shift: 0,
}
}
}

#[inline]
pub fn build(&self, packed_index: usize) -> BlockedGroupIndex {
let packed_index = packed_index as u64;
let block_id = ((packed_index & self.block_id_mask) >> 32) as u32;
let block_offset = packed_index & self.block_offset_mask;
let block_id = (packed_index as u64 & self.id_shift) as u32;
let block_offset = packed_index as u64 & self.block_offset_mask;

BlockedGroupIndex {
block_id,
Expand Down

0 comments on commit 3ed3847

Please sign in to comment.