Fix lsn bound

This commit is contained in:
Bojan Serafimov
2023-01-11 13:59:26 -05:00
parent e392d25828
commit dbb5d0800d
2 changed files with 4 additions and 2 deletions

View File

@@ -263,7 +263,9 @@ where
key_range: &Range<Key>,
lsn: Lsn,
) -> Result<Vec<(Range<Key>, Option<Arc<L>>)>> {
let version = match self.historic.get().unwrap().get_version(lsn.0 - 1) {
// TODO I'm 80% sure the lsn bound is inclusive. Double-check that
// and document it. Do the same for image_layer_exists and count_deltas
let version = match self.historic.get().unwrap().get_version(lsn.0) {
Some(v) => v,
None => return Ok(vec![]),
};

View File

@@ -65,7 +65,7 @@ impl<Value: Clone> HistoricLayerCoverage<Value> {
self.historic.insert(lsn.start, self.head.clone());
}
/// Query at a particular LSN
/// Query at a particular LSN, inclusive
pub fn get_version(self: &Self, lsn: u64) -> Option<&LayerCoverageTuple<Value>> {
match self.historic.range(..=lsn).rev().next() {
Some((_, v)) => Some(v),