diff --git a/src/util/HashMap.h b/src/util/HashMap.h index 2a6b94e2e..39c8a7a4c 100644 --- a/src/util/HashMap.h +++ b/src/util/HashMap.h @@ -6,7 +6,10 @@ #pragma once #include -#include + +#include + +#include "util/AllocatorWithLimit.h" namespace ad_utility { // Wrapper for HashMaps to be used everywhere throughout code for the semantic @@ -15,10 +18,13 @@ namespace ad_utility { template using HashMap = absl::flat_hash_map; -// A HashMap with a memory limit. +// A HashMap with a memory limit. Note: We cannot use `absl::flat_hash_map` +// here, because it is inherently not exception safe, and the +// `AllocatorWithLimit` uses exceptions. template , class EqualElem = absl::container_internal::hash_default_eq, class Alloc = ad_utility::AllocatorWithLimit>> -using HashMapWithMemoryLimit = HashMap; +using HashMapWithMemoryLimit = + std::unordered_map; } // namespace ad_utility diff --git a/src/util/HashSet.h b/src/util/HashSet.h index 4cf9bd56f..a851de6fd 100644 --- a/src/util/HashSet.h +++ b/src/util/HashSet.h @@ -6,13 +6,11 @@ #pragma once -#include +#include #include "absl/container/flat_hash_set.h" #include "util/AllocatorWithLimit.h" -using std::string; - namespace ad_utility { // Wrapper for HashSets (with elements of type T) to be used everywhere // throughout code for the semantic search. This wrapper interface is not @@ -25,11 +23,13 @@ template ; // A hash set (with elements of type T) with a memory Limit. +// Note: We cannot use `absl::flat_hash_set` +// here, because it is inherently not exception safe, and the +// `AllocatorWithLimit` uses exceptions. template , class EqualElem = absl::container_internal::hash_default_eq, class Alloc = ad_utility::AllocatorWithLimit> -using HashSetWithMemoryLimit = - absl::flat_hash_set; +using HashSetWithMemoryLimit = std::unordered_set; } // namespace ad_utility diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 46a83d5b7..bd375f482 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -160,7 +160,7 @@ addLinkAndDiscoverTest(TextLimitOperationTest engine) addLinkAndDiscoverTestSerial(QueryPlannerTest engine) -addLinkAndDiscoverTest(HashMapTest) +addLinkAndDiscoverTestNoLibs(HashMapTest) addLinkAndDiscoverTest(HashSetTest) diff --git a/test/HashMapTest.cpp b/test/HashMapTest.cpp index 7ce7934f9..cb1d670fe 100644 --- a/test/HashMapTest.cpp +++ b/test/HashMapTest.cpp @@ -8,7 +8,7 @@ #include #include -#include "../src/util/HashMap.h" +#include "util/HashMap.h" // Note: Since the HashMap class is a wrapper for a well tested hash map // implementation the following tests only check the API for functionality and