Rename 'InMemoryLayer::img_layer' field.

DeltaLayer uses the name `predecessor` for the same thing. Use the
same name in InMemoryLayer. The 'img_layer' name was misleading, as
the predecessor layer is not necessarily an image layer. Currently,
the 'freeze' function always creates a new image layer, but it
wouldn't have to be that way. Also, when you create a new branch, at
the branch point the predecessor layer can be a delta layer on the
ancestor branch.
This commit is contained in:
Heikki Linnakangas
2021-09-02 14:22:26 +03:00
parent 3c5452da88
commit 81479b0218
2 changed files with 8 additions and 8 deletions

View File

@@ -109,7 +109,7 @@ pub struct DeltaLayer {
dropped: bool,
/// Base layer preceding this layer.
/// Predecessor layer
predecessor: Option<Arc<dyn Layer>>,
inner: Mutex<DeltaLayerInner>,

View File

@@ -42,7 +42,7 @@ pub struct InMemoryLayer {
inner: Mutex<InMemoryLayerInner>,
/// Predecessor layer
img_layer: Option<Arc<dyn Layer>>,
predecessor: Option<Arc<dyn Layer>>,
}
pub struct InMemoryLayerInner {
@@ -169,9 +169,9 @@ impl Layer for InMemoryLayer {
// Use the base image, if needed
if let Some(need_lsn) = need_base_image_lsn {
if let Some(img_layer) = &self.img_layer {
if let Some(predecessor) = &self.predecessor {
need_base_image_lsn =
img_layer.get_page_reconstruct_data(blknum, need_lsn, reconstruct_data)?;
predecessor.get_page_reconstruct_data(blknum, need_lsn, reconstruct_data)?;
} else {
bail!(
"no base img found for {} at blk {} at LSN {}",
@@ -225,7 +225,7 @@ impl Layer for InMemoryLayer {
}
fn is_incremental(&self) -> bool {
self.img_layer.is_some()
self.predecessor.is_some()
}
/// debugging function to print out the contents of the layer
@@ -290,7 +290,7 @@ impl InMemoryLayer {
page_versions: BTreeMap::new(),
segsizes: BTreeMap::new(),
}),
img_layer: None,
predecessor: None,
})
}
@@ -431,7 +431,7 @@ impl InMemoryLayer {
page_versions: BTreeMap::new(),
segsizes: segsizes,
}),
img_layer: Some(src),
predecessor: Some(src),
})
}
@@ -525,7 +525,7 @@ impl InMemoryLayer {
self.start_lsn,
end_lsn,
dropped,
self.img_layer.clone(),
self.predecessor.clone(),
before_page_versions,
before_segsizes,
)?;