diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2017-07-19 17:21:40 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-01-13 09:02:11 -0500 |
commit | 9b3ff62c2776039725342f0f22a843e6b375f1be (patch) | |
tree | f66aa544e47079dbb24bcc52b79a54dbc1dec38e /src/mongo/db/s/collection_metadata.h | |
parent | f164097cb678f763289ee870e854f89749dbbba8 (diff) | |
download | mongo-9b3ff62c2776039725342f0f22a843e6b375f1be.tar.gz |
SERVER-32526 Use KeyString for ChunkMap key instead of BSONObj
Diffstat (limited to 'src/mongo/db/s/collection_metadata.h')
-rw-r--r-- | src/mongo/db/s/collection_metadata.h | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/mongo/db/s/collection_metadata.h b/src/mongo/db/s/collection_metadata.h index e606058eae5..1f2135d2674 100644 --- a/src/mongo/db/s/collection_metadata.h +++ b/src/mongo/db/s/collection_metadata.h @@ -54,7 +54,6 @@ public: * "does this key belong to this shard"? */ CollectionMetadata(std::shared_ptr<ChunkManager> cm, const ShardId& thisShardId); - ~CollectionMetadata(); /** * Returns true if 'key' contains exactly the same fields as the shard key pattern. @@ -67,7 +66,9 @@ public: * Returns true if the document with the given key belongs to this chunkset. If the key is empty * returns false. If key is not a valid shard key, the behaviour is undefined. */ - bool keyBelongsToMe(const BSONObj& key) const; + bool keyBelongsToMe(const BSONObj& key) const { + return _cm->keyBelongsToShard(key, _thisShardId); + } /** * Given a key 'lookupKey' in the shard key range, get the next chunk which overlaps or is @@ -85,12 +86,14 @@ public: /** * Validates that the passed-in chunk's bounds exactly match a chunk in the metadata cache. */ - Status checkChunkIsValid(const ChunkType& chunk); + Status checkChunkIsValid(const ChunkType& chunk) const; /** * Returns true if the argument range overlaps any chunk. */ - bool rangeOverlapsChunk(ChunkRange const& range); + bool rangeOverlapsChunk(ChunkRange const& range) const { + return _cm->rangeOverlapsShard(range, _thisShardId); + } /** * Given a key in the shard key range, get the next range which overlaps or is greater than @@ -169,11 +172,6 @@ public: } private: - /** - * Builds _rangesMap from the contents of _chunksMap. - */ - void _buildRangesMap(); - // The full routing table for the collection. std::shared_ptr<ChunkManager> _cm; @@ -185,11 +183,6 @@ private: // Map of chunks tracked by this shard RangeMap _chunksMap; - - // A second map from a min key into a range of contiguous chunks. This map is redundant with - // respect to the contents of _chunkMap but we expect high chunk contiguity, especially in small - // clusters. - RangeMap _rangesMap; }; } // namespace mongo |