fix: change IO related rust unwrap to ? (#48333)

issue: https://github.com/milvus-io/milvus/issues/48320

---------

Signed-off-by: SpadeA <tangchenjie1210@gmail.com>
This commit is contained in:
Spade A
2026-03-23 17:55:28 +08:00
committed by GitHub
parent c54b34a880
commit 786bb24288
4 changed files with 10 additions and 13 deletions
@@ -45,11 +45,10 @@ impl IndexWriterWrapper {
let (schema, field) = build_ngram_schema(field_name);
let index = Index::create_in_dir(path, schema).unwrap();
let index = Index::create_in_dir(path, schema)?;
index.tokenizers().register(NGRAM_TOKENIZER, tokenizer);
let index_writer = index
.writer_with_num_threads(num_threads, overall_memory_budget_in_bytes)
.unwrap();
let index_writer =
index.writer_with_num_threads(num_threads, overall_memory_budget_in_bytes)?;
Ok(IndexWriterWrapper::V7(IndexWriterWrapperImpl {
field,
@@ -43,12 +43,11 @@ impl IndexWriterWrapperImpl {
let index = if in_ram {
Index::create_in_ram(schema)
} else {
Index::create_in_dir(path, schema).unwrap()
Index::create_in_dir(path, schema)?
};
index.tokenizers().register(tokenizer_name, tokenizer);
let index_writer = index
.writer_with_num_threads(num_threads, overall_memory_budget_in_bytes)
.unwrap();
let index_writer =
index.writer_with_num_threads(num_threads, overall_memory_budget_in_bytes)?;
Ok(IndexWriterWrapperImpl {
field,
@@ -44,12 +44,11 @@ impl IndexWriterWrapperImpl {
let index = if in_ram {
Index::create_in_ram(schema)
} else {
Index::create_in_dir(path, schema).unwrap()
Index::create_in_dir(path, schema)?
};
index.tokenizers().register(analyzer_name, analyzer);
let index_writer = index
.writer_with_num_threads(num_threads, overall_memory_budget_in_bytes)
.unwrap();
let index_writer =
index.writer_with_num_threads(num_threads, overall_memory_budget_in_bytes)?;
Ok(IndexWriterWrapperImpl {
field,
@@ -22,7 +22,7 @@ pub fn index_exist(path: &str) -> bool {
);
return false;
};
let exists = Index::exists(&dir).unwrap();
let exists = Index::exists(&dir).unwrap_or(false);
if !exists {
init_log();
let files: Vec<_> = std::fs::read_dir(path)