summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp')
-rw-r--r--searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
index d00342d0e51..2f51459ebfa 100644
--- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
+++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
@@ -887,6 +887,7 @@ public:
}
void test_setup();
void test_save_load(bool multi_node);
+ void test_address_space_usage();
};
template <HnswIndexType type>
@@ -935,6 +936,23 @@ TensorAttributeHnswIndex<type>::test_save_load(bool multi_node)
expect_level_0(1, index_b.get_node(2));
}
+template <HnswIndexType type>
+void
+TensorAttributeHnswIndex<type>::test_address_space_usage()
+{
+ bool dense = type == HnswIndexType::SINGLE;
+ search::AddressSpaceUsage usage = _attr->getAddressSpaceUsage();
+ const auto& all = usage.get_all();
+ EXPECT_EQUAL(dense ? 3u : 5u, all.size());
+ EXPECT_EQUAL(1u, all.count("tensor-store"));
+ EXPECT_EQUAL(1u, all.count("hnsw-levels-store"));
+ EXPECT_EQUAL(1u, all.count("hnsw-links-store"));
+ if (!dense) {
+ EXPECT_EQUAL(1u, all.count("hnsw-nodeid-mapping"));
+ EXPECT_EQUAL(1u, all.count("shared-string-repo"));
+ }
+}
+
class DenseTensorAttributeHnswIndex : public TensorAttributeHnswIndex<HnswIndexType::SINGLE> {
public:
DenseTensorAttributeHnswIndex() : TensorAttributeHnswIndex<HnswIndexType::SINGLE>(vec_2d_spec, FixtureTraits().hnsw()) {}
@@ -970,16 +988,15 @@ TEST_F("Hnsw index is integrated in mixed tensor attribute and can be saved and
f.test_save_load(true);
}
-TEST_F("Populates address space usage", DenseTensorAttributeHnswIndex)
+TEST_F("Populates address space usage in dense tensor attribute with hnsw index", DenseTensorAttributeHnswIndex)
{
- search::AddressSpaceUsage usage = f._attr->getAddressSpaceUsage();
- const auto& all = usage.get_all();
- EXPECT_EQUAL(3u, all.size());
- EXPECT_EQUAL(1u, all.count("tensor-store"));
- EXPECT_EQUAL(1u, all.count("hnsw-levels-store"));
- EXPECT_EQUAL(1u, all.count("hnsw-links-store"));
+ f.test_address_space_usage();
}
+TEST_F("Populates address space usage in mixed tensor attribute with hnsw index", MixedTensorAttributeHnswIndex)
+{
+ f.test_address_space_usage();
+}
class DenseTensorAttributeMockIndex : public Fixture {
public: