summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Taskov <alex.taskov@mongodb.com>2020-07-13 14:28:19 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-13 19:12:46 +0000
commitada8adeff4939b89b59eec1f8a86ecab9a32db2b (patch)
treed2e61a3980b44d22faca295fefb4f5bc6f41ed4a
parent75691902119c31adc7955da52afcff63cc0bf97b (diff)
downloadmongo-ada8adeff4939b89b59eec1f8a86ecab9a32db2b.tar.gz
SERVER-48744 Convert ShardInfoMap to use unordered_map instead of map
-rw-r--r--src/mongo/s/catalog/type_chunk.cpp13
-rw-r--r--src/mongo/s/chunk_manager.h4
2 files changed, 8 insertions, 9 deletions
diff --git a/src/mongo/s/catalog/type_chunk.cpp b/src/mongo/s/catalog/type_chunk.cpp
index 390dd8e4e0c..f7024d02086 100644
--- a/src/mongo/s/catalog/type_chunk.cpp
+++ b/src/mongo/s/catalog/type_chunk.cpp
@@ -478,13 +478,6 @@ Status ChunkType::validate() const {
str::stream() << "missing " << shard.name() << " field");
}
- // 'min' and 'max' must share the same fields.
- if (_min->nFields() != _max->nFields()) {
- return {ErrorCodes::BadValue,
- str::stream() << "min and max don't have the same number of keys: " << *_min << ", "
- << *_max};
- }
-
BSONObjIterator minIt(getMin());
BSONObjIterator maxIt(getMax());
while (minIt.more() && maxIt.more()) {
@@ -497,6 +490,12 @@ Status ChunkType::validate() const {
}
}
+ // 'min' and 'max' must share the same fields.
+ if (minIt.more() || maxIt.more())
+ return {ErrorCodes::BadValue,
+ str::stream() << "min and max don't have the same number of keys: " << *_min << ", "
+ << *_max};
+
// 'max' should be greater than 'min'.
if (_min->woCompare(getMax()) >= 0) {
return {ErrorCodes::BadValue,
diff --git a/src/mongo/s/chunk_manager.h b/src/mongo/s/chunk_manager.h
index 3a0858f6a3d..28ec370ae07 100644
--- a/src/mongo/s/chunk_manager.h
+++ b/src/mongo/s/chunk_manager.h
@@ -29,7 +29,6 @@
#pragma once
-#include <map>
#include <set>
#include <string>
#include <vector>
@@ -40,6 +39,7 @@
#include "mongo/s/chunk_version.h"
#include "mongo/s/client/shard.h"
#include "mongo/s/shard_key_pattern.h"
+#include "mongo/stdx/unordered_map.h"
#include "mongo/util/concurrency/ticketholder.h"
namespace mongo {
@@ -62,7 +62,7 @@ struct ShardVersionTargetingInfo {
// Map from a shard to a struct indicating both the max chunk version on that shard and whether the
// shard is currently marked as needing a catalog cache refresh (stale).
-using ShardVersionMap = std::map<ShardId, ShardVersionTargetingInfo>;
+using ShardVersionMap = stdx::unordered_map<ShardId, ShardVersionTargetingInfo, ShardId::Hasher>;
// This class serves as a Facade around how the mapping of ranges to chunks is represented. It also
// provides a simpler, high-level interface for domain specific operations without exposing the