use crate::error::Result; use crate::sstable::{Key, SSTable, Value}; use crate::storage; use std::collections::BTreeMap; use std::ops::RangeInclusive; use std::sync::Arc; #[derive(Debug)] pub struct ReadTx { mem: Arc>, tables: Arc<[BTreeMap]>, } impl ReadTx { pub fn new(mem: BTreeMap, tables: Vec>) -> ReadTx { ReadTx { mem: Arc::new(mem), tables: Arc::from(tables.into_boxed_slice()), } } pub fn get(&self, key: &Key) -> Result>> { storage::get(&self.mem, &*self.tables, key) } pub fn range( &self, range: RangeInclusive, ) -> Result)>> { storage::range(&self.mem, &*self.tables, range) } }