-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Server Programmability
-
ALL
-
Programmability 2025-05-12
-
None
-
3
-
TBD
-
None
-
None
-
None
-
None
-
None
-
None
`AbslHashValue` has a specific purpose. It is the ADL-extension hook for making absl::Hash system able to hash user types. It's crucial to follow the rules laid out by the absl::Hash maintainers when participating in this system:
https://abseil.io/docs/cpp/guides/hash#making-hashable-types
If you want your type to be hashable by absl::Hash, you need to define an overload of AbslHashValue() for your type. The overload should combine state with the existing hash state (denoted as H in the template below), and your class must provide an equality operator.
An AbslHashValue() overload for a type Foo should only be declared in the header that defines Foo, and in the same namespace as Foo.
We are not doing this correctly in several instances. This makes the hashing system in our codebase unstable and susceptible to OneDefinitionRule violations.
Problematic `AbslHashValue` overloads:
fts_query_hash.h:
hasher for FTSQuery out of the way.
pipeline/expression_hasher.h:
TimeZone
Value
Expression.
src/mongo/db/query/query_stats/agg_key.h (etc)
hashers for specific smart pointers, hashing their dereffed object?
Make new smartpointer types for this, or use custom hashers when
then need to be hashed.
src/mongo/db/query/query_stats/query_stats_helpers.h
BSONObj, but in the wrong namespace. (dead file: can just remove it)
src/mongo/util/hash_utils.h: big problem here.
StringData
boost::optional
src/mongo/db/query/interval_evaluation_tree.h: (benign but fragile)
hasher defined in a different file from the class, by one user.
It's a hasher for a typedef of a template instantiation. using IET = algebra::PolyValue<...>.
This appears to be unused code though, so let's delete it.
- related to
-
SERVER-105040 Avoid forward declaration of IndexEntry in expression.h
-
- Open
-