summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-03-22 20:54:20 +0100
committerTor Egge <Tor.Egge@online.no>2023-03-22 20:54:20 +0100
commit4e5da07cf2d82bb6e7fe7e14b717716b8405892e (patch)
treef199f0b80b4643993d9f13a490304103b87019ca
parent75f3408bf3cae9b2e11bfcafbdfd65f8066695f4 (diff)
Handle removal of docid with empty tensor in HNSW index.
-rw-r--r--searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/tensor/hnsw_nodeid_mapping.cpp4
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);