Closed weedge closed 11 months ago
Hey, @weedge! We generally avoid dependencies in the higher-level bindings. It seems like it makes more sense to use it outside of the binding rather than inside. What's your opinion on that?
hi~! @ashvardanian use it outside of the binding, like this. ( it's ok, but have a little couple together;maybe there other good ways. )
#[derive(Serialize, Deserialize, Debug, PartialEq)]
enum MKind {
IP,
L2sq,
Cos,
Pearson,
Haversine,
Hamming,
Tanimoto,
Sorensen,
}
impl MKind {
fn map_metric_kind(&self) -> MetricKind {
match self {
Self::IP => MetricKind::IP,
Self::L2sq => MetricKind::L2sq,
Self::Cos => MetricKind::Cos,
Self::Pearson => MetricKind::Pearson,
Self::Haversine => MetricKind::Haversine,
Self::Hamming => MetricKind::Hamming,
Self::Tanimoto => MetricKind::Tanimoto,
Self::Sorensen => MetricKind::Sorensen,
}
}
}
#[derive(Serialize, Deserialize, Debug, PartialEq)]
enum SKind {
F64,
F32,
F16,
I8,
B1,
}
impl SKind {
fn map_scalar_kind(&self) -> ScalarKind {
match self {
Self::F64 => ScalarKind::F64,
Self::F32 => ScalarKind::F32,
Self::F16 => ScalarKind::F16,
Self::I8 => ScalarKind::I8,
Self::B1 => ScalarKind::B1,
}
}
}
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct IndexOpts {
dimensions: usize,
metric: MKind,
quantization: SKind,
connectivity: usize,
expansion_add: usize,
expansion_search: usize,
multi: bool,
}
if enum MetricKind and ScalarKind change (add new one) , then update usearch crate package version, need to change this map_* fn and enum MKind and Scand.
If this can be done externally, let's keep it that way.
@weedge, thank you for your effort! Are you, by any chance, on our Discord? If you let me know beforehand, which features you are looking to implement, we can probably schedule it more effectively 🤗
@ashvardanian thanks, it's my pleasure, how to find it on Discord? my Discord ID: weedge
There is an invite link in the README.md.
add serde Serialize/Deserialize for IndexOptions, in order to config index opts