Skip to content

Commit

Permalink
Merge pull request #26541 from vespa-engine/toregge/handle-removal-of…
Browse files Browse the repository at this point in the history
…-docid-with-empty-tensor

Handle removal of docid with empty tensor in HNSW index.
  • Loading branch information
geirst committed Mar 22, 2023
2 parents 8741b01 + 4e5da07 commit c0e8ae2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,14 @@ TEST_F(HnswMultiIndexTest, duplicate_docid_is_removed)
EXPECT_EQ(2, filter->max_docid());
};

TEST_F(HnswMultiIndexTest, docid_with_empty_tensor_can_be_removed)
{
this->init(false);
this->vectors.set(1, {});
this->add_document(1);
this->remove_document(1);
}

TEST(LevelGeneratorTest, gives_various_levels)
{
InvLogLevelGenerator generator(4);
Expand Down
4 changes: 3 additions & 1 deletion searchlib/src/vespa/searchlib/tensor/hnsw_nodeid_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ HnswNodeidMapping::free_ids(uint32_t docid)
{
assert(docid < _refs.size());
EntryRef ref = _refs[docid];
assert(ref.valid());
if (!ref.valid()) {
return;
}
auto nodeids = _nodeids.get(ref);
for (auto nodeid : nodeids) {
_hold_list.insert(nodeid);
Expand Down

0 comments on commit c0e8ae2

Please sign in to comment.