mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
Replace the ugly unwraps by clean if let Somes
This commit is contained in:
parent
8d26f3040c
commit
d5b8b5a2f8
@ -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,18 +424,20 @@ where
|
|||||||
total_databases: TOTAL_POSTING_DATABASE_COUNT,
|
total_databases: TOTAL_POSTING_DATABASE_COUNT,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Run the word prefix docids update operation.
|
if let Some(word_docids) = word_docids {
|
||||||
let mut builder = WordPrefixDocids::new(self.wtxn, self.index);
|
// Run the word prefix docids update operation.
|
||||||
builder.chunk_compression_type = self.indexer_config.chunk_compression_type;
|
let mut builder = WordPrefixDocids::new(self.wtxn, self.index);
|
||||||
builder.chunk_compression_level = self.indexer_config.chunk_compression_level;
|
builder.chunk_compression_type = self.indexer_config.chunk_compression_type;
|
||||||
builder.max_nb_chunks = self.indexer_config.max_nb_chunks;
|
builder.chunk_compression_level = self.indexer_config.chunk_compression_level;
|
||||||
builder.max_memory = self.indexer_config.max_memory;
|
builder.max_nb_chunks = self.indexer_config.max_nb_chunks;
|
||||||
builder.execute(
|
builder.max_memory = self.indexer_config.max_memory;
|
||||||
word_docids,
|
builder.execute(
|
||||||
&new_prefix_fst_words,
|
word_docids,
|
||||||
&common_prefix_fst_words,
|
&new_prefix_fst_words,
|
||||||
&del_prefix_fst_words,
|
&common_prefix_fst_words,
|
||||||
)?;
|
&del_prefix_fst_words,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
databases_seen += 1;
|
databases_seen += 1;
|
||||||
(self.progress)(UpdateIndexingStep::MergeDataIntoFinalDatabase {
|
(self.progress)(UpdateIndexingStep::MergeDataIntoFinalDatabase {
|
||||||
@ -443,18 +445,20 @@ where
|
|||||||
total_databases: TOTAL_POSTING_DATABASE_COUNT,
|
total_databases: TOTAL_POSTING_DATABASE_COUNT,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Run the word prefix pair proximity docids update operation.
|
if let Some(word_pair_proximity_docids) = word_pair_proximity_docids {
|
||||||
let mut builder = WordPrefixPairProximityDocids::new(self.wtxn, self.index);
|
// Run the word prefix pair proximity docids update operation.
|
||||||
builder.chunk_compression_type = self.indexer_config.chunk_compression_type;
|
let mut builder = WordPrefixPairProximityDocids::new(self.wtxn, self.index);
|
||||||
builder.chunk_compression_level = self.indexer_config.chunk_compression_level;
|
builder.chunk_compression_type = self.indexer_config.chunk_compression_type;
|
||||||
builder.max_nb_chunks = self.indexer_config.max_nb_chunks;
|
builder.chunk_compression_level = self.indexer_config.chunk_compression_level;
|
||||||
builder.max_memory = self.indexer_config.max_memory;
|
builder.max_nb_chunks = self.indexer_config.max_nb_chunks;
|
||||||
builder.execute(
|
builder.max_memory = self.indexer_config.max_memory;
|
||||||
word_pair_proximity_docids,
|
builder.execute(
|
||||||
&new_prefix_fst_words,
|
word_pair_proximity_docids,
|
||||||
&common_prefix_fst_words,
|
&new_prefix_fst_words,
|
||||||
&del_prefix_fst_words,
|
&common_prefix_fst_words,
|
||||||
)?;
|
&del_prefix_fst_words,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
databases_seen += 1;
|
databases_seen += 1;
|
||||||
(self.progress)(UpdateIndexingStep::MergeDataIntoFinalDatabase {
|
(self.progress)(UpdateIndexingStep::MergeDataIntoFinalDatabase {
|
||||||
@ -462,24 +466,26 @@ where
|
|||||||
total_databases: TOTAL_POSTING_DATABASE_COUNT,
|
total_databases: TOTAL_POSTING_DATABASE_COUNT,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Run the words prefix position docids update operation.
|
if let Some(word_position_docids) = word_position_docids {
|
||||||
let mut builder = WordPrefixPositionDocids::new(self.wtxn, self.index);
|
// Run the words prefix position docids update operation.
|
||||||
builder.chunk_compression_type = self.indexer_config.chunk_compression_type;
|
let mut builder = WordPrefixPositionDocids::new(self.wtxn, self.index);
|
||||||
builder.chunk_compression_level = self.indexer_config.chunk_compression_level;
|
builder.chunk_compression_type = self.indexer_config.chunk_compression_type;
|
||||||
builder.max_nb_chunks = self.indexer_config.max_nb_chunks;
|
builder.chunk_compression_level = self.indexer_config.chunk_compression_level;
|
||||||
builder.max_memory = self.indexer_config.max_memory;
|
builder.max_nb_chunks = self.indexer_config.max_nb_chunks;
|
||||||
if let Some(value) = self.config.words_positions_level_group_size {
|
builder.max_memory = self.indexer_config.max_memory;
|
||||||
builder.level_group_size(value);
|
if let Some(value) = self.config.words_positions_level_group_size {
|
||||||
|
builder.level_group_size(value);
|
||||||
|
}
|
||||||
|
if let Some(value) = self.config.words_positions_min_level_size {
|
||||||
|
builder.min_level_size(value);
|
||||||
|
}
|
||||||
|
builder.execute(
|
||||||
|
word_position_docids,
|
||||||
|
&new_prefix_fst_words,
|
||||||
|
&common_prefix_fst_words,
|
||||||
|
&del_prefix_fst_words,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
if let Some(value) = self.config.words_positions_min_level_size {
|
|
||||||
builder.min_level_size(value);
|
|
||||||
}
|
|
||||||
builder.execute(
|
|
||||||
word_position_docids,
|
|
||||||
&new_prefix_fst_words,
|
|
||||||
&common_prefix_fst_words,
|
|
||||||
&del_prefix_fst_words,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
databases_seen += 1;
|
databases_seen += 1;
|
||||||
(self.progress)(UpdateIndexingStep::MergeDataIntoFinalDatabase {
|
(self.progress)(UpdateIndexingStep::MergeDataIntoFinalDatabase {
|
||||||
|
Loading…
Reference in New Issue
Block a user