From a994fd22a12836eb4a6f03539dbb821caf0880c1 Mon Sep 17 00:00:00 2001 From: Cihangir Savas Date: Thu, 21 Sep 2023 15:41:31 -0700 Subject: [PATCH] add SqlQuery options. (#17) Summary: Pull Request resolved: https://github.com/facebook/squangle/pull/17 X-link: https://github.com/facebook/hhvm/pull/9396 Adds basic operator functions for implementing hash function for QueryOptions. Reviewed By: aditya-jalan Differential Revision: D48757065 fbshipit-source-id: a12a27125ba8a1ee7c8468e43bcd2f3a3731b88e --- squangle/mysql_client/Query.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/squangle/mysql_client/Query.h b/squangle/mysql_client/Query.h index 704b12f..913d6cb 100644 --- a/squangle/mysql_client/Query.h +++ b/squangle/mysql_client/Query.h @@ -116,6 +116,15 @@ class QueryOptions { return attributes_; } + bool operator==(const QueryOptions& other) const { + return attributes_ == other.attributes_; + } + + std::size_t hashValue() const { + return folly::hash::commutative_hash_combine_range( + attributes_.begin(), attributes_.end()); + } + protected: QueryAttributes attributes_; }; @@ -610,4 +619,14 @@ inline std::ostream& operator<<( } } // namespace std +namespace std { +template <> +struct hash { + std::size_t operator()( + const facebook::common::mysql_client::QueryOptions& opt) const { + return opt.hashValue(); + } +}; +} // namespace std + #endif // COMMON_ASYNC_MYSQL_QUERY_H