diff --git a/src/storage/src/hummock/sstable/builder.rs b/src/storage/src/hummock/sstable/builder.rs index f9c747c154e84..cac05a889f8ef 100644 --- a/src/storage/src/hummock/sstable/builder.rs +++ b/src/storage/src/hummock/sstable/builder.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::{BTreeMap, BTreeSet, HashMap}; +use std::collections::{BTreeMap, BTreeSet}; use std::sync::Arc; use bytes::BytesMut; @@ -101,7 +101,7 @@ pub struct SstableBuilder { /// `table_id` of added keys. table_ids: BTreeSet, /// Hashes of user keys. - user_key_hashes: HashMap>, + user_key_hashes: BTreeMap>, last_full_key: Vec, last_extract_key: Vec, /// Buffer for encoded key and value to avoid allocation. @@ -149,7 +149,7 @@ impl SstableBuilder { }), block_metas: Vec::with_capacity(options.capacity / options.block_capacity + 1), table_ids: BTreeSet::new(), - user_key_hashes: HashMap::new(), + user_key_hashes: BTreeMap::new(), last_table_id: None, raw_key: BytesMut::new(), raw_value: BytesMut::new(), diff --git a/src/storage/src/hummock/state_store_v1.rs b/src/storage/src/hummock/state_store_v1.rs index e31144ba163ba..362dc603e282b 100644 --- a/src/storage/src/hummock/state_store_v1.rs +++ b/src/storage/src/hummock/state_store_v1.rs @@ -336,16 +336,14 @@ impl HummockStorageV1 { .sstable(sstable_info, &mut local_stats) .in_span(Span::enter_with_local_parent("get_sstable")) .await?; - for table_id in &sstable_info.table_ids { - if hit_sstable_bloom_filter( - sstable.value(), - *prefix_hash, - &mut local_stats, - *table_id, - ) { - sstables.push((*sstable_info).clone()); - break; - } + + if hit_sstable_bloom_filter( + sstable.value(), + *prefix_hash, + &mut local_stats, + table_id.table_id(), + ) { + sstables.push((*sstable_info).clone()); } } else { sstables.push((*sstable_info).clone()); diff --git a/src/storage/src/hummock/store/version.rs b/src/storage/src/hummock/store/version.rs index 534d9d09d26f6..30eccb44f0892 100644 --- a/src/storage/src/hummock/store/version.rs +++ b/src/storage/src/hummock/store/version.rs @@ -546,30 +546,24 @@ impl HummockVersionReader { .prefix_hint .as_ref() .map(|hint| Sstable::hash_for_bloom_filter(hint)); - + let table_id = read_options.table_id.table_id(); for sstable_info in &uncommitted_ssts { let table_holder = self .sstable_store .sstable(sstable_info, &mut local_stats) .in_span(Span::enter_with_local_parent("get_sstable")) .await?; - let mut hit_bloom_filter = false; - for table_id in &sstable_info.table_ids { - if let Some(prefix_hash) = bloom_filter_prefix_hash.as_ref() { - if !hit_sstable_bloom_filter( - table_holder.value(), - *prefix_hash, - &mut local_stats, - *table_id, - ) { - hit_bloom_filter = true; - break; - } + + if let Some(prefix_hash) = bloom_filter_prefix_hash.as_ref() { + if !hit_sstable_bloom_filter( + table_holder.value(), + *prefix_hash, + &mut local_stats, + table_id, + ) { + continue; } } - if hit_bloom_filter { - continue; - } if !table_holder.value().meta.range_tombstone_list.is_empty() && !read_options.ignore_range_tombstone @@ -636,23 +630,17 @@ impl HummockVersionReader { .in_span(Span::enter_with_local_parent("get_sstable")) .await?; - let mut hit_bloom_filter = false; - for table_id in &sstable_info.table_ids { - if let Some(prefix_hash) = bloom_filter_prefix_hash.as_ref() { - if !hit_sstable_bloom_filter( - sstable.value(), - *prefix_hash, - &mut local_stats, - *table_id, - ) { - hit_bloom_filter = true; - break; - } + if let Some(prefix_hash) = bloom_filter_prefix_hash.as_ref() { + if !hit_sstable_bloom_filter( + sstable.value(), + *prefix_hash, + &mut local_stats, + table_id, + ) { + continue; } } - if hit_bloom_filter { - continue; - } + if !sstable.value().meta.range_tombstone_list.is_empty() && !read_options.ignore_range_tombstone {