Skip to content

Commit

Permalink
remove split entry
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Apr 25, 2024
1 parent 187d5d1 commit 18f9af2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
12 changes: 2 additions & 10 deletions libsql-wal/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,6 @@ impl LogHeader {
}
}

/// split the index entry value into it's components: (frame_no, offset)
pub fn index_entry_split(k: u64) -> (u32, u32) {
let offset = (k & u32::MAX as u64) as u32;
let frame_no = (k >> 32) as u32;
(frame_no, offset)
}

#[repr(C)]
#[derive(Debug, zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes)]
pub struct FrameHeader {
Expand Down Expand Up @@ -559,9 +552,8 @@ impl<F: FileExt> SealedLog<F> {
}

let index = self.index();
if let Some(value) = index.get(page_no.to_be_bytes()) {
let (_f, offset) = index_entry_split(value);
self.read_page_offset(offset, buf)?;
if let Some(offset) = index.get(page_no.to_be_bytes()) {
self.read_page_offset(offset as u32, buf)?;

return Ok(true);
}
Expand Down
4 changes: 2 additions & 2 deletions libsql-wal/src/segment_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use zerocopy::{AsBytes, FromZeroes};

use crate::error::Result;
use crate::fs::file::FileExt;
use crate::log::{index_entry_split, Frame, SealedLog};
use crate::log::{Frame, SealedLog};

struct SegmentLink<F> {
log: SealedLog<F>,
Expand Down Expand Up @@ -124,7 +124,7 @@ impl<F> SegmentList<F> {
let page_no = u32::from_be_bytes(k.try_into().unwrap());
let v = v.iter().min_by_key(|i| i.index).unwrap();
let seg = &segs[v.index];
let (_, offset) = index_entry_split(v.value);
let offset = v.value as u32;
seg.log.read_frame_offset(offset, &mut buf)?;
assert_eq!(buf.header().page_no(), page_no);
last_replication_index = last_replication_index.max(buf.header().frame_no());
Expand Down

0 comments on commit 18f9af2

Please sign in to comment.