aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/tensor
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-01-11 13:17:09 +0100
committerTor Egge <Tor.Egge@online.no>2023-01-11 13:17:09 +0100
commit8929e6c459e7dcbc1ed4ab102ce86545d5736a57 (patch)
treecde7ae590bc4e8b9f4867b4a299e2b57e73977ac /searchlib/src/tests/tensor
parentafb9f81ffd4befa141dfb22d64190a5725d001e7 (diff)
Rename HnswGraph nested types:
LinkStore => LinkArrayStore NodeStore => LevelArrayStore NodeRef => LevelsRef NodeRefVector => NodeVector
Diffstat (limited to 'searchlib/src/tests/tensor')
-rw-r--r--searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp14
-rw-r--r--searchlib/src/tests/tensor/hnsw_nodeid_mapping/hnsw_nodeid_mapping_test.cpp6
-rw-r--r--searchlib/src/tests/tensor/hnsw_saver/hnsw_save_load_test.cpp6
3 files changed, 13 insertions, 13 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 d8e189717c3..7fbfe19b42b 100644
--- a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp
+++ b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp
@@ -522,7 +522,7 @@ TYPED_TEST(HnswIndexTest, memory_is_reclaimed_when_doing_changes_to_graph)
EXPECT_EQ(0, mem_2.allocatedBytesOnHold());
this->remove_document(2);
- size_t node_ref_growth = 0;
+ size_t nodes_growth = 0;
if constexpr (TestFixture::is_single) {
this->expect_level_0(1, {3});
this->expect_empty_level_0(2);
@@ -532,11 +532,11 @@ TYPED_TEST(HnswIndexTest, memory_is_reclaimed_when_doing_changes_to_graph)
this->expect_level_0(1, {2});
this->expect_empty_level_0(3);
this->expect_level_0(2, {1});
- node_ref_growth = sizeof(HnswNode); // Entry for nodeid 3 added when adding doc 2
+ nodes_growth = sizeof(HnswNode); // Entry for nodeid 3 added when adding doc 2
}
auto mem_3 = this->memory_usage();
// We end up in the same state as before document 2 was added and effectively use the same amount of memory.
- EXPECT_EQ((mem_1.usedBytes() - mem_1.deadBytes() + node_ref_growth), (mem_3.usedBytes() - mem_3.deadBytes()));
+ EXPECT_EQ((mem_1.usedBytes() - mem_1.deadBytes() + nodes_growth), (mem_3.usedBytes() - mem_3.deadBytes()));
EXPECT_EQ(0, mem_3.allocatedBytesOnHold());
}
@@ -642,14 +642,14 @@ make_graph_helper(HnswIndex<type>& index)
using LinkArrayRef = typename HnswGraph<type>::LinkArrayRef;
auto& graph = index.get_graph();
ResultGraph result(graph.size());
- assert(!graph.get_node_ref(0).valid());
+ assert(!graph.get_levels_ref(0).valid());
for (uint32_t doc_id = 1; doc_id < graph.size(); ++doc_id) {
auto& node = result[doc_id];
- auto node_ref = graph.get_node_ref(doc_id);
+ auto levels_ref = graph.get_levels_ref(doc_id);
if constexpr (std::is_same_v<std::remove_reference_t<decltype(node)>, uint32_t>) {
- node = node_ref.ref();
+ node = levels_ref.ref();
} else {
- LevelArrayRef level_array(graph.get_level_array(node_ref));
+ LevelArrayRef level_array(graph.get_level_array(levels_ref));
for (uint32_t level = 0; level < level_array.size(); ++level) {
if constexpr (std::is_same_v<std::remove_reference_t<decltype(node)>, std::vector<uint32_t>>) {
node.emplace_back(level_array[level].load_relaxed().ref());
diff --git a/searchlib/src/tests/tensor/hnsw_nodeid_mapping/hnsw_nodeid_mapping_test.cpp b/searchlib/src/tests/tensor/hnsw_nodeid_mapping/hnsw_nodeid_mapping_test.cpp
index ac8b21d6136..3dba1aa44ac 100644
--- a/searchlib/src/tests/tensor/hnsw_nodeid_mapping/hnsw_nodeid_mapping_test.cpp
+++ b/searchlib/src/tests/tensor/hnsw_nodeid_mapping/hnsw_nodeid_mapping_test.cpp
@@ -79,13 +79,13 @@ TEST_F(HnswNodeidMappingTest, free_ids_puts_nodeids_on_hold_list_and_then_free_l
TEST_F(HnswNodeidMappingTest, on_load_populates_mapping)
{
std::vector<HnswNode> nodes(10);
- nodes[1].ref().store_relaxed(EntryRef(1));
+ nodes[1].levels_ref().store_relaxed(EntryRef(1));
nodes[1].store_docid(7);
nodes[1].store_subspace(0);
- nodes[2].ref().store_relaxed(EntryRef(2));
+ nodes[2].levels_ref().store_relaxed(EntryRef(2));
nodes[2].store_docid(4);
nodes[2].store_subspace(0);
- nodes[7].ref().store_relaxed(EntryRef(3));
+ nodes[7].levels_ref().store_relaxed(EntryRef(3));
nodes[7].store_docid(4);
nodes[7].store_subspace(1);
mapping.on_load(vespalib::ConstArrayRef(nodes.data(), nodes.size()));
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 bf4abdd7cf8..21ee88a46fe 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
@@ -113,7 +113,7 @@ void modify(HnswGraph<type> &graph) {
graph.set_link_array(4, 1, V{7});
graph.set_link_array(7, 1, V{4});
- graph.set_entry_node({4, graph.get_node_ref(4), 1});
+ graph.set_entry_node({4, graph.get_levels_ref(4), 1});
}
@@ -124,7 +124,7 @@ public:
GraphType copy;
void expect_empty_d(uint32_t nodeid) const {
- EXPECT_FALSE(copy.acquire_node_ref(nodeid).valid());
+ EXPECT_FALSE(copy.acquire_levels_ref(nodeid).valid());
}
void expect_level_0(uint32_t nodeid, const V& exp_links) const {
@@ -160,7 +160,7 @@ public:
}
void expect_docid_and_subspace(uint32_t nodeid) const {
- auto& node = copy.node_refs.get_elem_ref(nodeid);
+ auto& node = copy.nodes.get_elem_ref(nodeid);
EXPECT_EQ(fake_docid<GraphType::index_type>(nodeid), fake_get_docid(node, nodeid));
EXPECT_EQ(fake_subspace<GraphType::index_type>(nodeid), node.acquire_subspace());
}