From 8d16088c244801df1bd2e6b1cc06516d817756b6 Mon Sep 17 00:00:00 2001 From: Croxx Date: Fri, 7 Jun 2024 15:20:06 +0800 Subject: [PATCH] chore(storage): rename field with _v2 (#17166) Signed-off-by: MrCroxx --- src/ctl/src/common/hummock_service.rs | 8 +-- src/jni_core/src/hummock_iterator.rs | 8 +-- src/storage/benches/bench_compactor.rs | 8 +-- src/storage/benches/bench_multi_builder.rs | 8 +-- .../hummock_test/src/bin/replay/main.rs | 8 +-- .../src/hummock/iterator/test_utils.rs | 8 +-- src/storage/src/hummock/sstable_store.rs | 60 +++++++++---------- src/storage/src/store_impl.rs | 8 +-- .../src/delete_range_runner.rs | 8 +-- 9 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/ctl/src/common/hummock_service.rs b/src/ctl/src/common/hummock_service.rs index c71e7facc287..59d272c3a27f 100644 --- a/src/ctl/src/common/hummock_service.rs +++ b/src/ctl/src/common/hummock_service.rs @@ -168,13 +168,13 @@ impl HummockServiceOpts { let opts = self.get_storage_opts(); - let meta_cache_v2 = HybridCacheBuilder::new() + let meta_cache = HybridCacheBuilder::new() .memory(opts.meta_cache_capacity_mb * (1 << 20)) .with_shards(opts.meta_cache_shard_num) .storage() .build() .await?; - let block_cache_v2 = HybridCacheBuilder::new() + let block_cache = HybridCacheBuilder::new() .memory(opts.block_cache_capacity_mb * (1 << 20)) .with_shards(opts.block_cache_shard_num) .storage() @@ -190,8 +190,8 @@ impl HummockServiceOpts { state_store_metrics: Arc::new(global_hummock_state_store_metrics( MetricLevel::Disabled, )), - meta_cache_v2, - block_cache_v2, + meta_cache, + block_cache, }))) } } diff --git a/src/jni_core/src/hummock_iterator.rs b/src/jni_core/src/hummock_iterator.rs index 4fc6bce57e6e..c4445dece131 100644 --- a/src/jni_core/src/hummock_iterator.rs +++ b/src/jni_core/src/hummock_iterator.rs @@ -79,7 +79,7 @@ impl HummockJavaBindingIterator { .await, ); - let meta_cache_v2 = HybridCacheBuilder::new() + let meta_cache = HybridCacheBuilder::new() .memory(1 << 10) .with_shards(2) .storage() @@ -87,7 +87,7 @@ impl HummockJavaBindingIterator { .map_err(HummockError::foyer_error) .map_err(StorageError::from) .await?; - let block_cache_v2 = HybridCacheBuilder::new() + let block_cache = HybridCacheBuilder::new() .memory(1 << 10) .with_shards(2) .storage() @@ -105,8 +105,8 @@ impl HummockJavaBindingIterator { state_store_metrics: Arc::new(global_hummock_state_store_metrics( MetricLevel::Disabled, )), - meta_cache_v2, - block_cache_v2, + meta_cache, + block_cache, })); let reader = HummockVersionReader::new( sstable_store, diff --git a/src/storage/benches/bench_compactor.rs b/src/storage/benches/bench_compactor.rs index 085fb722ec60..1ccb3a4eccaa 100644 --- a/src/storage/benches/bench_compactor.rs +++ b/src/storage/benches/bench_compactor.rs @@ -58,14 +58,14 @@ pub async fn mock_sstable_store() -> SstableStoreRef { ); let store = Arc::new(ObjectStoreImpl::InMem(store)); let path = "test".to_string(); - let meta_cache_v2 = HybridCacheBuilder::new() + let meta_cache = HybridCacheBuilder::new() .memory(64 << 20) .with_shards(2) .storage() .build() .await .unwrap(); - let block_cache_v2 = HybridCacheBuilder::new() + let block_cache = HybridCacheBuilder::new() .memory(128 << 20) .with_shards(2) .storage() @@ -81,8 +81,8 @@ pub async fn mock_sstable_store() -> SstableStoreRef { recent_filter: None, state_store_metrics: Arc::new(global_hummock_state_store_metrics(MetricLevel::Disabled)), - meta_cache_v2, - block_cache_v2, + meta_cache, + block_cache, })) } diff --git a/src/storage/benches/bench_multi_builder.rs b/src/storage/benches/bench_multi_builder.rs index 8d96001d2db7..08318891eac8 100644 --- a/src/storage/benches/bench_multi_builder.rs +++ b/src/storage/benches/bench_multi_builder.rs @@ -132,14 +132,14 @@ async fn build_tables( } async fn generate_sstable_store(object_store: Arc) -> Arc { - let meta_cache_v2 = HybridCacheBuilder::new() + let meta_cache = HybridCacheBuilder::new() .memory(64 << 20) .with_shards(2) .storage() .build() .await .unwrap(); - let block_cache_v2 = HybridCacheBuilder::new() + let block_cache = HybridCacheBuilder::new() .memory(128 << 20) .with_shards(2) .storage() @@ -153,8 +153,8 @@ async fn generate_sstable_store(object_store: Arc) -> Arc Result Result SstableStoreRef { pub async fn mock_sstable_store_with_object_store(store: ObjectStoreRef) -> SstableStoreRef { let path = "test".to_string(); - let meta_cache_v2 = HybridCacheBuilder::new() + let meta_cache = HybridCacheBuilder::new() .memory(64 << 20) .with_shards(2) .storage() .build() .await .unwrap(); - let block_cache_v2 = HybridCacheBuilder::new() + let block_cache = HybridCacheBuilder::new() .memory(64 << 20) .with_shards(2) .storage() @@ -91,8 +91,8 @@ pub async fn mock_sstable_store_with_object_store(store: ObjectStoreRef) -> Ssta recent_filter: None, state_store_metrics: Arc::new(global_hummock_state_store_metrics(MetricLevel::Disabled)), - meta_cache_v2, - block_cache_v2, + meta_cache, + block_cache, })) } diff --git a/src/storage/src/hummock/sstable_store.rs b/src/storage/src/hummock/sstable_store.rs index 7bd1a98b51c6..a6ab2a6162e0 100644 --- a/src/storage/src/hummock/sstable_store.rs +++ b/src/storage/src/hummock/sstable_store.rs @@ -126,16 +126,16 @@ pub struct SstableStoreConfig { pub recent_filter: Option>>, pub state_store_metrics: Arc, - pub meta_cache_v2: HybridCache>, - pub block_cache_v2: HybridCache>, + pub meta_cache: HybridCache>, + pub block_cache: HybridCache>, } pub struct SstableStore { path: String, store: ObjectStoreRef, - meta_cache_v2: HybridCache>, - block_cache_v2: HybridCache>, + meta_cache: HybridCache>, + block_cache: HybridCache>, /// Recent filter for `(sst_obj_id, blk_idx)`. /// @@ -155,8 +155,8 @@ impl SstableStore { path: config.path, store: config.store, - meta_cache_v2: config.meta_cache_v2, - block_cache_v2: config.block_cache_v2, + meta_cache: config.meta_cache, + block_cache: config.block_cache, recent_filter: config.recent_filter, prefetch_buffer_usage: Arc::new(AtomicUsize::new(0)), @@ -174,7 +174,7 @@ impl SstableStore { block_cache_capacity: usize, meta_cache_capacity: usize, ) -> HummockResult { - let meta_cache_v2 = HybridCacheBuilder::new() + let meta_cache = HybridCacheBuilder::new() .memory(meta_cache_capacity) .with_shards(1) .with_weighter(|_: &HummockSstableObjectId, value: &Box| { @@ -185,7 +185,7 @@ impl SstableStore { .await .map_err(HummockError::foyer_error)?; - let block_cache_v2 = HybridCacheBuilder::new() + let block_cache = HybridCacheBuilder::new() .memory(block_cache_capacity) .with_shards(1) .with_weighter(|_: &SstableBlockIndex, value: &Box| { @@ -206,8 +206,8 @@ impl SstableStore { max_prefetch_block_number: 16, /* compactor won't use this parameter, so just assign a default value. */ recent_filter: None, - meta_cache_v2, - block_cache_v2, + meta_cache, + block_cache, }) } @@ -215,7 +215,7 @@ impl SstableStore { self.store .delete(self.get_sst_data_path(object_id).as_str()) .await?; - self.meta_cache_v2.remove(&object_id); + self.meta_cache.remove(&object_id); // TODO(MrCroxx): support group remove in foyer. Ok(()) } @@ -235,14 +235,14 @@ impl SstableStore { // Delete from cache. for object_id in object_id_list { - self.meta_cache_v2.remove(object_id); + self.meta_cache.remove(object_id); } Ok(()) } pub fn delete_cache(&self, object_id: HummockSstableObjectId) -> HummockResult<()> { - self.meta_cache_v2.remove(&object_id); + self.meta_cache.remove(&object_id); Ok(()) } @@ -277,7 +277,7 @@ impl SstableStore { } stats.cache_data_block_total += 1; if let Some(entry) = self - .block_cache_v2 + .block_cache .get(&SstableBlockIndex { sst_id: object_id, block_idx: block_index as _, @@ -298,7 +298,7 @@ impl SstableStore { let mut min_hit_index = end_index; let mut hit_count = 0; for idx in block_index..end_index { - if self.block_cache_v2.contains(&SstableBlockIndex { + if self.block_cache.contains(&SstableBlockIndex { sst_id: object_id, block_idx: idx as _, }) { @@ -366,7 +366,7 @@ impl SstableStore { } else { CacheContext::LowPriority }; - let entry = self.block_cache_v2.insert_with_context( + let entry = self.block_cache.insert_with_context( SstableBlockIndex { sst_id: object_id, block_idx: idx as _, @@ -450,7 +450,7 @@ impl SstableStore { match policy { CachePolicy::Fill(context) => { - let entry = self.block_cache_v2.fetch( + let entry = self.block_cache.fetch( SstableBlockIndex { sst_id: object_id, block_idx: block_index as _, @@ -464,7 +464,7 @@ impl SstableStore { } CachePolicy::NotFill => { if let Some(entry) = self - .block_cache_v2 + .block_cache .get(&SstableBlockIndex { sst_id: object_id, block_idx: block_index as _, @@ -530,7 +530,7 @@ impl SstableStore { #[cfg(any(test, feature = "test"))] pub async fn clear_block_cache(&self) -> HummockResult<()> { - self.block_cache_v2 + self.block_cache .clear() .await .map_err(HummockError::foyer_error) @@ -538,7 +538,7 @@ impl SstableStore { #[cfg(any(test, feature = "test"))] pub async fn clear_meta_cache(&self) -> HummockResult<()> { - self.meta_cache_v2 + self.meta_cache .clear() .await .map_err(HummockError::foyer_error) @@ -548,7 +548,7 @@ impl SstableStore { &self, sst_obj_id: HummockSstableObjectId, ) -> HummockResult>>> { - self.meta_cache_v2 + self.meta_cache .get(&sst_obj_id) .await .map_err(HummockError::foyer_error) @@ -562,7 +562,7 @@ impl SstableStore { ) -> impl Future> + Send + 'static { let object_id = sst.get_object_id(); - let entry = self.meta_cache_v2.fetch(object_id, || { + let entry = self.meta_cache.fetch(object_id, || { let store = self.store.clone(); let meta_path = self.get_sst_data_path(object_id); let stats_ptr = stats.remote_io_time.clone(); @@ -609,7 +609,7 @@ impl SstableStore { pub fn insert_meta_cache(&self, object_id: HummockSstableObjectId, meta: SstableMeta) { let sst = Sstable::new(object_id, meta); - self.meta_cache_v2.insert(object_id, Box::new(sst)); + self.meta_cache.insert(object_id, Box::new(sst)); } pub fn insert_block_cache( @@ -618,7 +618,7 @@ impl SstableStore { block_index: u64, block: Box, ) { - self.block_cache_v2.insert( + self.block_cache.insert( SstableBlockIndex { sst_id: object_id, block_idx: block_index, @@ -628,7 +628,7 @@ impl SstableStore { } pub fn get_meta_memory_usage(&self) -> u64 { - self.meta_cache_v2.memory().usage() as _ + self.meta_cache.memory().usage() as _ } pub fn get_prefetch_memory_usage(&self) -> usize { @@ -670,11 +670,11 @@ impl SstableStore { } pub fn meta_cache(&self) -> &HybridCache> { - &self.meta_cache_v2 + &self.meta_cache } pub fn block_cache(&self) -> &HybridCache> { - &self.block_cache_v2 + &self.block_cache } } @@ -706,7 +706,7 @@ impl MemoryCollector for HummockMemoryCollector { } fn get_data_memory_usage(&self) -> u64 { - self.sstable_store.block_cache_v2.memory().usage() as _ + self.sstable_store.block_cache.memory().usage() as _ } fn get_uploading_memory_usage(&self) -> u64 { @@ -869,7 +869,7 @@ impl SstableWriter for BatchUploadWriter { // The `block_info` may be empty when there is only range-tombstones, because we // store them in meta-block. for (block_idx, block) in self.block_info.into_iter().enumerate() { - self.sstable_store.block_cache_v2.insert_with_context( + self.sstable_store.block_cache.insert_with_context( SstableBlockIndex { sst_id: self.object_id, block_idx: block_idx as _, @@ -980,7 +980,7 @@ impl SstableWriter for StreamingUploadWriter { && !self.blocks.is_empty() { for (block_idx, block) in self.blocks.into_iter().enumerate() { - self.sstable_store.block_cache_v2.insert_with_context( + self.sstable_store.block_cache.insert_with_context( SstableBlockIndex { sst_id: self.object_id, block_idx: block_idx as _, diff --git a/src/storage/src/store_impl.rs b/src/storage/src/store_impl.rs index f0aace0e1247..fdecccc85893 100644 --- a/src/storage/src/store_impl.rs +++ b/src/storage/src/store_impl.rs @@ -626,7 +626,7 @@ impl StateStoreImpl { .build_and_install(); } - let meta_cache_v2 = { + let meta_cache = { let mut builder = HybridCacheBuilder::new() .with_name("foyer.meta") .memory(opts.meta_cache_capacity_mb * MB) @@ -674,7 +674,7 @@ impl StateStoreImpl { builder.build().await.map_err(HummockError::foyer_error)? }; - let block_cache_v2 = { + let block_cache = { let mut builder = HybridCacheBuilder::new() .with_name("foyer.data") .with_event_listener(Arc::new(BlockCacheEventListener::new( @@ -753,8 +753,8 @@ impl StateStoreImpl { recent_filter, state_store_metrics: state_store_metrics.clone(), - meta_cache_v2, - block_cache_v2, + meta_cache, + block_cache, })); let notification_client = RpcNotificationClient::new(hummock_meta_client.get_inner().clone()); diff --git a/src/tests/compaction_test/src/delete_range_runner.rs b/src/tests/compaction_test/src/delete_range_runner.rs index 58e9fde74c48..7183ee7e2e85 100644 --- a/src/tests/compaction_test/src/delete_range_runner.rs +++ b/src/tests/compaction_test/src/delete_range_runner.rs @@ -208,13 +208,13 @@ async fn compaction_test( Arc::new(ObjectStoreConfig::default()), ) .await; - let meta_cache_v2 = HybridCacheBuilder::new() + let meta_cache = HybridCacheBuilder::new() .memory(storage_memory_config.meta_cache_capacity_mb * (1 << 20)) .with_shards(storage_memory_config.meta_cache_shard_num) .storage() .build() .await?; - let block_cache_v2 = HybridCacheBuilder::new() + let block_cache = HybridCacheBuilder::new() .memory(storage_memory_config.block_cache_capacity_mb * (1 << 20)) .with_shards(storage_memory_config.block_cache_shard_num) .storage() @@ -227,8 +227,8 @@ async fn compaction_test( max_prefetch_block_number: storage_opts.max_prefetch_block_number, recent_filter: None, state_store_metrics: state_store_metrics.clone(), - meta_cache_v2, - block_cache_v2, + meta_cache, + block_cache, })); let store = HummockStorage::new(