aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2021-08-20 14:20:55 +0000
committerGeir Storli <geirst@verizonmedia.com>2021-08-20 15:16:56 +0000
commitece9618bad3bd6f1af33f3e11106634762027034 (patch)
treef8a6eb5b0b2d9c40c84db3819a12de640aa935ce /searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
parent30c8dac6c619d6fe2d5858e5def4f64c64a11029 (diff)
Report address space usage for components in tensor attributes.
Diffstat (limited to 'searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp')
-rw-r--r--searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
index 084bdf90a14..db76d8bad25 100644
--- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
+++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp
@@ -34,6 +34,7 @@
LOG_SETUP("tensorattribute_test");
using document::WrongTensorTypeException;
+using search::AddressSpaceUsage;
using search::AttributeGuard;
using search::AttributeVector;
using search::CompactionStrategy;
@@ -210,6 +211,7 @@ public:
++_memory_usage_cnt;
return vespalib::MemoryUsage();
}
+ void populate_address_space_usage(AddressSpaceUsage&) const override {}
void get_state(const vespalib::slime::Inserter&) const override {}
void shrink_lid_space(uint32_t) override { }
std::unique_ptr<NearestNeighborIndexSaver> make_saver() const override {
@@ -517,6 +519,7 @@ struct Fixture {
void testTensorTypeFileHeaderTag();
void testEmptyTensor();
void testOnHoldAccounting();
+ void test_populate_address_space_usage();
};
@@ -708,6 +711,15 @@ Fixture::testOnHoldAccounting()
EXPECT_EQUAL(0u, getStatus().getOnHold());
}
+void
+Fixture::test_populate_address_space_usage()
+{
+ search::AddressSpaceUsage usage = _attr->getAddressSpaceUsage();
+ const auto& all = usage.get_all();
+ EXPECT_EQUAL(1u, all.size());
+ EXPECT_EQUAL(1u, all.count("tensor-store"));
+}
+
template <class MakeFixture>
void testAll(MakeFixture &&f)
{
@@ -718,6 +730,7 @@ void testAll(MakeFixture &&f)
TEST_DO(f()->testTensorTypeFileHeaderTag());
TEST_DO(f()->testEmptyTensor());
TEST_DO(f()->testOnHoldAccounting());
+ TEST_DO(f()->test_populate_address_space_usage());
}
TEST("Test sparse tensors with generic tensor attribute")
@@ -790,6 +803,16 @@ TEST_F("Hnsw index is integrated in dense tensor attribute and can be saved and
expect_level_0(1, index_b.get_node(2));
}
+TEST_F("Populates address space usage", 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-node-store"));
+ EXPECT_EQUAL(1u, all.count("hnsw-link-store"));
+}
+
class DenseTensorAttributeMockIndex : public Fixture {
public: