mito2/sst/index/indexer/
update.rsuse common_telemetry::warn;
use crate::read::Batch;
use crate::sst::index::Indexer;
impl Indexer {
pub(crate) async fn do_update(&mut self, batch: &mut Batch) {
if batch.is_empty() {
return;
}
if !self.do_update_inverted_index(batch).await {
self.do_abort().await;
}
if !self.do_update_fulltext_index(batch).await {
self.do_abort().await;
}
if !self.do_update_bloom_filter(batch).await {
self.do_abort().await;
}
}
async fn do_update_inverted_index(&mut self, batch: &mut Batch) -> bool {
let Some(creator) = self.inverted_indexer.as_mut() else {
return true;
};
let Err(err) = creator.update(batch).await else {
return true;
};
if cfg!(any(test, feature = "test")) {
panic!(
"Failed to update inverted index, region_id: {}, file_id: {}, err: {:?}",
self.region_id, self.file_id, err
);
} else {
warn!(
err; "Failed to update inverted index, region_id: {}, file_id: {}",
self.region_id, self.file_id,
);
}
false
}
async fn do_update_fulltext_index(&mut self, batch: &mut Batch) -> bool {
let Some(creator) = self.fulltext_indexer.as_mut() else {
return true;
};
let Err(err) = creator.update(batch).await else {
return true;
};
if cfg!(any(test, feature = "test")) {
panic!(
"Failed to update full-text index, region_id: {}, file_id: {}, err: {:?}",
self.region_id, self.file_id, err
);
} else {
warn!(
err; "Failed to update full-text index, region_id: {}, file_id: {}",
self.region_id, self.file_id,
);
}
false
}
async fn do_update_bloom_filter(&mut self, batch: &mut Batch) -> bool {
let Some(creator) = self.bloom_filter_indexer.as_mut() else {
return true;
};
let Err(err) = creator.update(batch).await else {
return true;
};
if cfg!(any(test, feature = "test")) {
panic!(
"Failed to update bloom filter, region_id: {}, file_id: {}, err: {:?}",
self.region_id, self.file_id, err
);
} else {
warn!(
err; "Failed to update bloom filter, region_id: {}, file_id: {}",
self.region_id, self.file_id,
);
}
false
}
}