diff --git a/src/engine/LocalVocab.h b/src/engine/LocalVocab.h index 756fd190f8..147a2f20f8 100644 --- a/src/engine/LocalVocab.h +++ b/src/engine/LocalVocab.h @@ -45,7 +45,7 @@ class LocalVocab { // `LiteralOrIri`) to remain stable over their lifetime in the hash map // because we hand out pointers to them. using Set = - ad_utility::CustomHashSetWithMemoryLimit; + ad_utility::NodeHashSetWithMemoryLimit; ad_utility::detail::AllocationMemoryLeftThreadsafe limit_; std::shared_ptr primaryWordSet_; diff --git a/src/util/HashSet.h b/src/util/HashSet.h index 43812260cc..843855bcb2 100644 --- a/src/util/HashSet.h +++ b/src/util/HashSet.h @@ -17,6 +17,7 @@ #include "util/AllocatorWithLimit.h" #include "util/DefaultValueSizeGetter.h" #include "util/MemorySize/MemorySize.h" +#include "util/ValueSizeGetters.h" using std::string; @@ -43,10 +44,10 @@ using HashSetWithMemoryLimit = // Wrapper around absl::node_hash_set with a memory limit. All operations that // may change the allocated memory of the hash set is tracked using a // `AllocationMemoryLeftThreadsafe` object. -template , class HashFct = absl::container_internal::hash_default_hash, class EqualElem = absl::container_internal::hash_default_eq> -class CustomHashSetWithMemoryLimit { +class NodeHashSetWithMemoryLimit { private: using HashSet = absl::node_hash_set; HashSet hashSet_; @@ -70,9 +71,8 @@ class CustomHashSetWithMemoryLimit { constexpr static size_t slotMemoryCost = sizeof(void*) + 1; public: - CustomHashSetWithMemoryLimit( - detail::AllocationMemoryLeftThreadsafe memoryLeft, - SizeGetter sizeGetter = {}) + NodeHashSetWithMemoryLimit(detail::AllocationMemoryLeftThreadsafe memoryLeft, + SizeGetter sizeGetter = {}) : memoryLeft_{memoryLeft}, memoryUsed_{MemorySize::bytes(0)}, sizeGetter_{sizeGetter}, @@ -82,7 +82,7 @@ class CustomHashSetWithMemoryLimit { updateSlotArrayMemoryUsage(); } - ~CustomHashSetWithMemoryLimit() { decreaseMemoryUsed(memoryUsed_); } + ~NodeHashSetWithMemoryLimit() { decreaseMemoryUsed(memoryUsed_); } // Try to allocate the amount of memory requested void increaseMemoryUsed(ad_utility::MemorySize amount) { diff --git a/test/CustomHashSetWithMemoryLimitTest.cpp b/test/CustomHashSetWithMemoryLimitTest.cpp index e4a89af72c..b2d5b42e41 100644 --- a/test/CustomHashSetWithMemoryLimitTest.cpp +++ b/test/CustomHashSetWithMemoryLimitTest.cpp @@ -7,7 +7,7 @@ using ad_utility::makeAllocationMemoryLeftThreadsafeObject; using namespace ad_utility::memory_literals; -using Set = ad_utility::CustomHashSetWithMemoryLimit; +using Set = ad_utility::NodeHashSetWithMemoryLimit; TEST(CustomHashSetWithMemoryLimitTest, sizeAndInsert) { Set hashSet{makeAllocationMemoryLeftThreadsafeObject(100_B)}; @@ -142,7 +142,7 @@ struct StringSizeGetter { }; using StringSet = - ad_utility::CustomHashSetWithMemoryLimit; + ad_utility::NodeHashSetWithMemoryLimit; TEST(CustomHashSetWithMemoryLimitTest, stringInsertAndMemoryTracking) { StringSet hashSet{makeAllocationMemoryLeftThreadsafeObject(1000_B)};