Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

Commit

Permalink
fix: Bound::Excluded may cause the read data to be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Mar 13, 2024
1 parent b855736 commit a0699b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kip_db"
version = "0.1.2-alpha.25.fix1"
version = "0.1.2-alpha.25.fix2"
edition = "2021"
authors = ["Kould <[email protected]>"]
description = "轻量级、异步 基于LSM Leveled Compaction K-V数据库"
Expand Down
20 changes: 14 additions & 6 deletions src/kernel/lsm/mvcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,22 @@ impl<'a> Iter<'a> for TransactionIter<'a> {
let mut item = self.inner.try_next()?;

if !self.is_inited {
item = match &self.min {
Bound::Included(key) => item.and_then(|data| (data.0 >= key).then_some(data)),
Bound::Excluded(key) => item.and_then(|data| (data.0 > key).then_some(data)),
Bound::Unbounded => item,
};
loop {
if match &self.min {
Bound::Included(key) => {
!matches!(item.as_ref().map(|data| data.0 < key), Some(true))
}
Bound::Excluded(key) => {
!matches!(item.as_ref().map(|data| data.0 <= key), Some(true))
}
Bound::Unbounded => true,
} {
break;
}
item = self.inner.try_next()?;
}
self.is_inited = true
}

let option = match &self.max {
Bound::Included(key) => item.and_then(|data| (data.0 <= key).then_some(data)),
Bound::Excluded(key) => item.and_then(|data| (data.0 < key).then_some(data)),
Expand Down

0 comments on commit a0699b2

Please sign in to comment.