mirror of
https://github.com/lancedb/lancedb.git
synced 2025-12-26 22:59:57 +00:00
In addition, there are also a number of changes in nodejs to the docstrings of existing methods because this PR adds a jsdoc linter.
14 lines
487 B
Rust
14 lines
487 B
Rust
use lancedb::DistanceType;
|
|
|
|
pub fn parse_distance_type(distance_type: impl AsRef<str>) -> napi::Result<DistanceType> {
|
|
match distance_type.as_ref().to_lowercase().as_str() {
|
|
"l2" => Ok(DistanceType::L2),
|
|
"cosine" => Ok(DistanceType::Cosine),
|
|
"dot" => Ok(DistanceType::Dot),
|
|
_ => Err(napi::Error::from_reason(format!(
|
|
"Invalid distance type '{}'. Must be one of l2, cosine, or dot",
|
|
distance_type.as_ref()
|
|
))),
|
|
}
|
|
}
|