mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-14 12:00:40 +00:00
refactor(sst): extract index version check into method
Signed-off-by: discord9 <discord9@163.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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!(
|
||||
|
||||
Reference in New Issue
Block a user