diff --git a/mountpoint-s3/src/data_cache.rs b/mountpoint-s3/src/data_cache.rs index 12e68ba60..e8dd730ce 100644 --- a/mountpoint-s3/src/data_cache.rs +++ b/mountpoint-s3/src/data_cache.rs @@ -7,8 +7,6 @@ mod disk_data_cache; mod in_memory_data_cache; -use std::ops::RangeBounds; - use mountpoint_s3_client::types::ETag; use thiserror::Error; @@ -52,16 +50,4 @@ pub trait DataCache { /// Returns the block size for the data cache. fn block_size(&self) -> u64; - - /// For the given range of blocks, which are present in the cache? - /// Indices in the vector are already sorted. - /// - /// It is possible that the **blocks may be deleted before reading**, or may be corrupted or inaccessible. - /// This method only indicates that a cache entry was present at the time of calling. - /// There is no guarantee that the data will still be available at the time of reading. - fn cached_block_indices>( - &self, - cache_key: &CacheKey, - range: R, - ) -> DataCacheResult>; } diff --git a/mountpoint-s3/src/data_cache/disk_data_cache.rs b/mountpoint-s3/src/data_cache/disk_data_cache.rs index 04b76ca33..07857fcef 100644 --- a/mountpoint-s3/src/data_cache/disk_data_cache.rs +++ b/mountpoint-s3/src/data_cache/disk_data_cache.rs @@ -2,7 +2,6 @@ use std::fs; use std::io::{ErrorKind, Read, Write}; -use std::ops::RangeBounds; use std::path::PathBuf; use bytes::Bytes; @@ -248,14 +247,6 @@ impl DataCache for DiskDataCache { fn block_size(&self) -> u64 { self.block_size } - - fn cached_block_indices>( - &self, - _cache_key: &CacheKey, - _range: R, - ) -> DataCacheResult> { - todo!("implement or deprecate"); - } } #[cfg(test)] diff --git a/mountpoint-s3/src/data_cache/in_memory_data_cache.rs b/mountpoint-s3/src/data_cache/in_memory_data_cache.rs index f9852bd97..eef1872bd 100644 --- a/mountpoint-s3/src/data_cache/in_memory_data_cache.rs +++ b/mountpoint-s3/src/data_cache/in_memory_data_cache.rs @@ -2,7 +2,6 @@ use std::collections::HashMap; use std::default::Default; -use std::ops::RangeBounds; use super::{BlockIndex, CacheKey, ChecksummedBytes, DataCache, DataCacheResult}; use crate::sync::RwLock; @@ -40,21 +39,6 @@ impl DataCache for InMemoryDataCache { fn block_size(&self) -> u64 { self.block_size } - - fn cached_block_indices>( - &self, - cache_key: &CacheKey, - range: R, - ) -> DataCacheResult> { - let data = self.data.read().unwrap(); - let mut result = match data.get(cache_key) { - None => Vec::new(), - Some(blocks) => blocks.keys().filter(|idx| range.contains(idx)).copied().collect(), - }; - result.sort(); - - Ok(result) - } } #[cfg(test)] @@ -139,43 +123,4 @@ mod tests { "cache entry returned should match original bytes after put" ); } - - #[test] - fn test_cached_indices() { - let data_1 = Bytes::from_static(b"Hello world"); - let data_1 = ChecksummedBytes::from_bytes(data_1.clone()); - let data_2 = Bytes::from_static(b"Foo bar"); - let data_2 = ChecksummedBytes::from_bytes(data_2.clone()); - - let cache = InMemoryDataCache::new(8 * 1024 * 1024); - let cache_key_1 = CacheKey { - s3_key: "a".into(), - etag: ETag::for_tests(), - }; - let cache_key_2 = CacheKey { - s3_key: "b".into(), - etag: ETag::for_tests(), - }; - - let cached_indices = cache - .cached_block_indices(&cache_key_1, 0..5) - .expect("should not error"); - let expected: Vec = Vec::new(); - assert_eq!(cached_indices, expected); - - cache - .put_block(cache_key_1.clone(), 2, data_1.clone()) - .expect("no reason to error, cache is accessible"); - cache - .put_block(cache_key_1.clone(), 3, data_2.clone()) - .expect("no reason to error, cache is accessible"); - cache - .put_block(cache_key_2.clone(), 5, data_2.clone()) - .expect("no reason to error, cache is accessible"); - - let cached_indices = cache - .cached_block_indices(&cache_key_1, 0..12) - .expect("should not error"); - assert_eq!(cached_indices, vec![2, 3]); - } }