Skip to content

Commit

Permalink
Store block offsets in disk data cache (#611)
Browse files Browse the repository at this point in the history
* Store block offsets in disk data cache

Signed-off-by: Alessandro Passaro <[email protected]>

* Add the block offset to the methods in data cache

Signed-off-by: Alessandro Passaro <[email protected]>

* Fix typo

Signed-off-by: Alessandro Passaro <[email protected]>

* Remove redundant variable

Signed-off-by: Alessandro Passaro <[email protected]>

---------

Signed-off-by: Alessandro Passaro <[email protected]>
  • Loading branch information
passaro authored Nov 17, 2023
1 parent 06a1d7d commit b23eaca
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 94 deletions.
17 changes: 15 additions & 2 deletions mountpoint-s3/src/data_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub enum DataCacheError {
IoFailure(#[from] std::io::Error),
#[error("Block content was not valid/readable")]
InvalidBlockContent,
#[error("Block offset does not match block index")]
InvalidBlockOffset,
#[error("Error while trying to evict cache content")]
EvictionFailure,
}
Expand All @@ -45,10 +47,21 @@ pub trait DataCache {
/// Get block of data from the cache for the given [CacheKey] and [BlockIndex], if available.
///
/// Operation may fail due to errors, or return [None] if the block was not available in the cache.
fn get_block(&self, cache_key: &CacheKey, block_idx: BlockIndex) -> DataCacheResult<Option<ChecksummedBytes>>;
fn get_block(
&self,
cache_key: &CacheKey,
block_idx: BlockIndex,
block_offset: u64,
) -> DataCacheResult<Option<ChecksummedBytes>>;

/// Put block of data to the cache for the given [CacheKey] and [BlockIndex].
fn put_block(&self, cache_key: CacheKey, block_idx: BlockIndex, bytes: ChecksummedBytes) -> DataCacheResult<()>;
fn put_block(
&self,
cache_key: CacheKey,
block_idx: BlockIndex,
block_offset: u64,
bytes: ChecksummedBytes,
) -> DataCacheResult<()>;

/// Returns the block size for the data cache.
fn block_size(&self) -> u64;
Expand Down
Loading

0 comments on commit b23eaca

Please sign in to comment.