Closed ava57r closed 3 years ago
What if we also had a way to upcast a specific index type back to an IndexImpl
?
let f1 = FlatIndex::new_l2(128);
let f2 = index_factory(128, "Flat", MetricType::L2);
let v: Vec<faiss::IndexImpl> = vec![
f1.upcast(),
f2,
];
What if we also had a way to upcast a specific index type back to an
IndexImpl
?let f1 = FlatIndex::new_l2(128); let f2 = index_factory(128, "Flat", MetricType::L2); let v: Vec<faiss::IndexImpl> = vec![ f1.upcast(), f2, ];
I agree.
Box<dyn faiss::Index>
is Rust idiomatic path.
What if we also had a way to upcast a specific index type back to an
IndexImpl
?let f1 = FlatIndex::new_l2(128); let f2 = index_factory(128, "Flat", MetricType::L2); let v: Vec<faiss::IndexImpl> = vec![ f1.upcast(), f2, ];
Do upcast
in C_API?
Do upcast in C_API?
I don't imagine this to be necessary. The operation is a reinterpret_cast
between two index pointers, which is a no-op and can be done in Rust. Having functions for a downcast was important because then we could dynamic_cast
, which checks at run-time that the target type is acceptable.
For erase type of index.
Rust std. https://doc.rust-lang.org/beta/std/boxed/struct.Box.html#impl-Iterator
For code: