summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2024-04-23 16:36:19 +0200
committerTor Egge <Tor.Egge@online.no>2024-04-23 16:36:19 +0200
commitc12acd311c172b7a753de6863da12f9491f5e166 (patch)
tree877203819fd2b4616f7efef2e7c632c6ea23a8a5 /searchlib
parentc6685d0d0c8c25f6790cadea4e4c6daf791c57b6 (diff)
HNSW index: Drop candidate if typed cells are invalid.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp
index 7b42fd9a0e1..e0a361e2d9f 100644
--- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp
@@ -180,7 +180,16 @@ template <HnswIndexType type>
bool
HnswIndex<type>::have_closer_distance(HnswTraversalCandidate candidate, const HnswTraversalCandidateVector& result) const
{
- auto df = _distance_ff->for_insertion_vector(get_vector(candidate.nodeid));
+ auto candidate_vector = get_vector(candidate.nodeid);
+ if (!candidate_vector.valid()) {
+ /*
+ * We are in a read thread and the write thread has removed the
+ * tensor for the candidate. Return true to prevent the candidate
+ * from being considered.
+ */
+ return true;
+ }
+ auto df = _distance_ff->for_insertion_vector(candidate_vector);
for (const auto & neighbor : result) {
double dist = calc_distance(*df, neighbor.nodeid);
if (dist < candidate.distance) {