Skip to content

Commit 0dde100

Browse files
committed
add timestamp field to segment header
1 parent d569e2a commit 0dde100

3 files changed

Lines changed: 5 additions & 0 deletions

File tree

libsql-wal/src/segment/compacted.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub struct CompactedSegmentDataHeader {
2323
pub(crate) size_after: lu32,
2424
/// for now, always 4096
2525
pub(crate) page_size: lu16,
26+
pub(crate) timestamp: lu64,
2627
}
2728
impl CompactedSegmentDataHeader {
2829
fn check(&self) -> Result<()> {

libsql-wal/src/segment/sealed.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ where
9494
version: LIBSQL_WAL_VERSION.into(),
9595
magic: LIBSQL_MAGIC.into(),
9696
page_size: self.header().page_size,
97+
timestamp: self.header.sealed_at_timestamp,
9798
};
9899

99100
hasher.update(header.as_bytes());

libsql-wal/src/storage/compaction/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ impl<B> Compactor<B> {
246246
version: LIBSQL_WAL_VERSION.into(),
247247
magic: LIBSQL_MAGIC.into(),
248248
page_size: last_header.page_size,
249+
// the new compacted segment inherit the last segment timestamp: it contains the same
250+
// logical data.
251+
timestamp: last_header.timestamp,
249252
};
250253

251254
hasher.update(header.as_bytes());

0 commit comments

Comments
 (0)