Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move sst meta offset to the end of the object #8524

Merged
merged 1 commit into from
Mar 14, 2023
Merged
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/src/hummock/sstable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ impl SstableMeta {
/// | smallest key len (4B) | smallest key |
/// | largest key len (4B) | largest key |
/// | range-tombstone 0 | ... | range-tombstone M-1 |
/// | file offset of this meta block (8B) |
/// | checksum (8B) | version (4B) | magic (4B) |
/// ```
pub fn encode_to_bytes(&self) -> Vec<u8> {
Expand All @@ -299,11 +300,11 @@ impl SstableMeta {
buf.put_u32_le(self.key_count);
put_length_prefixed_slice(buf, &self.smallest_key);
put_length_prefixed_slice(buf, &self.largest_key);
buf.put_u64_le(self.meta_offset);
buf.put_u32_le(self.range_tombstone_list.len() as u32);
for tombstone in &self.range_tombstone_list {
tombstone.encode(buf);
}
buf.put_u64_le(self.meta_offset);
let checksum = xxhash64_checksum(&buf[start_offset..]);
buf.put_u64_le(checksum);
buf.put_u32_le(VERSION);
Expand Down Expand Up @@ -340,13 +341,13 @@ impl SstableMeta {
let key_count = buf.get_u32_le();
let smallest_key = get_length_prefixed_slice(buf);
let largest_key = get_length_prefixed_slice(buf);
let meta_offset = buf.get_u64_le();
let range_del_count = buf.get_u32_le() as usize;
let mut range_tombstone_list = Vec::with_capacity(range_del_count);
for _ in 0..range_del_count {
let tombstone = DeleteRangeTombstone::decode(buf);
range_tombstone_list.push(tombstone);
}
let meta_offset = buf.get_u64_le();

Ok(Self {
block_metas,
Expand Down