Browse Source

feat(storage): sort needles by offset during compaction

rust-volume-server
Chris Lu 5 days ago
parent
commit
371fa1e8a0
  1. 2
      seaweed-volume/src/storage/types.rs
  2. 2
      seaweed-volume/src/storage/volume.rs

2
seaweed-volume/src/storage/types.rs

@ -176,7 +176,7 @@ impl From<Size> for i32 {
/// [b3][b2][b1][b0] (big-endian 4 bytes) /// [b3][b2][b1][b0] (big-endian 4 bytes)
/// ///
/// actual_offset = stored_value * 8 /// actual_offset = stored_value * 8
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct Offset { pub struct Offset {
pub b0: u8, pub b0: u8,
pub b1: u8, pub b1: u8,

2
seaweed-volume/src/storage/volume.rs

@ -1649,7 +1649,7 @@ impl Volume {
} }
entries.push((id, nv.offset, nv.size)); entries.push((id, nv.offset, nv.size));
} }
entries.sort_by_key(|(id, _, _)| *id);
entries.sort_by_key(|(_, offset, _)| *offset);
for (id, offset, size) in entries { for (id, offset, size) in entries {
// Progress callback // Progress callback

Loading…
Cancel
Save