Skip to content

Commit a55c3af

Browse files
authored
chore: change some index errors to invalid input errors (#4999)
1 parent affff28 commit a55c3af

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

rust/lance-index/src/scalar/inverted/index.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ impl PostingListReader {
14011401
}
14021402

14031403
async fn read_positions(&self, token_id: u32) -> Result<ListArray> {
1404-
Ok(self.index_cache.get_or_insert_with_key(PositionKey { token_id }, || async move {
1404+
let positions = self.index_cache.get_or_insert_with_key(PositionKey { token_id }, || async move {
14051405
let batch = self
14061406
.reader
14071407
.read_range(self.posting_list_range(token_id), Some(&[POSITION_COL]))
@@ -1417,9 +1417,8 @@ impl PostingListReader {
14171417
Result::Ok(Positions(batch[POSITION_COL]
14181418
.as_list::<i32>()
14191419
.clone()))
1420-
}).await.map_err(|e| Error::io(e.to_string(), location!()))?.as_ref()
1421-
.clone()
1422-
.0)
1420+
}).await?;
1421+
Ok(positions.0.clone())
14231422
}
14241423

14251424
fn posting_list_range(&self, token_id: u32) -> Range<usize> {

rust/lance/src/index/vector/utils.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ fn infer_vector_dim_impl(data_type: &arrow::datatypes::DataType, in_list: bool)
3535
match (data_type,in_list) {
3636
(arrow::datatypes::DataType::FixedSizeList(_, dim),_) => Ok(*dim as usize),
3737
(arrow::datatypes::DataType::List(inner), false) => infer_vector_dim_impl(inner.data_type(),true),
38-
_ => Err(Error::Index {
39-
message: format!("Data type is not a vector (FixedSizeListArray or List<FixedSizeListArray>), but {:?}", data_type),
40-
location: location!(),
41-
}),
38+
_ => Err(Error::invalid_input(format!("Data type is not a vector (FixedSizeListArray or List<FixedSizeListArray>), but {:?}", data_type), location!()))
4239
}
4340
}
4441

@@ -93,13 +90,13 @@ fn infer_vector_element_type_impl(
9390
(arrow::datatypes::DataType::List(inner), false) => {
9491
infer_vector_element_type_impl(inner.data_type(), true)
9592
}
96-
_ => Err(Error::Index {
97-
message: format!(
98-
"Data type is not a vector (FixedSizeListArray or List<FixedSizeListArray>), but {:?}",
99-
data_type
100-
),
101-
location: location!(),
102-
}),
93+
_ => Err(Error::invalid_input(
94+
format!(
95+
"Data type is not a vector (FixedSizeListArray or List<FixedSizeListArray>), but {:?}",
96+
data_type
97+
),
98+
location!(),
99+
)),
103100
}
104101
}
105102

0 commit comments

Comments
 (0)