From ab79bbac295e6f9d3fa9d6d069c6163f2085e05a Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Tue, 22 Nov 2022 13:20:02 +0100 Subject: Pass id mapper to HnswIndexLoader. --- .../tensor/hnsw_saver/hnsw_save_load_test.cpp | 26 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'searchlib/src/tests/tensor/hnsw_saver') 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 7495fa18c4d..bf4abdd7cf8 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 @@ -1,8 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include +#include #include #include +#include +#include #include #include #include @@ -32,7 +35,14 @@ uint32_t fake_docid(uint32_t nodeid) template <> uint32_t fake_docid(uint32_t nodeid) { - return nodeid + 100; + switch (nodeid) { + case 5: + return 104; + case 6: + return 104; + default: + return nodeid + 100; + } } template @@ -47,7 +57,14 @@ uint32_t fake_subspace(uint32_t) template <> uint32_t fake_subspace(uint32_t nodeid) { - return nodeid + 10; + switch (nodeid) { + case 5: + return 2; + case 6: + return 1; + default: + return 0; + } } template @@ -69,7 +86,7 @@ template void populate(HnswGraph &graph) { // no 0 graph.make_node(1, fake_docid(1), fake_subspace(1), 1); - auto er = graph.make_node(2, 102, 12, 2); + auto er = graph.make_node(2, fake_docid(2), fake_subspace(2), 2); // no 3 graph.make_node(4, fake_docid(4), fake_subspace(4), 2); graph.make_node(5, fake_docid(5), fake_subspace(5), 0); @@ -137,7 +154,8 @@ public: return vector_writer.output; } void load_copy(std::vector data) { - HnswIndexLoader loader(copy, std::make_unique(data)); + typename HnswIndexTraits::IdMapping id_mapping; + HnswIndexLoader loader(copy, id_mapping, std::make_unique(data)); while (loader.load_next()) {} } -- cgit v1.2.3