From 854d10495e6a13846ecba96dd2989c21160df1b1 Mon Sep 17 00:00:00 2001 From: Evgeny Malygin Date: Fri, 2 Aug 2024 19:28:24 +0100 Subject: [PATCH 1/7] Fix[mqbs::DataStoreRecordKeyHashAlgo]: prevent trivial collisions Signed-off-by: Evgeny Malygin --- src/groups/mqb/mqbs/mqbs_datastore.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/groups/mqb/mqbs/mqbs_datastore.h b/src/groups/mqb/mqbs/mqbs_datastore.h index 70949267c..d3617d46a 100644 --- a/src/groups/mqb/mqbs/mqbs_datastore.h +++ b/src/groups/mqb/mqbs/mqbs_datastore.h @@ -34,7 +34,6 @@ // BlazingMQ storage mechanism testable. // MQB - #include #include #include @@ -834,7 +833,7 @@ inline DataStoreRecordKeyHashAlgo::result_type DataStoreRecordKeyHashAlgo::operator()(const TYPE& type) const { return type.d_sequenceNum + - static_cast(type.d_primaryLeaseId); + static_cast(type.d_primaryLeaseId) << 32; } // ----------------------------- From 85a7ea6951e8d93c93b173f456398d3cd72cf386 Mon Sep 17 00:00:00 2001 From: Evgeny Malygin Date: Fri, 2 Aug 2024 19:30:20 +0100 Subject: [PATCH 2/7] Formatter: mqbs_datastore.h Signed-off-by: Evgeny Malygin --- src/groups/mqb/mqbs/mqbs_datastore.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/groups/mqb/mqbs/mqbs_datastore.h b/src/groups/mqb/mqbs/mqbs_datastore.h index d3617d46a..f9f18116f 100644 --- a/src/groups/mqb/mqbs/mqbs_datastore.h +++ b/src/groups/mqb/mqbs/mqbs_datastore.h @@ -231,7 +231,7 @@ template void hashAppend(HASH_ALGORITHM& hashAlgo, const DataStoreRecordKey& key); // ================================ -// class DataStoreRecordKeyHashAlgo +// class DataStoreRecordKey // ================================ /// This class provides a hashing algorithm for `mqbs::DataStoreRecordKey`. @@ -240,7 +240,7 @@ void hashAppend(HASH_ALGORITHM& hashAlgo, const DataStoreRecordKey& key); /// `bslh::Hash<>`) in `bslh` framework lingo (see BDE "Modular Hashing" /// document). Note that this class is not templatized on a /// `HASHING_ALGORITHM` (unlike recommended in the document). -class DataStoreRecordKeyHashAlgo { +class DataStoreRecordKey { public: // TYPES typedef bsls::Types::Uint64 result_type; @@ -833,7 +833,8 @@ inline DataStoreRecordKeyHashAlgo::result_type DataStoreRecordKeyHashAlgo::operator()(const TYPE& type) const { return type.d_sequenceNum + - static_cast(type.d_primaryLeaseId) << 32; + static_cast(type.d_primaryLeaseId) + << 32; } // ----------------------------- From 04780cc5201b46580f51e8cf90ac3f1a8018d9ab Mon Sep 17 00:00:00 2001 From: Evgeny Malygin Date: Fri, 2 Aug 2024 19:31:43 +0100 Subject: [PATCH 3/7] Update mqbs_datastore.h Signed-off-by: Evgeny Malygin --- src/groups/mqb/mqbs/mqbs_datastore.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/groups/mqb/mqbs/mqbs_datastore.h b/src/groups/mqb/mqbs/mqbs_datastore.h index f9f18116f..c6f897548 100644 --- a/src/groups/mqb/mqbs/mqbs_datastore.h +++ b/src/groups/mqb/mqbs/mqbs_datastore.h @@ -231,7 +231,7 @@ template void hashAppend(HASH_ALGORITHM& hashAlgo, const DataStoreRecordKey& key); // ================================ -// class DataStoreRecordKey +// class DataStoreRecordKeyHashAlgo // ================================ /// This class provides a hashing algorithm for `mqbs::DataStoreRecordKey`. @@ -240,7 +240,7 @@ void hashAppend(HASH_ALGORITHM& hashAlgo, const DataStoreRecordKey& key); /// `bslh::Hash<>`) in `bslh` framework lingo (see BDE "Modular Hashing" /// document). Note that this class is not templatized on a /// `HASHING_ALGORITHM` (unlike recommended in the document). -class DataStoreRecordKey { +class DataStoreRecordKeyHashAlgo { public: // TYPES typedef bsls::Types::Uint64 result_type; From 9d5ebe9fdbe5a2e71b8df31454f838ba751003aa Mon Sep 17 00:00:00 2001 From: Evgeny Malygin Date: Fri, 2 Aug 2024 19:36:23 +0100 Subject: [PATCH 4/7] Update mqbs_datastore.h Signed-off-by: Evgeny Malygin --- src/groups/mqb/mqbs/mqbs_datastore.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/groups/mqb/mqbs/mqbs_datastore.h b/src/groups/mqb/mqbs/mqbs_datastore.h index c6f897548..ade23211b 100644 --- a/src/groups/mqb/mqbs/mqbs_datastore.h +++ b/src/groups/mqb/mqbs/mqbs_datastore.h @@ -833,7 +833,7 @@ inline DataStoreRecordKeyHashAlgo::result_type DataStoreRecordKeyHashAlgo::operator()(const TYPE& type) const { return type.d_sequenceNum + - static_cast(type.d_primaryLeaseId) + static_cast(type.d_primaryLeaseId) << 32; } From e130efbfacde60fa0156c74997421c9b69aba161 Mon Sep 17 00:00:00 2001 From: Evgeny Malygin Date: Mon, 5 Aug 2024 14:44:00 +0100 Subject: [PATCH 5/7] Update mqbs_datastore.h Signed-off-by: Evgeny Malygin --- src/groups/mqb/mqbs/mqbs_datastore.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/groups/mqb/mqbs/mqbs_datastore.h b/src/groups/mqb/mqbs/mqbs_datastore.h index ade23211b..ec4899428 100644 --- a/src/groups/mqb/mqbs/mqbs_datastore.h +++ b/src/groups/mqb/mqbs/mqbs_datastore.h @@ -463,7 +463,7 @@ class DataStoreConfig { /// Format the specified `value` to the specified output `stream` and return /// a reference to the modifiable `stream`. -bsl::ostream& operator<<(bsl::ostream& stream, const DataStoreConfig& value); +bsl::ostream& operator(bsl::ostream& stream, const DataStoreConfig& value); // =========================== // class DataStoreRecordHandle @@ -833,8 +833,8 @@ inline DataStoreRecordKeyHashAlgo::result_type DataStoreRecordKeyHashAlgo::operator()(const TYPE& type) const { return type.d_sequenceNum + - static_cast(type.d_primaryLeaseId) - << 32; + (static_cast(type.d_primaryLeaseId) + << 32); } // ----------------------------- From 3f8f7ea2c9f063f00d947c04b3a0486f23c2411c Mon Sep 17 00:00:00 2001 From: Evgeny Malygin Date: Mon, 5 Aug 2024 14:45:04 +0100 Subject: [PATCH 6/7] Update mqbs_datastore.h Signed-off-by: Evgeny Malygin --- src/groups/mqb/mqbs/mqbs_datastore.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/groups/mqb/mqbs/mqbs_datastore.h b/src/groups/mqb/mqbs/mqbs_datastore.h index ec4899428..e02ff7ec6 100644 --- a/src/groups/mqb/mqbs/mqbs_datastore.h +++ b/src/groups/mqb/mqbs/mqbs_datastore.h @@ -833,8 +833,7 @@ inline DataStoreRecordKeyHashAlgo::result_type DataStoreRecordKeyHashAlgo::operator()(const TYPE& type) const { return type.d_sequenceNum + - (static_cast(type.d_primaryLeaseId) - << 32); + (static_cast(type.d_primaryLeaseId) << 32); } // ----------------------------- From 48f70f67d407a28daf1a3aa18ef9d8918aae5cf6 Mon Sep 17 00:00:00 2001 From: Evgeny Malygin Date: Mon, 5 Aug 2024 14:46:43 +0100 Subject: [PATCH 7/7] Update mqbs_datastore.h Signed-off-by: Evgeny Malygin --- src/groups/mqb/mqbs/mqbs_datastore.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/groups/mqb/mqbs/mqbs_datastore.h b/src/groups/mqb/mqbs/mqbs_datastore.h index e02ff7ec6..70ea91568 100644 --- a/src/groups/mqb/mqbs/mqbs_datastore.h +++ b/src/groups/mqb/mqbs/mqbs_datastore.h @@ -463,7 +463,7 @@ class DataStoreConfig { /// Format the specified `value` to the specified output `stream` and return /// a reference to the modifiable `stream`. -bsl::ostream& operator(bsl::ostream& stream, const DataStoreConfig& value); +bsl::ostream& operator<<(bsl::ostream& stream, const DataStoreConfig& value); // =========================== // class DataStoreRecordHandle