Skip to content

Commit

Permalink
Cleanup some lifetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
cberner committed Jan 20, 2024
1 parent 929b42b commit 4b8fc3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
13 changes: 5 additions & 8 deletions src/tree_store/btree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl UntypedBtreeMut {
}
}

pub(crate) struct BtreeMut<'a, K: RedbKey, V: RedbValue> {
pub(crate) struct BtreeMut<'a, K: RedbKey + 'static, V: RedbValue + 'static> {
mem: Arc<TransactionalMemory>,
transaction_guard: Arc<TransactionGuard>,
root: Arc<Mutex<Option<(PageNumber, Checksum)>>>,
Expand All @@ -227,7 +227,7 @@ pub(crate) struct BtreeMut<'a, K: RedbKey, V: RedbValue> {
_lifetime: PhantomData<&'a ()>,
}

impl<'a, K: RedbKey + 'a, V: RedbValue + 'a> BtreeMut<'a, K, V> {
impl<K: RedbKey + 'static, V: RedbValue + 'static> BtreeMut<'_, K, V> {
pub(crate) fn new(
root: Option<(PageNumber, Checksum)>,
guard: Arc<TransactionGuard>,
Expand Down Expand Up @@ -552,7 +552,7 @@ impl RawBtree {
}
}

pub(crate) struct Btree<K: RedbKey, V: RedbValue> {
pub(crate) struct Btree<K: RedbKey + 'static, V: RedbValue + 'static> {
mem: Arc<TransactionalMemory>,
_transaction_guard: Arc<TransactionGuard>,
// Cache of the root page to avoid repeated lookups
Expand Down Expand Up @@ -621,13 +621,10 @@ impl<K: RedbKey, V: RedbValue> Btree<K, V> {
}
}

pub(crate) fn range<'a0, T: RangeBounds<KR> + 'a0, KR: Borrow<K::SelfType<'a0>> + 'a0>(
pub(crate) fn range<'a0, T: RangeBounds<KR>, KR: Borrow<K::SelfType<'a0>>>(
&self,
range: &'_ T,
) -> Result<BtreeRangeIter<K, V>>
where
K: 'a0,
{
) -> Result<BtreeRangeIter<K, V>> {
BtreeRangeIter::new(range, self.root.map(|(p, _)| p), self.mem.clone())
}

Expand Down
17 changes: 7 additions & 10 deletions src/tree_store/btree_iters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl Iterator for AllPageNumbersBtreeIter {
}
}

pub(crate) struct BtreeDrain<K: RedbKey, V: RedbValue> {
pub(crate) struct BtreeDrain<K: RedbKey + 'static, V: RedbValue + 'static> {
inner: BtreeRangeIter<K, V>,
free_on_drop: Vec<PageNumber>,
master_free_list: Arc<Mutex<Vec<PageNumber>>>,
Expand Down Expand Up @@ -298,8 +298,8 @@ impl<K: RedbKey, V: RedbValue> Drop for BtreeDrain<K, V> {
}

pub(crate) struct BtreeDrainFilter<
K: RedbKey,
V: RedbValue,
K: RedbKey + 'static,
V: RedbValue + 'static,
F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool,
> {
inner: BtreeRangeIter<K, V>,
Expand Down Expand Up @@ -380,7 +380,7 @@ impl<K: RedbKey, V: RedbValue, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>
}
}

pub(crate) struct BtreeRangeIter<K: RedbKey, V: RedbValue> {
pub(crate) struct BtreeRangeIter<K: RedbKey + 'static, V: RedbValue + 'static> {
left: Option<RangeIterState>, // Exclusive. The previous element returned
right: Option<RangeIterState>, // Exclusive. The previous element returned
include_left: bool, // left is inclusive, instead of exclusive
Expand All @@ -390,15 +390,12 @@ pub(crate) struct BtreeRangeIter<K: RedbKey, V: RedbValue> {
_value_type: PhantomData<V>,
}

impl<K: RedbKey, V: RedbValue> BtreeRangeIter<K, V> {
pub(crate) fn new<'a0, T: RangeBounds<KR> + 'a0, KR: Borrow<K::SelfType<'a0>> + 'a0>(
impl<K: RedbKey + 'static, V: RedbValue + 'static> BtreeRangeIter<K, V> {
pub(crate) fn new<'a, T: RangeBounds<KR>, KR: Borrow<K::SelfType<'a>>>(
query_range: &'_ T,
table_root: Option<PageNumber>,
manager: Arc<TransactionalMemory>,
) -> Result<Self>
where
K: 'a0,
{
) -> Result<Self> {
if let Some(root) = table_root {
let (include_left, left) = match query_range.start_bound() {
Bound::Included(k) => find_iter_left::<K, V>(
Expand Down

0 comments on commit 4b8fc3e

Please sign in to comment.