Skip to content

Commit

Permalink
chore: expose utils for infering vector dim and element type
Browse files Browse the repository at this point in the history
Signed-off-by: BubbleCal <[email protected]>
  • Loading branch information
BubbleCal committed Jan 15, 2025
1 parent b572905 commit 644ddef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rust/lance/src/index/vector/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ pub fn get_vector_dim(schema: &Schema, column: &str) -> Result<usize> {
infer_vector_dim(&field.data_type())
}

fn infer_vector_dim(data_type: &arrow::datatypes::DataType) -> Result<usize> {
pub fn infer_vector_dim(data_type: &arrow::datatypes::DataType) -> Result<usize> {
match data_type {
arrow::datatypes::DataType::FixedSizeList(_, dim) => Ok(*dim as usize),
arrow::datatypes::DataType::List(inner) => infer_vector_dim(inner.data_type()),
_ => Err(Error::Index {
message: format!("Data type is not a FixedSizeListArray, but {:?}", data_type),
message: format!("Data type is not a vector (FixedSizeListArray or List<FixedSizeListArray>), but {:?}", data_type),
location: location!(),
}),
}
Expand All @@ -48,7 +48,7 @@ pub fn get_vector_type(
))
}

fn infer_vector_element_type(
pub fn infer_vector_element_type(
data_type: &arrow::datatypes::DataType,
) -> Result<arrow_schema::DataType> {
match data_type {
Expand Down

0 comments on commit 644ddef

Please sign in to comment.