Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/VecSim/algorithms/brute_force/brute_force.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ class BruteForceIndex : public VecSimIndexAbstract<DataType, DistType> {

const RawDataContainer *getVectorsContainer() const { return this->vectors; }

const labelType getLabelByInternalId(idType internal_id) const {
return idToLabelMapping.at(internal_id);
}
// Remove a specific vector that is stored under a label from the index by its internal id.
virtual int deleteVectorById(labelType label, idType id) = 0;
// Remove a vector and return a map between internal ids and the original internal ids of the
Expand All @@ -71,6 +68,9 @@ class BruteForceIndex : public VecSimIndexAbstract<DataType, DistType> {
// Check if a certain label exists in the index.
virtual bool isLabelExists(labelType label) = 0;

// Unsafe (assume index data guard is held in MT mode).
virtual vecsim_stl::vector<idType> getElementIds(size_t label) const = 0;

virtual ~BruteForceIndex() = default;
#ifdef BUILD_TESTS
void fitMemory() override {
Expand Down
10 changes: 9 additions & 1 deletion src/VecSim/algorithms/brute_force/brute_force_multi.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,15 @@
keys.insert(it.first);
}
return keys;
};
}

Check warning on line 97 in src/VecSim/algorithms/brute_force/brute_force_multi.h

View check run for this annotation

Codecov / codecov/patch

src/VecSim/algorithms/brute_force/brute_force_multi.h#L97

Added line #L97 was not covered by tests

inline vecsim_stl::vector<idType> getElementIds(size_t label) const override {
auto it = labelToIdsLookup.find(label);
if (it == labelToIdsLookup.end()) {
return vecsim_stl::vector<idType>{this->allocator}; // return an empty collection

Check warning on line 102 in src/VecSim/algorithms/brute_force/brute_force_multi.h

View check run for this annotation

Codecov / codecov/patch

src/VecSim/algorithms/brute_force/brute_force_multi.h#L102

Added line #L102 was not covered by tests
}
return it->second;
}

inline vecsim_stl::abstract_priority_queue<DistType, labelType> *
getNewMaxPriorityQueue() const override {
Expand Down
11 changes: 10 additions & 1 deletion src/VecSim/algorithms/brute_force/brute_force_single.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,16 @@
keys.insert(it.first);
}
return keys;
};
}

Check warning on line 96 in src/VecSim/algorithms/brute_force/brute_force_single.h

View check run for this annotation

Codecov / codecov/patch

src/VecSim/algorithms/brute_force/brute_force_single.h#L96

Added line #L96 was not covered by tests

vecsim_stl::vector<idType> getElementIds(size_t label) const override {
vecsim_stl::vector<idType> ids(this->allocator);
auto it = labelToIdLookup.find(label);
if (it != labelToIdLookup.end()) {
ids.push_back(it->second);
}
return ids;
}

Check warning on line 105 in src/VecSim/algorithms/brute_force/brute_force_single.h

View check run for this annotation

Codecov / codecov/patch

src/VecSim/algorithms/brute_force/brute_force_single.h#L105

Added line #L105 was not covered by tests

vecsim_stl::abstract_priority_queue<DistType, labelType> *
getNewMaxPriorityQueue() const override {
Expand Down
2 changes: 1 addition & 1 deletion src/VecSim/algorithms/hnsw/hnsw_tiered.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ void TieredHNSWIndex<DataType, DistType>::executeInsertJob(HNSWInsertJob *job) {
// corresponding job id. Note that after calling deleteVectorById, the last id's label
// shouldn't be available, since it is removed from the lookup.
labelType last_vec_label =
this->frontendIndex->getLabelByInternalId(this->frontendIndex->indexSize() - 1);
this->frontendIndex->getVectorLabel(this->frontendIndex->indexSize() - 1);
int deleted = this->frontendIndex->deleteVectorById(job->label, job->id);
if (deleted && job->id != this->frontendIndex->indexSize()) {
// If the vector removal caused a swap with the last id, update the relevant insert job.
Expand Down
298 changes: 201 additions & 97 deletions src/VecSim/algorithms/svs/svs_tiered.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/VecSim/index_factories/tiered_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ BFParams NewBFParams(const TieredIndexParams *params) {
return BFParams{.type = svs_params.type,
.dim = svs_params.dim,
.metric = svs_params.metric,
.multi = false, // multi not supported
.multi = svs_params.multi,
.blockSize = svs_params.blockSize};
}

Expand Down Expand Up @@ -155,7 +155,7 @@ inline VecSimIndex *NewIndex(const TieredIndexParams *params) {
.blockSize = bf_params.blockSize,
.multi = bf_params.multi,
.logCtx = params->primaryIndexParams->logCtx};
auto frontendIndex = static_cast<BruteForceIndex_Single<DataType, float> *>(
auto frontendIndex = static_cast<BruteForceIndex<DataType, float> *>(
BruteForceFactory::NewIndex(&bf_params, abstractInitParams, false));

// Create new tiered svs index
Expand Down
Loading
Loading