no-op: type aliases for Layer::iter and Layer::key_iter return types

Not needed by anything right now, but the next commit adds a `Result<>`
around iter() and key_iter()'s return types, and that makes clippy
complain.
This commit is contained in:
Christian Schwarz
2022-12-07 12:52:25 -05:00
committed by Christian Schwarz
parent 91e8937112
commit f5b424b96c
3 changed files with 14 additions and 8 deletions

View File

@@ -55,7 +55,7 @@ use utils::{
};
use super::filename::LayerFileName;
use super::storage_layer::Layer;
use super::storage_layer::{Layer, LayerIter, LayerKeyIter};
///
/// Header stored in the beginning of the file
@@ -391,7 +391,7 @@ impl PersistentLayer for DeltaLayer {
self.path()
}
fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = anyhow::Result<(Key, Lsn, Value)>> + 'a> {
fn iter(&self) -> LayerIter<'_> {
let inner = match self.load() {
Ok(inner) => inner,
Err(e) => panic!("Failed to load a delta layer: {e:?}"),
@@ -403,7 +403,7 @@ impl PersistentLayer for DeltaLayer {
}
}
fn key_iter<'a>(&'a self) -> Box<dyn Iterator<Item = (Key, Lsn, u64)> + 'a> {
fn key_iter(&self) -> LayerKeyIter<'_> {
let inner = match self.load() {
Ok(inner) => inner,
Err(e) => panic!("Failed to load a delta layer: {e:?}"),

View File

@@ -21,7 +21,7 @@
//! actual page images are stored in the "values" part.
use crate::config::PageServerConf;
use crate::page_cache::PAGE_SZ;
use crate::repository::{Key, Value, KEY_SIZE};
use crate::repository::{Key, KEY_SIZE};
use crate::tenant::blob_io::{BlobCursor, BlobWriter, WriteBlobWriter};
use crate::tenant::block_io::{BlockBuf, BlockReader, FileBlockReader};
use crate::tenant::disk_btree::{DiskBtreeBuilder, DiskBtreeReader, VisitDirection};
@@ -51,7 +51,7 @@ use utils::{
};
use super::filename::LayerFileName;
use super::storage_layer::Layer;
use super::storage_layer::{Layer, LayerIter};
///
/// Header stored in the beginning of the file
@@ -219,7 +219,7 @@ impl PersistentLayer for ImageLayer {
fn get_timeline_id(&self) -> TimelineId {
self.timeline_id
}
fn iter(&self) -> Box<dyn Iterator<Item = Result<(Key, Lsn, Value)>>> {
fn iter(&self) -> LayerIter<'_> {
unimplemented!();
}

View File

@@ -116,6 +116,12 @@ pub trait Layer: Send + Sync {
fn dump(&self, verbose: bool) -> Result<()>;
}
/// Returned by [`Layer::iter`]
pub type LayerIter<'i> = Box<dyn Iterator<Item = Result<(Key, Lsn, Value)>> + 'i>;
/// Returned by [`Layer::key_iter`]
pub type LayerKeyIter<'i> = Box<dyn Iterator<Item = (Key, Lsn, u64)> + 'i>;
/// A Layer contains all data in a "rectangle" consisting of a range of keys and
/// range of LSNs.
///
@@ -144,11 +150,11 @@ pub trait PersistentLayer: Layer {
fn local_path(&self) -> PathBuf;
/// Iterate through all keys and values stored in the layer
fn iter(&self) -> Box<dyn Iterator<Item = Result<(Key, Lsn, Value)>> + '_>;
fn iter(&self) -> LayerIter<'_>;
/// Iterate through all keys stored in the layer. Returns key, lsn and value size
/// It is used only for compaction and so is currently implemented only for DeltaLayer
fn key_iter(&self) -> Box<dyn Iterator<Item = (Key, Lsn, u64)> + '_> {
fn key_iter(&self) -> LayerKeyIter<'_> {
panic!("Not implemented")
}