summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/tensor/hnsw_saver
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-06-11 13:47:28 +0000
committerArne Juul <arnej@verizonmedia.com>2020-06-12 08:36:29 +0000
commitd42fba42c3a8e58e87d3b03ad0124169c7b96e51 (patch)
tree96025e356141bbfc35b443cdef9b322e81107bc9 /searchlib/src/tests/tensor/hnsw_saver
parent2ccbb15bc59d6ebd743eed0a918ad0374e75f821 (diff)
keep and follow node_refs when traversing HNSW graph
* cannot assert in HnswGraph read operations, because nodes may be removed or replaced by another thread * read operations on the HNSW graph need to load the node_ref (and check that it's valid) when following links; keep and use that node_ref to ensure succeeding operations actually access information that belongs to the same version of the node. * to ensure the entry point is internally consistent, check that the atomic value is the same after reading the corresponding node_ref, and retry if it was updated concurrently.
Diffstat (limited to 'searchlib/src/tests/tensor/hnsw_saver')
-rw-r--r--searchlib/src/tests/tensor/hnsw_saver/hnsw_save_load_test.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/searchlib/src/tests/tensor/hnsw_saver/hnsw_save_load_test.cpp b/searchlib/src/tests/tensor/hnsw_saver/hnsw_save_load_test.cpp
index bcc886fccad..2db6437664e 100644
--- a/searchlib/src/tests/tensor/hnsw_saver/hnsw_save_load_test.cpp
+++ b/searchlib/src/tests/tensor/hnsw_saver/hnsw_save_load_test.cpp
@@ -37,7 +37,7 @@ using V = std::vector<uint32_t>;
void populate(HnswGraph &graph) {
// no 0
graph.make_node_for_document(1, 1);
- graph.make_node_for_document(2, 2);
+ auto er = graph.make_node_for_document(2, 2);
// no 3
graph.make_node_for_document(4, 2);
graph.make_node_for_document(5, 0);
@@ -49,7 +49,7 @@ void populate(HnswGraph &graph) {
graph.set_link_array(6, 0, V{1, 2, 4});
graph.set_link_array(2, 1, V{4});
graph.set_link_array(4, 1, V{2});
- graph.set_entry_node({2, 1});
+ graph.set_entry_node({2, er, 1});
}
void modify(HnswGraph &graph) {
@@ -63,7 +63,7 @@ void modify(HnswGraph &graph) {
graph.set_link_array(4, 1, V{7});
graph.set_link_array(7, 1, V{4});
- graph.set_entry_node({4, 1});
+ graph.set_entry_node({4, graph.get_node_ref(4), 1});
}