Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
wcy-fdu committed Jan 5, 2023
1 parent 7533110 commit ad1fc49
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 44 deletions.
6 changes: 3 additions & 3 deletions src/storage/src/hummock/sstable/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -101,7 +101,7 @@ pub struct SstableBuilder<W: SstableWriter> {
/// `table_id` of added keys.
table_ids: BTreeSet<u32>,
/// Hashes of user keys.
user_key_hashes: HashMap<u32, Vec<u32>>,
user_key_hashes: BTreeMap<u32, Vec<u32>>,
last_full_key: Vec<u8>,
last_extract_key: Vec<u8>,
/// Buffer for encoded key and value to avoid allocation.
Expand Down Expand Up @@ -149,7 +149,7 @@ impl<W: SstableWriter> SstableBuilder<W> {
}),
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(),
Expand Down
18 changes: 8 additions & 10 deletions src/storage/src/hummock/state_store_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
50 changes: 19 additions & 31 deletions src/storage/src/hummock/store/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit ad1fc49

Please sign in to comment.