diff --git a/src/storage/hummock_sdk/src/key_cmp.rs b/src/storage/hummock_sdk/src/key_cmp.rs index bc18350f9839b..a6b7377170412 100644 --- a/src/storage/hummock_sdk/src/key_cmp.rs +++ b/src/storage/hummock_sdk/src/key_cmp.rs @@ -15,7 +15,7 @@ use std::cmp::{self, Ordering}; use super::key::split_key_epoch; -use crate::key::{FullKey, UserKey}; +use crate::key::UserKey; /// A comparator for comparing [`FullKey`] and [`UserKey`] with possibly different table key types. pub struct KeyComparator; @@ -30,16 +30,6 @@ impl KeyComparator { l_p.cmp(r_p).then_with(|| r_s.cmp(l_s)) } - pub fn compare_full_key_without_table_id( - lhs: FullKey<&[u8]>, - rhs: FullKey<&[u8]>, - ) -> cmp::Ordering { - lhs.user_key - .table_key - .cmp(&rhs.user_key.table_key) - .then_with(|| rhs.epoch.cmp(&lhs.epoch)) - } - /// Used to compare [`UserKey`] and its encoded format. pub fn compare_user_key_cross_format( encoded: impl AsRef<[u8]>, diff --git a/src/storage/src/hummock/compactor/compaction_utils.rs b/src/storage/src/hummock/compactor/compaction_utils.rs index 2ba9420e439c8..da8307896e188 100644 --- a/src/storage/src/hummock/compactor/compaction_utils.rs +++ b/src/storage/src/hummock/compactor/compaction_utils.rs @@ -25,7 +25,7 @@ use risingwave_hummock_sdk::key::FullKey; use risingwave_hummock_sdk::key_range::KeyRange; use risingwave_hummock_sdk::prost_key_range::KeyRangeExt; use risingwave_hummock_sdk::table_stats::TableStatsMap; -use risingwave_hummock_sdk::HummockEpoch; +use risingwave_hummock_sdk::{HummockEpoch, KeyComparator}; use risingwave_pb::hummock::{compact_task, CompactTask, KeyRange as KeyRange_vec, LevelType}; pub use super::context::CompactorContext; @@ -219,7 +219,7 @@ pub async fn generate_splits(compact_task: &mut CompactTask, context: Arc = vec![]; splits.push(KeyRange_vec::new(vec![], vec![])); let parallelism = std::cmp::min( diff --git a/src/storage/src/hummock/compactor/iterator.rs b/src/storage/src/hummock/compactor/iterator.rs index 5826f577d0398..c2447bcd8727a 100644 --- a/src/storage/src/hummock/compactor/iterator.rs +++ b/src/storage/src/hummock/compactor/iterator.rs @@ -20,6 +20,7 @@ use std::time::Instant; use risingwave_hummock_sdk::key::FullKey; use risingwave_hummock_sdk::key_range::KeyRange; +use risingwave_hummock_sdk::KeyComparator; use risingwave_pb::hummock::SstableInfo; use crate::hummock::iterator::{Forward, HummockIterator}; @@ -261,9 +262,10 @@ impl ConcatSstableIterator { block_metas.len() } else { block_metas.partition_point(|block| { - FullKey::decode(&block.smallest_key) - .cmp(&FullKey::decode(&self.key_range.right)) - != Ordering::Greater + KeyComparator::compare_encoded_full_key( + &block.smallest_key, + &self.key_range.right, + ) != Ordering::Greater }) }; if end_index <= start_index { diff --git a/src/storage/src/hummock/sstable/block.rs b/src/storage/src/hummock/sstable/block.rs index 13beb4f2cada0..cdb36807f5a66 100644 --- a/src/storage/src/hummock/sstable/block.rs +++ b/src/storage/src/hummock/sstable/block.rs @@ -450,13 +450,7 @@ impl BlockBuilder { if self.entry_count > 0 { debug_assert!(!key.is_empty()); debug_assert_eq!( - KeyComparator::compare_full_key_without_table_id( - FullKey::from_slice_without_table_id( - TableId::new(input_table_id), - &self.last_key[..] - ), - full_key - ), + KeyComparator::compare_encoded_full_key(&self.last_key[..], &key[..]), Ordering::Less ); }