refactor(sst): extract index version check into method

Signed-off-by: discord9 <discord9@163.com>
This commit is contained in:
discord9
2025-12-11 11:17:44 +08:00
parent f2f56a463a
commit 44e81bd767
2 changed files with 7 additions and 4 deletions

View File

@@ -306,6 +306,11 @@ impl FileMeta {
!self.available_indexes.is_empty()
}
/// Whether the index file is up-to-date comparing to another file meta.
pub fn is_index_up_to_date(&self, other: &FileMeta) -> bool {
self.exists_index() && other.exists_index() && self.index_version >= other.index_version
}
/// Returns true if the file has an inverted index
pub fn inverted_index_available(&self) -> bool {
self.available_indexes.contains(&IndexType::InvertedIndex)

View File

@@ -63,10 +63,8 @@ impl SstVersion {
.files
.entry(file.file_id)
.and_modify(|f| {
let is_same = *f.meta_ref() == file;
let is_index_up_to_date = f.meta_ref().exists_index() && file.exists_index() && f.index_id().version >= new_index_version;
if is_same || is_index_up_to_date {
// current file handle's index is up-to-date, skip adding
if *f.meta_ref() == file || f.meta_ref().is_index_up_to_date(&file) {
// same file meta or current file handle's index is up-to-date, skip adding
if f.index_id().version > new_index_version {
// what does it mean for us to see older index version?
common_telemetry::warn!(