diff options
author | Geir Storli <geirst@yahooinc.com> | 2023-03-22 21:25:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-22 21:25:13 +0100 |
commit | c0e8ae27d4fe623de21586ff711c7bcddeef3026 (patch) | |
tree | 7d80cc4d9d9282d68b3fa6d7ea26e12bc0e5a8f6 | |
parent | 8741b011cb22b809858e313dc4da47263a644bd6 (diff) | |
parent | 4e5da07cf2d82bb6e7fe7e14b717716b8405892e (diff) |
Merge pull request #26541 from vespa-engine/toregge/handle-removal-of-docid-with-empty-tensor
Handle removal of docid with empty tensor in HNSW index.
-rw-r--r-- | searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp | 8 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/tensor/hnsw_nodeid_mapping.cpp | 4 |
2 files changed, 11 insertions, 1 deletions
diff --git a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp index f3487f6e585..d9230849699 100644 --- a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp +++ b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp @@ -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); diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_nodeid_mapping.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_nodeid_mapping.cpp index e3afbc3b4c5..8c169e63f9a 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_nodeid_mapping.cpp +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_nodeid_mapping.cpp @@ -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); |