Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/storage/chunk_engine/src/types/group_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ impl GroupId {
// 32bit chunk size + 24bit group + 8bit cluster
const SHIFT: u32 = 8;
pub const COUNT: u32 = (1 << Self::SHIFT);
pub const CLUSTER_MASK: u64 = (Self::COUNT - 1) as u64;
pub const GROUP_MASK: u64 = ((1u64 << 24) - 1) << Self::SHIFT;

pub const fn new(chunk_size: Size, cluster: u8, group: u32) -> Self {
Self(chunk_size.0 << 32 | (group << Self::SHIFT | cluster as u32) as u64)
Expand All @@ -31,8 +33,7 @@ impl GroupId {
}

pub fn offset(&self) -> Size {
const MARKS: u64 = !(GroupId::COUNT - 1) as u64;
self.chunk_size() * (self.0 & MARKS)
self.chunk_size() * (self.0 & Self::GROUP_MASK)
}

pub fn size(&self) -> Size {
Expand Down
3 changes: 1 addition & 2 deletions src/storage/chunk_engine/src/types/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ impl Position {
}

pub fn group_id(&self) -> GroupId {
const MARKS: u64 = (GroupId::COUNT - 1) as u64;
const CLEAN: u64 = !(MARKS | MARKS << 32);
const CLEAN: u64 = !(GroupId::CLUSTER_MASK | GroupId::CLUSTER_MASK << 32);
GroupId::from(self.0 & CLEAN | self.cluster() as u64)
}

Expand Down