coordinode-lsm-tree 4.4.0

A K.I.S.S. implementation of log-structured merge trees (LSM-trees/LSMTs) — CoordiNode fork
Documentation
// Copyright (c) 2024-present, fjall-rs
// This source code is licensed under both the Apache 2.0 and MIT License
// (found in the LICENSE-* files in the repository)

use crate::{SeqNo, UserKey, table::BlockOffset};

pub struct Metadata {
    /// Written data block count
    pub data_block_count: usize,

    /// Written item count
    pub item_count: usize,

    /// Tombstone count
    pub tombstone_count: usize,

    /// Weak tombstone (single delete) count
    pub weak_tombstone_count: usize,

    /// Weak tombstone + value pairs that become reclaimable when GC watermark advances
    pub weak_tombstone_reclaimable_count: usize,

    /// Written key count (unique keys)
    pub key_count: usize,

    /// Current file position of writer
    pub file_pos: BlockOffset,

    /// Only takes user data into account
    pub uncompressed_size: u64,

    /// First encountered key
    pub first_key: Option<UserKey>,

    /// Last encountered key
    pub last_key: Option<UserKey>,

    /// Lowest encountered seqno
    pub lowest_seqno: SeqNo,

    /// Highest encountered seqno (includes both KV and RT)
    pub highest_seqno: SeqNo,

    /// Highest encountered seqno from KV entries only (excludes range tombstones).
    ///
    /// Used for table-skip decisions: a covering RT stored in the same table
    /// can now trigger skip because `rt.seqno > highest_kv_seqno` may be true
    /// even when `rt.seqno <= highest_seqno`.
    pub highest_kv_seqno: SeqNo,
}

impl Default for Metadata {
    fn default() -> Self {
        Self {
            data_block_count: 0,

            item_count: 0,
            tombstone_count: 0,
            weak_tombstone_count: 0,
            weak_tombstone_reclaimable_count: 0,
            key_count: 0,
            file_pos: BlockOffset(0),
            uncompressed_size: 0,

            first_key: None,
            last_key: None,

            lowest_seqno: SeqNo::MAX,
            highest_seqno: 0,
            highest_kv_seqno: 0,
        }
    }
}