diff options
Diffstat (limited to 'searchlib/src/tests')
-rw-r--r-- | searchlib/src/tests/attribute/enumstore/enumstore_test.cpp | 10 | ||||
-rw-r--r-- | searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp | 18 |
2 files changed, 25 insertions, 3 deletions
diff --git a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp index 5346cc7f764..99fdd9f4b0a 100644 --- a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp +++ b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchlib/attribute/enumstore.hpp> +#include <vespa/vespalib/test/memory_allocator_observer.h> #include <vespa/vespalib/gtest/gtest.h> #include <vespa/log/log.h> @@ -11,6 +12,8 @@ using vespalib::datastore::CompactionStrategy; using vespalib::datastore::EntryRef; using vespalib::datastore::EntryRefFilter; using RefT = vespalib::datastore::EntryRefT<22>; +using vespalib::alloc::test::MemoryAllocatorObserver; +using AllocStats = MemoryAllocatorObserver::Stats; namespace vespalib::datastore { @@ -374,6 +377,13 @@ TEST(EnumStoreTest, address_space_usage_is_reported) EXPECT_EQ(AddressSpace(3, 3, ADDRESS_LIMIT + 2), store.get_values_address_space_usage()); } +TEST(EnumStoreTest, provided_memory_allocator_is_used) +{ + AllocStats stats; + NumericEnumStore ses(false, DictionaryConfig::Type::BTREE, std::make_unique<MemoryAllocatorObserver>(stats)); + EXPECT_EQ(AllocStats(1, 0), stats); +} + class BatchUpdaterTest : public ::testing::Test { public: NumericEnumStore store; diff --git a/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp b/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp index bddaa4f4e31..29af989d484 100644 --- a/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp +++ b/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp @@ -6,6 +6,7 @@ #include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/stllike/hash_set.h> #include <vespa/vespalib/test/insertion_operators.h> +#include <vespa/vespalib/test/memory_allocator_observer.h> #include <vespa/vespalib/util/generationhandler.h> #include <vespa/vespalib/util/rand48.h> #include <vespa/vespalib/util/size_literals.h> @@ -16,6 +17,8 @@ LOG_SETUP("multivaluemapping_test"); using vespalib::datastore::ArrayStoreConfig; using vespalib::datastore::CompactionSpec; using vespalib::datastore::CompactionStrategy; +using vespalib::alloc::test::MemoryAllocatorObserver; +using AllocStats = MemoryAllocatorObserver::Stats; template <typename EntryT> void @@ -69,6 +72,7 @@ class MappingTestBase : public ::testing::Test { protected: using MvMapping = search::attribute::MultiValueMapping<EntryT>; using AttributeType = MyAttribute<MvMapping>; + AllocStats _stats; std::unique_ptr<MvMapping> _mvMapping; std::unique_ptr<AttributeType> _attr; uint32_t _maxSmallArraySize; @@ -78,7 +82,8 @@ protected: public: using ConstArrayRef = vespalib::ConstArrayRef<EntryT>; MappingTestBase() - : _mvMapping(), + : _stats(), + _mvMapping(), _attr(), _maxSmallArraySize() { @@ -87,7 +92,7 @@ public: ArrayStoreConfig config(maxSmallArraySize, ArrayStoreConfig::AllocSpec(0, RefType::offsetSize(), 8_Ki, ALLOC_GROW_FACTOR)); config.enable_free_lists(enable_free_lists); - _mvMapping = std::make_unique<MvMapping>(config); + _mvMapping = std::make_unique<MvMapping>(config, vespalib::GrowStrategy(), std::make_unique<MemoryAllocatorObserver>(_stats)); _attr = std::make_unique<AttributeType>(*_mvMapping); _maxSmallArraySize = maxSmallArraySize; } @@ -95,7 +100,7 @@ public: ArrayStoreConfig config(maxSmallArraySize, ArrayStoreConfig::AllocSpec(minArrays, maxArrays, numArraysForNewBuffer, ALLOC_GROW_FACTOR)); config.enable_free_lists(enable_free_lists); - _mvMapping = std::make_unique<MvMapping>(config); + _mvMapping = std::make_unique<MvMapping>(config, vespalib::GrowStrategy(), std::make_unique<MemoryAllocatorObserver>(_stats)); _attr = std::make_unique<AttributeType>(*_mvMapping); _maxSmallArraySize = maxSmallArraySize; } @@ -129,6 +134,7 @@ public: _mvMapping->clearDocs(lidLow, lidLimit, [this](uint32_t docId) { _attr->clearDoc(docId); }); } size_t getTotalValueCnt() const { return _mvMapping->getTotalValueCnt(); } + const AllocStats &get_stats() const noexcept { return _stats; } uint32_t countBuffers() { using RefVector = typename MvMapping::RefCopyVector; @@ -326,6 +332,12 @@ TEST_F(IntMappingTest, test_that_free_lists_can_be_disabled) EXPECT_FALSE(_mvMapping->has_free_lists_enabled()); } +TEST_F(IntMappingTest, provided_memory_allocator_is_used) +{ + setup(3, 64, 512, 129, true); + EXPECT_EQ(AllocStats(5, 0), get_stats()); +} + TEST_F(CompactionIntMappingTest, test_that_compaction_works) { setup(3, 64, 512, 129); |