Replace the ugly unwraps by clean if let Somes

This commit is contained in:
Kerollmops 2022-02-28 16:00:33 +01:00
parent 8d26f3040c
commit d5b8b5a2f8
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -345,9 +345,9 @@ where
self.index.put_documents_ids(self.wtxn, &all_documents_ids)?; self.index.put_documents_ids(self.wtxn, &all_documents_ids)?;
self.execute_prefix_databases( self.execute_prefix_databases(
word_docids.unwrap(), word_docids,
word_pair_proximity_docids.unwrap(), word_pair_proximity_docids,
word_position_docids.unwrap(), word_position_docids,
)?; )?;
Ok(all_documents_ids.len()) Ok(all_documents_ids.len())
@ -356,9 +356,9 @@ where
#[logging_timer::time("IndexDocuments::{}")] #[logging_timer::time("IndexDocuments::{}")]
pub fn execute_prefix_databases( pub fn execute_prefix_databases(
self, self,
word_docids: grenad::Reader<CursorClonableMmap>, word_docids: Option<grenad::Reader<CursorClonableMmap>>,
word_pair_proximity_docids: grenad::Reader<CursorClonableMmap>, word_pair_proximity_docids: Option<grenad::Reader<CursorClonableMmap>>,
word_position_docids: grenad::Reader<CursorClonableMmap>, word_position_docids: Option<grenad::Reader<CursorClonableMmap>>,
) -> Result<()> ) -> Result<()>
where where
F: Fn(UpdateIndexingStep) + Sync, F: Fn(UpdateIndexingStep) + Sync,
@ -424,6 +424,7 @@ where
total_databases: TOTAL_POSTING_DATABASE_COUNT, total_databases: TOTAL_POSTING_DATABASE_COUNT,
}); });
if let Some(word_docids) = word_docids {
// Run the word prefix docids update operation. // Run the word prefix docids update operation.
let mut builder = WordPrefixDocids::new(self.wtxn, self.index); let mut builder = WordPrefixDocids::new(self.wtxn, self.index);
builder.chunk_compression_type = self.indexer_config.chunk_compression_type; builder.chunk_compression_type = self.indexer_config.chunk_compression_type;
@ -436,6 +437,7 @@ where
&common_prefix_fst_words, &common_prefix_fst_words,
&del_prefix_fst_words, &del_prefix_fst_words,
)?; )?;
}
databases_seen += 1; databases_seen += 1;
(self.progress)(UpdateIndexingStep::MergeDataIntoFinalDatabase { (self.progress)(UpdateIndexingStep::MergeDataIntoFinalDatabase {
@ -443,6 +445,7 @@ where
total_databases: TOTAL_POSTING_DATABASE_COUNT, total_databases: TOTAL_POSTING_DATABASE_COUNT,
}); });
if let Some(word_pair_proximity_docids) = word_pair_proximity_docids {
// Run the word prefix pair proximity docids update operation. // Run the word prefix pair proximity docids update operation.
let mut builder = WordPrefixPairProximityDocids::new(self.wtxn, self.index); let mut builder = WordPrefixPairProximityDocids::new(self.wtxn, self.index);
builder.chunk_compression_type = self.indexer_config.chunk_compression_type; builder.chunk_compression_type = self.indexer_config.chunk_compression_type;
@ -455,6 +458,7 @@ where
&common_prefix_fst_words, &common_prefix_fst_words,
&del_prefix_fst_words, &del_prefix_fst_words,
)?; )?;
}
databases_seen += 1; databases_seen += 1;
(self.progress)(UpdateIndexingStep::MergeDataIntoFinalDatabase { (self.progress)(UpdateIndexingStep::MergeDataIntoFinalDatabase {
@ -462,6 +466,7 @@ where
total_databases: TOTAL_POSTING_DATABASE_COUNT, total_databases: TOTAL_POSTING_DATABASE_COUNT,
}); });
if let Some(word_position_docids) = word_position_docids {
// Run the words prefix position docids update operation. // Run the words prefix position docids update operation.
let mut builder = WordPrefixPositionDocids::new(self.wtxn, self.index); let mut builder = WordPrefixPositionDocids::new(self.wtxn, self.index);
builder.chunk_compression_type = self.indexer_config.chunk_compression_type; builder.chunk_compression_type = self.indexer_config.chunk_compression_type;
@ -480,6 +485,7 @@ where
&common_prefix_fst_words, &common_prefix_fst_words,
&del_prefix_fst_words, &del_prefix_fst_words,
)?; )?;
}
databases_seen += 1; databases_seen += 1;
(self.progress)(UpdateIndexingStep::MergeDataIntoFinalDatabase { (self.progress)(UpdateIndexingStep::MergeDataIntoFinalDatabase {