diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-11-29 10:21:19 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-12-04 13:24:55 -0500 |
commit | 95e95613412c33b52bb8a514751550c2447526d4 (patch) | |
tree | b0f86dd04b6c6f8978b6a77f6d29adffab79eddf /src/mongo/db/s/collection_metadata.cpp | |
parent | 7920e242c0def907b502265ca14ddf3d86c98025 (diff) | |
download | mongo-95e95613412c33b52bb8a514751550c2447526d4.tar.gz |
SERVER-31056 Remove usages of ScopedCollectionMetadata default constructor
Diffstat (limited to 'src/mongo/db/s/collection_metadata.cpp')
-rw-r--r-- | src/mongo/db/s/collection_metadata.cpp | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/mongo/db/s/collection_metadata.cpp b/src/mongo/db/s/collection_metadata.cpp index c9edf1f8194..964370cc4e8 100644 --- a/src/mongo/db/s/collection_metadata.cpp +++ b/src/mongo/db/s/collection_metadata.cpp @@ -45,8 +45,8 @@ CollectionMetadata::CollectionMetadata(std::shared_ptr<ChunkManager> cm, const S : _cm(std::move(cm)), _thisShardId(thisShardId), _shardVersion(_cm->getVersion(_thisShardId)), - _chunksMap(SimpleBSONObjComparator::kInstance.makeBSONObjIndexedMap<CachedChunkInfo>()), - _rangesMap(SimpleBSONObjComparator::kInstance.makeBSONObjIndexedMap<CachedChunkInfo>()) { + _chunksMap(SimpleBSONObjComparator::kInstance.makeBSONObjIndexedMap<BSONObj>()), + _rangesMap(SimpleBSONObjComparator::kInstance.makeBSONObjIndexedMap<BSONObj>()) { invariant(_cm->getVersion().isSet()); invariant(_cm->getVersion() >= _shardVersion); @@ -55,9 +55,7 @@ CollectionMetadata::CollectionMetadata(std::shared_ptr<ChunkManager> cm, const S if (chunk->getShardId() != _thisShardId) continue; - _chunksMap.emplace_hint(_chunksMap.end(), - chunk->getMin(), - CachedChunkInfo(chunk->getMax(), chunk->getLastmod())); + _chunksMap.emplace_hint(_chunksMap.end(), chunk->getMin(), chunk->getMax()); } if (_chunksMap.empty()) { @@ -81,7 +79,7 @@ void CollectionMetadata::_buildRangesMap() { for (const auto& entry : _chunksMap) { BSONObj const& currMin = entry.first; - BSONObj const& currMax = entry.second.getMaxKey(); + BSONObj const& currMax = entry.second; // Coalesce the chunk's bounds in ranges if they are adjacent chunks if (min.isEmpty()) { @@ -95,8 +93,7 @@ void CollectionMetadata::_buildRangesMap() { continue; } - _rangesMap.emplace_hint( - _rangesMap.end(), min, CachedChunkInfo(max, ChunkVersion::IGNORED())); + _rangesMap.emplace_hint(_rangesMap.end(), min, max); min = currMin; max = currMax; @@ -105,7 +102,7 @@ void CollectionMetadata::_buildRangesMap() { invariant(!min.isEmpty()); invariant(!max.isEmpty()); - _rangesMap.emplace(min, CachedChunkInfo(max, ChunkVersion::IGNORED())); + _rangesMap.emplace(min, max); } bool CollectionMetadata::keyBelongsToMe(const BSONObj& key) const { @@ -117,7 +114,7 @@ bool CollectionMetadata::keyBelongsToMe(const BSONObj& key) const { if (it != _rangesMap.begin()) it--; - return rangeContains(it->first, it->second.getMaxKey(), key); + return rangeContains(it->first, it->second, key); } bool CollectionMetadata::getNextChunk(const BSONObj& lookupKey, ChunkType* chunk) const { @@ -130,16 +127,15 @@ bool CollectionMetadata::getNextChunk(const BSONObj& lookupKey, ChunkType* chunk lowerChunkIt = _chunksMap.end(); } - if (lowerChunkIt != _chunksMap.end() && - lowerChunkIt->second.getMaxKey().woCompare(lookupKey) > 0) { + if (lowerChunkIt != _chunksMap.end() && lowerChunkIt->second.woCompare(lookupKey) > 0) { chunk->setMin(lowerChunkIt->first); - chunk->setMax(lowerChunkIt->second.getMaxKey()); + chunk->setMax(lowerChunkIt->second); return true; } if (upperChunkIt != _chunksMap.end()) { chunk->setMin(upperChunkIt->first); - chunk->setMax(upperChunkIt->second.getMaxKey()); + chunk->setMax(upperChunkIt->second); return true; } @@ -154,7 +150,7 @@ bool CollectionMetadata::getDifferentChunk(const BSONObj& chunkMinKey, while (lowerChunkIt != upperChunkIt) { if (lowerChunkIt->first.woCompare(chunkMinKey) != 0) { differentChunk->setMin(lowerChunkIt->first); - differentChunk->setMax(lowerChunkIt->second.getMaxKey()); + differentChunk->setMax(lowerChunkIt->second); return true; } ++lowerChunkIt; @@ -202,7 +198,7 @@ void CollectionMetadata::toBSONChunks(BSONArrayBuilder& bb) const { for (RangeMap::const_iterator it = _chunksMap.begin(); it != _chunksMap.end(); ++it) { BSONArrayBuilder chunkBB(bb.subarrayStart()); chunkBB.append(it->first); - chunkBB.append(it->second.getMaxKey()); + chunkBB.append(it->second); chunkBB.done(); } } @@ -235,8 +231,8 @@ boost::optional<KeyRange> CollectionMetadata::getNextOrphanRange( // If we overlap, continue after the overlap // TODO: Could optimize slightly by finding next non-contiguous chunk - if (lowerIt != map.end() && lowerIt->second.getMaxKey().woCompare(lookupKey) > 0) { - lookupKey = lowerIt->second.getMaxKey(); // note side effect + if (lowerIt != map.end() && lowerIt->second.woCompare(lookupKey) > 0) { + lookupKey = lowerIt->second; // note side effect return boost::none; } else { return Its(lowerIt, upperIt); @@ -258,8 +254,8 @@ boost::optional<KeyRange> CollectionMetadata::getNextOrphanRange( // bounds of the surrounding ranges in both maps. auto lowerIt = its.first, upperIt = its.second; - if (lowerIt != map.end() && lowerIt->second.getMaxKey().woCompare(range->minKey) > 0) { - range->minKey = lowerIt->second.getMaxKey(); + if (lowerIt != map.end() && lowerIt->second.woCompare(range->minKey) > 0) { + range->minKey = lowerIt->second; } if (upperIt != map.end() && upperIt->first.woCompare(range->maxKey) < 0) { range->maxKey = upperIt->first; |