1818#include " IndexSVSImplDefs.h"
1919
2020#include < cstddef>
21- #include < istream>
22- #include < memory>
23- #include < numeric>
24- #include < ostream>
25- #include < vector>
2621
2722namespace svs {
2823namespace runtime {
2924
3025// Abstract interface for Vamana-based indexes.
26+ // NOTE VamanaIndex is not implemented directly, only DynamicVamanaIndex is implemented.
3127struct SVS_RUNTIME_API VamanaIndex {
32- enum StorageKind {
33- FP32, FP16, SQI8,
34- LVQ4x0, LVQ4x4, LVQ4x8,
35- LeanVec4x4, LeanVec4x8, LeanVec8x8,
36- };
28+ virtual ~VamanaIndex () = 0 ;
3729
38- // TODO:
39- // 1. Should StorageKind, metric, be a part of BuildParams?
40- // 2. Does it make sense to have "Common" BuildParams{dim, metric} struct for other index algos (Flat, IVF)?
41- // Or dim, metric, storage kind should be passed separately to the build() method?
42- // What about storage kind in Flat, IVF?
4330 struct BuildParams {
44- size_t dim;
4531 size_t graph_max_degree;
4632 size_t prune_to = 0 ;
4733 float alpha = 0 ;
@@ -51,21 +37,12 @@ struct SVS_RUNTIME_API VamanaIndex {
5137 };
5238
5339 struct SearchParams {
54- size_t search_window_size = 0 ;
55- size_t search_buffer_capacity = 0 ;
40+ size_t search_window_size = 10 ;
41+ size_t search_buffer_capacity = 10 ;
42+ size_t prefetch_lookahead = 0 ;
43+ size_t prefetch_step = 0 ;
5644 };
5745
58- // Unused for now:
59- virtual size_t size () const noexcept = 0;
60- virtual size_t dimensions () const noexcept = 0;
61- virtual MetricType metric_type () const noexcept = 0;
62- virtual StorageKind get_storage_kind () const noexcept = 0;
63-
64- virtual Status add (size_t n, const size_t * labels, const float * x) noexcept = 0;
65- virtual Status remove_selected (size_t * num_removed, const IDFilter& selector) noexcept = 0;
66- // Further method for deletion can be added later:
67- // virtual Status remove(size_t n, const size_t* labels) noexcept = 0;
68-
6946 virtual Status search (
7047 size_t n,
7148 const float * x,
@@ -84,48 +61,6 @@ struct SVS_RUNTIME_API VamanaIndex {
8461 const SearchParams* params = nullptr ,
8562 IDFilter* filter = nullptr
8663 ) const noexcept = 0;
87-
88- virtual Status reset () noexcept = 0;
89- // TODO: Does it make sense to rename it to "save()"?
90- virtual Status serialize (std::ostream& out) const noexcept = 0;
91-
92- // Static constructors and destructors
93- static Status build (
94- VamanaIndex** index,
95- MetricType metric,
96- StorageKind storage_kind,
97- const VamanaIndex::BuildParams& params,
98- const VamanaIndex::SearchParams& default_search_params = {10 ,10 }
99- ) noexcept ;
100-
101- static Status destroy (VamanaIndex* index) noexcept ;
102- // TODO: Does it make sense to rename it to "load()"?
103- // TODO: is it possible to get metric and storage kind from the stream instead of passing them explicitly?
104- static Status deserialize (VamanaIndex** index, std::istream& in, MetricType metric, VamanaIndex::StorageKind storage_kind) noexcept ;
105- };
106-
107- struct SVS_RUNTIME_API VamanaIndexLeanVecFactory {
108- static Status train (
109- VamanaIndexLeanVecFactory** factory,
110- size_t d,
111- size_t n,
112- const float * x,
113- size_t leanvec_dims
114- ) noexcept ;
115-
116- static Status destroy (VamanaIndexLeanVecFactory* factory) noexcept ;
117-
118- virtual Status serialize (std::ostream& out) const noexcept ;
119- static Status deserialize (VamanaIndexLeanVecFactory** factory, std::istream& in) noexcept ;
120-
121- virtual Status buildIndex (
122- VamanaIndex** index,
123- size_t dim,
124- MetricType metric,
125- const VamanaIndex::BuildParams& params,
126- const VamanaIndex::SearchParams& default_search_params = {}
127- ) noexcept ;
12864};
129-
13065} // namespace runtime
13166} // namespace svs
0 commit comments