Skip to content

Commit c52a57f

Browse files
committed
[SVS] Add multi-vector support to the Tiered SVS Index
1 parent 276ac2a commit c52a57f

File tree

6 files changed

+559
-141
lines changed

6 files changed

+559
-141
lines changed

src/VecSim/algorithms/brute_force/brute_force.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class BruteForceIndex : public VecSimIndexAbstract<DataType, DistType> {
7474
// without duplicates in tiered index). Caller should hold the flat buffer lock for read.
7575
virtual vecsim_stl::set<labelType> getLabelsSet() const = 0;
7676

77+
// Unsafe (assume index data guard is held in MT mode).
78+
virtual vecsim_stl::vector<idType> getElementIds(size_t label) const = 0;
79+
7780
virtual ~BruteForceIndex() = default;
7881
#ifdef BUILD_TESTS
7982
void fitMemory() override {

src/VecSim/algorithms/brute_force/brute_force_multi.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ class BruteForceIndex_Multi : public BruteForceIndex<DataType, DistType> {
9595
}
9696
return keys;
9797
};
98-
98+
inline vecsim_stl::vector<idType> getElementIds(size_t label) const override {
99+
auto it = labelToIdsLookup.find(label);
100+
if (it == labelToIdsLookup.end()) {
101+
return vecsim_stl::vector<idType>{this->allocator}; // return an empty collection
102+
}
103+
return it->second;
104+
}
99105
inline vecsim_stl::abstract_priority_queue<DistType, labelType> *
100106
getNewMaxPriorityQueue() const override {
101107
return new (this->allocator)

src/VecSim/algorithms/brute_force/brute_force_single.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,17 @@ class BruteForceIndex_Single : public BruteForceIndex<DataType, DistType> {
9393
keys.insert(it.first);
9494
}
9595
return keys;
96-
};
96+
}
97+
98+
vecsim_stl::vector<idType> getElementIds(size_t label) const override {
99+
vecsim_stl::vector<idType> ids(this->allocator);
100+
auto it = labelToIdLookup.find(label);
101+
if (it == labelToIdLookup.end()) {
102+
return ids;
103+
}
104+
ids.push_back(it->second);
105+
return ids;
106+
}
97107

98108
vecsim_stl::abstract_priority_queue<DistType, labelType> *
99109
getNewMaxPriorityQueue() const override {

0 commit comments

Comments
 (0)