summaryrefslogtreecommitdiff
path: root/src/mongo/db/s
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r--src/mongo/db/s/collection_metadata.cpp3
-rw-r--r--src/mongo/db/s/metadata_manager.cpp12
-rw-r--r--src/mongo/db/s/metadata_manager_test.cpp6
-rw-r--r--src/mongo/db/s/split_vector_command.cpp8
-rw-r--r--src/mongo/db/s/start_chunk_clone_request_test.cpp6
-rw-r--r--src/mongo/db/s/type_shard_identity_test.cpp4
6 files changed, 21 insertions, 18 deletions
diff --git a/src/mongo/db/s/collection_metadata.cpp b/src/mongo/db/s/collection_metadata.cpp
index e3a576d88d3..78815711446 100644
--- a/src/mongo/db/s/collection_metadata.cpp
+++ b/src/mongo/db/s/collection_metadata.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/s/collection_metadata.h"
+#include "mongo/bson/simple_bsonobj_comparator.h"
#include "mongo/bson/util/builder.h"
#include "mongo/s/catalog/type_chunk.h"
#include "mongo/stdx/memory.h"
@@ -576,7 +577,7 @@ void CollectionMetadata::fillRanges() {
max = currMax;
continue;
}
- if (max == currMin) {
+ if (SimpleBSONObjComparator::kInstance.evaluate(max == currMin)) {
max = currMax;
continue;
}
diff --git a/src/mongo/db/s/metadata_manager.cpp b/src/mongo/db/s/metadata_manager.cpp
index ffae537754b..c51b4a4ba7a 100644
--- a/src/mongo/db/s/metadata_manager.cpp
+++ b/src/mongo/db/s/metadata_manager.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/s/metadata_manager.h"
+#include "mongo/bson/simple_bsonobj_comparator.h"
#include "mongo/db/range_arithmetic.h"
#include "mongo/db/s/collection_range_deleter.h"
#include "mongo/db/s/sharding_state.h"
@@ -216,7 +217,7 @@ void MetadataManager::forgetReceive(const ChunkRange& range) {
invariant(it != _receivingChunks.end());
// Verify entire ChunkRange is identical, not just the min key.
- invariant(it->second == range.getMax());
+ invariant(SimpleBSONObjComparator::kInstance.evaluate(it->second == range.getMax()));
_receivingChunks.erase(it);
}
@@ -362,8 +363,9 @@ void MetadataManager::_removeRangeToClean_inlock(const ChunkRange& range, Status
--it;
}
- for (; it != _rangesToClean.end() && it->first < range.getMax();) {
- if (it->second.getMax() <= range.getMin()) {
+ for (; it != _rangesToClean.end() &&
+ SimpleBSONObjComparator::kInstance.evaluate(it->first < range.getMax());) {
+ if (SimpleBSONObjComparator::kInstance.evaluate(it->second.getMax() <= range.getMin())) {
++it;
continue;
}
@@ -374,11 +376,11 @@ void MetadataManager::_removeRangeToClean_inlock(const ChunkRange& range, Status
BSONObj oldMax = it->second.getMax();
it->second.complete(deletionStatus);
_rangesToClean.erase(it++);
- if (oldMin < range.getMin()) {
+ if (SimpleBSONObjComparator::kInstance.evaluate(oldMin < range.getMin())) {
_addRangeToClean_inlock(ChunkRange(oldMin, range.getMin()));
}
- if (oldMax > range.getMax()) {
+ if (SimpleBSONObjComparator::kInstance.evaluate(oldMax > range.getMax())) {
_addRangeToClean_inlock(ChunkRange(range.getMax(), oldMax));
}
}
diff --git a/src/mongo/db/s/metadata_manager_test.cpp b/src/mongo/db/s/metadata_manager_test.cpp
index 7e7ff13b9e2..977b35a5f70 100644
--- a/src/mongo/db/s/metadata_manager_test.cpp
+++ b/src/mongo/db/s/metadata_manager_test.cpp
@@ -356,7 +356,7 @@ TEST_F(MetadataManagerTest, BeginReceiveWithOverlappingRange) {
const auto it = copyOfPending.find(BSON("key" << 5));
ASSERT(it != copyOfPending.end());
- ASSERT_EQ(it->second, BSON("key" << 35));
+ ASSERT_BSONOBJ_EQ(it->second, BSON("key" << 35));
}
TEST_F(MetadataManagerTest, RefreshMetadataAfterDropAndRecreate) {
@@ -382,8 +382,8 @@ TEST_F(MetadataManagerTest, RefreshMetadataAfterDropAndRecreate) {
ASSERT_EQ(manager.getActiveMetadata()->getChunks().size(), 1UL);
const auto chunkEntry = manager.getActiveMetadata()->getChunks().begin();
- ASSERT_EQ(BSON("key" << 20), chunkEntry->first);
- ASSERT_EQ(BSON("key" << 30), chunkEntry->second);
+ ASSERT_BSONOBJ_EQ(BSON("key" << 20), chunkEntry->first);
+ ASSERT_BSONOBJ_EQ(BSON("key" << 30), chunkEntry->second);
}
// Tests membership functions for _rangesToClean
diff --git a/src/mongo/db/s/split_vector_command.cpp b/src/mongo/db/s/split_vector_command.cpp
index 5ed698daad1..e00377e5a13 100644
--- a/src/mongo/db/s/split_vector_command.cpp
+++ b/src/mongo/db/s/split_vector_command.cpp
@@ -34,6 +34,7 @@
#include <string>
#include <vector>
+#include "mongo/bson/simple_bsonobj_comparator.h"
#include "mongo/db/auth/action_set.h"
#include "mongo/db/auth/action_type.h"
#include "mongo/db/auth/authorization_manager.h"
@@ -271,7 +272,7 @@ public:
// Use every 'keyCount'-th key as a split point. We add the initial key as a sentinel,
// to be removed at the end. If a key appears more times than entries allowed on a
// chunk, we issue a warning and split on the following key.
- set<BSONObj> tooFrequentKeys;
+ auto tooFrequentKeys = SimpleBSONObjComparator::kInstance.makeOrderedBSONObjSet();
splitKeys.push_back(dps::extractElementsBasedOnTemplate(
prettyKey(idx->keyPattern(), currKey.getOwned()), keyPattern));
@@ -371,9 +372,8 @@ public:
}
// Make sure splitKeys is in ascending order
- std::sort(splitKeys.begin(),
- splitKeys.end(),
- [](const BSONObj& lhs, const BSONObj& rhs) -> bool { return lhs < rhs; });
+ std::sort(
+ splitKeys.begin(), splitKeys.end(), SimpleBSONObjComparator::kInstance.makeLessThan());
result.append("splitKeys", splitKeys);
return true;
}
diff --git a/src/mongo/db/s/start_chunk_clone_request_test.cpp b/src/mongo/db/s/start_chunk_clone_request_test.cpp
index 107c5628580..342d49d9130 100644
--- a/src/mongo/db/s/start_chunk_clone_request_test.cpp
+++ b/src/mongo/db/s/start_chunk_clone_request_test.cpp
@@ -71,9 +71,9 @@ TEST(StartChunkCloneRequest, CreateAsCommandComplete) {
.toString(),
request.getFromShardConnectionString().toString());
ASSERT_EQ("shard0002", request.getToShardId());
- ASSERT_EQ(BSON("Key" << -100), request.getMinKey());
- ASSERT_EQ(BSON("Key" << 100), request.getMaxKey());
- ASSERT_EQ(BSON("Key" << 1), request.getShardKeyPattern());
+ ASSERT_BSONOBJ_EQ(BSON("Key" << -100), request.getMinKey());
+ ASSERT_BSONOBJ_EQ(BSON("Key" << 100), request.getMaxKey());
+ ASSERT_BSONOBJ_EQ(BSON("Key" << 1), request.getShardKeyPattern());
ASSERT_EQ(MigrationSecondaryThrottleOptions::kOff,
request.getSecondaryThrottle().getSecondaryThrottle());
}
diff --git a/src/mongo/db/s/type_shard_identity_test.cpp b/src/mongo/db/s/type_shard_identity_test.cpp
index 960faff68ba..cb9af748106 100644
--- a/src/mongo/db/s/type_shard_identity_test.cpp
+++ b/src/mongo/db/s/type_shard_identity_test.cpp
@@ -61,7 +61,7 @@ TEST(ShardIdentityType, RoundTrip) {
ASSERT_TRUE(shardIdentity.isClusterIdSet());
ASSERT_EQ(clusterId, shardIdentity.getClusterId());
- ASSERT_EQ(doc, shardIdentity.toBSON());
+ ASSERT_BSONOBJ_EQ(doc, shardIdentity.toBSON());
}
TEST(ShardIdentityType, ParseMissingId) {
@@ -144,7 +144,7 @@ TEST(ShardIdentityType, CreateUpdateObject) {
auto updateObj = ShardIdentityType::createConfigServerUpdateObject("test/a:1,b:2");
auto expectedObj = BSON("$set" << BSON("configsvrConnectionString"
<< "test/a:1,b:2"));
- ASSERT_EQ(expectedObj, updateObj);
+ ASSERT_BSONOBJ_EQ(expectedObj, updateObj);
}
} // namespace mongo