Skip to content

Commit f14a835

Browse files
authored
fix: change IO related rust unwrap to ? [2.6] (milvus-io#48454)
pr: milvus-io#48333 issue: milvus-io#48320 Signed-off-by: SpadeA <tangchenjie1210@gmail.com>
1 parent 6800b08 commit f14a835

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

internal/core/thirdparty/tantivy/tantivy-binding/src/index_ngram_writer.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ impl IndexWriterWrapper {
4545

4646
let (schema, field) = build_ngram_schema(field_name);
4747

48-
let index = Index::create_in_dir(path, schema).unwrap();
48+
let index = Index::create_in_dir(path, schema)?;
4949
index.tokenizers().register(NGRAM_TOKENIZER, tokenizer);
50-
let index_writer = index
51-
.writer_with_num_threads(num_threads, overall_memory_budget_in_bytes)
52-
.unwrap();
50+
let index_writer =
51+
index.writer_with_num_threads(num_threads, overall_memory_budget_in_bytes)?;
5352

5453
Ok(IndexWriterWrapper::V7(IndexWriterWrapperImpl {
5554
field,

internal/core/thirdparty/tantivy/tantivy-binding/src/index_writer_v5/index_writer_text.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ impl IndexWriterWrapperImpl {
4343
let index = if in_ram {
4444
Index::create_in_ram(schema)
4545
} else {
46-
Index::create_in_dir(path, schema).unwrap()
46+
Index::create_in_dir(path, schema)?
4747
};
4848
index.tokenizers().register(tokenizer_name, tokenizer);
49-
let index_writer = index
50-
.writer_with_num_threads(num_threads, overall_memory_budget_in_bytes)
51-
.unwrap();
49+
let index_writer =
50+
index.writer_with_num_threads(num_threads, overall_memory_budget_in_bytes)?;
5251

5352
Ok(IndexWriterWrapperImpl {
5453
field,

internal/core/thirdparty/tantivy/tantivy-binding/src/index_writer_v7/index_writer_text.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ impl IndexWriterWrapperImpl {
4343
let index = if in_ram {
4444
Index::create_in_ram(schema)
4545
} else {
46-
Index::create_in_dir(path, schema).unwrap()
46+
Index::create_in_dir(path, schema)?
4747
};
4848
index.tokenizers().register(tokenizer_name, tokenizer);
49-
let index_writer = index
50-
.writer_with_num_threads(num_threads, overall_memory_budget_in_bytes)
51-
.unwrap();
49+
let index_writer =
50+
index.writer_with_num_threads(num_threads, overall_memory_budget_in_bytes)?;
5251

5352
Ok(IndexWriterWrapperImpl {
5453
field,

internal/core/thirdparty/tantivy/tantivy-binding/src/util.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use crate::error::Result;
2+
use crate::log::init_log;
23
use core::slice;
4+
use log::info;
35
use std::collections::HashSet;
46
use std::ffi::CStr;
57
use std::ffi::{c_char, c_void};
@@ -15,7 +17,7 @@ pub fn index_exist(path: &str) -> bool {
1517
let Ok(dir) = MmapDirectory::open(path) else {
1618
return false;
1719
};
18-
Index::exists(&dir).unwrap()
20+
Index::exists(&dir).unwrap_or(false)
1921
}
2022

2123
pub fn make_bounds<T>(bound: T, inclusive: bool) -> Bound<T> {

0 commit comments

Comments
 (0)