// Copyright (c) 2022-2025 Alex Chi Z // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #![allow(unused_variables)] // TODO(you): remove this lint after implementing this mod #![allow(dead_code)] // TODO(you): remove this lint after implementing this mod use std::{ collections::HashSet, ops::Bound, sync::{Arc, atomic::AtomicBool}, }; use anyhow::Result; use bytes::Bytes; use crossbeam_skiplist::SkipMap; use ouroboros::self_referencing; use parking_lot::Mutex; use crate::{ iterators::{StorageIterator, two_merge_iterator::TwoMergeIterator}, lsm_iterator::{FusedIterator, LsmIterator}, lsm_storage::LsmStorageInner, }; pub struct Transaction { pub(crate) read_ts: u64, pub(crate) inner: Arc, pub(crate) local_storage: Arc>, pub(crate) committed: Arc, /// Write set and read set pub(crate) key_hashes: Option, HashSet)>>, } impl Transaction { pub fn get(&self, key: &[u8]) -> Result> { unimplemented!() } pub fn scan(self: &Arc, lower: Bound<&[u8]>, upper: Bound<&[u8]>) -> Result { unimplemented!() } pub fn put(&self, key: &[u8], value: &[u8]) { unimplemented!() } pub fn delete(&self, key: &[u8]) { unimplemented!() } pub fn commit(&self) -> Result<()> { unimplemented!() } } impl Drop for Transaction { fn drop(&mut self) {} } type SkipMapRangeIter<'a> = crossbeam_skiplist::map::Range<'a, Bytes, (Bound, Bound), Bytes, Bytes>; #[self_referencing] pub struct TxnLocalIterator { /// Stores a reference to the skipmap. map: Arc>, /// Stores a skipmap iterator that refers to the lifetime of `TxnLocalIterator` itself. #[borrows(map)] #[not_covariant] iter: SkipMapRangeIter<'this>, /// Stores the current key-value pair. item: (Bytes, Bytes), } impl StorageIterator for TxnLocalIterator { type KeyType<'a> = &'a [u8]; fn value(&self) -> &[u8] { unimplemented!() } fn key(&self) -> &[u8] { unimplemented!() } fn is_valid(&self) -> bool { unimplemented!() } fn next(&mut self) -> Result<()> { unimplemented!() } } pub struct TxnIterator { _txn: Arc, iter: TwoMergeIterator>, } impl TxnIterator { pub fn create( txn: Arc, iter: TwoMergeIterator>, ) -> Result { unimplemented!() } } impl StorageIterator for TxnIterator { type KeyType<'a> = &'a [u8] where Self: 'a; fn value(&self) -> &[u8] { self.iter.value() } fn key(&self) -> Self::KeyType<'_> { self.iter.key() } fn is_valid(&self) -> bool { self.iter.is_valid() } fn next(&mut self) -> Result<()> { unimplemented!() } fn num_active_iterators(&self) -> usize { self.iter.num_active_iterators() } }