You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[yugabyte#25403] docdb: Add helpers for defining hash functions
Summary:
Defining hash functions for structs requires a lot of boilerplate. For example, to make
`boost::hash` work with `YsqlFullTableName`, we have:
```
inline size_t hash_value(const YsqlFullTableName& table) {
size_t value = 0;
boost::hash_combine(value, table.namespace_name);
boost::hash_combine(value, table.schema_name);
boost::hash_combine(value, table.table_name);
return value;
}
```
This diff adds helper macros to eliminate much of the boilerplate needed to make std::hash
and boost::hash work with structs, e.g.
```
YB_STRUCT_DEFINE_HASH(yb, YsqlFullTableName, namespace_name, schema_name, table_name);
```
will allow both `std::hash<YsqlFullTableName>` and `boost::hash<YsqlFullTableName>` to work and hash over `namespace_name`, `schema_name`, and `table_name`.
Jira: DB-14634
Test Plan: Jenkins
Reviewers: hsunder, sergei, xCluster
Reviewed By: hsunder
Subscribers: svc_phabricator, ycdcxcluster, bkolagani, ybase
Differential Revision: https://phorge.dev.yugabyte.com/D40837
0 commit comments