coordinode-lsm-tree 4.3.1

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::tree::inner::TreeId;

pub type TableId = u64;

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct GlobalTableId(TreeId, TableId);

impl GlobalTableId {
    #[must_use]
    pub fn tree_id(&self) -> TreeId {
        self.0
    }

    #[must_use]
    pub fn table_id(&self) -> TableId {
        self.1
    }
}

impl From<(TreeId, TableId)> for GlobalTableId {
    fn from((tid, sid): (TreeId, TableId)) -> Self {
        Self(tid, sid)
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use test_log::test;

    #[test]
    fn global_table_id_accessors() {
        let tree_id = 42;
        let table_id: TableId = 7;
        let global_table_id = GlobalTableId::from((tree_id, table_id));

        assert_eq!(global_table_id.tree_id(), 42);
        assert_eq!(global_table_id.table_id(), 7);
    }
}