diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-09-16 18:08:29 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-11-02 16:46:47 -0400 |
commit | f0ada5e29eb5218c257897bfd1a8fb1e36e06733 (patch) | |
tree | af7cb64596f73165d813e7eb68a030e6028c769d /src/mongo/db/range_arithmetic.cpp | |
parent | fd16deb6dd3d08756f15c181facc707cb53f4e15 (diff) | |
download | mongo-f0ada5e29eb5218c257897bfd1a8fb1e36e06733.tar.gz |
SERVER-25665 Make splitChunk and moveChunk commands use 'chunkVersion'
This change makes the collection metadata on the shard also include the
chunk version and makes the splitChunk and moveChunk commands use it when
checking for consistency.
Diffstat (limited to 'src/mongo/db/range_arithmetic.cpp')
-rw-r--r-- | src/mongo/db/range_arithmetic.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mongo/db/range_arithmetic.cpp b/src/mongo/db/range_arithmetic.cpp index 603dcd324f5..c02daa7c03c 100644 --- a/src/mongo/db/range_arithmetic.cpp +++ b/src/mongo/db/range_arithmetic.cpp @@ -37,6 +37,9 @@ using std::pair; using std::string; using std::stringstream; +CachedChunkInfo::CachedChunkInfo(BSONObj maxKey, ChunkVersion version) + : _maxKey(std::move(maxKey)), _version(version) {} + bool rangeContains(const BSONObj& inclusiveLower, const BSONObj& exclusiveUpper, const BSONObj& point) { @@ -78,7 +81,7 @@ OverlapBounds rangeMapOverlapBounds(const RangeMap& ranges, --low; // If the previous range's max value is lte our min value - if (low->second.woCompare(inclusiveLower) < 1) { + if (low->second.getMaxKey().woCompare(inclusiveLower) < 1) { low = next; } } @@ -97,7 +100,7 @@ void getRangeMapOverlap(const RangeMap& ranges, overlap->clear(); OverlapBounds bounds = rangeMapOverlapBounds(ranges, inclusiveLower, exclusiveUpper); for (RangeMap::const_iterator it = bounds.first; it != bounds.second; ++it) { - overlap->push_back(make_pair(it->first, it->second)); + overlap->push_back(make_pair(it->first, it->second.getMaxKey())); } } @@ -116,7 +119,7 @@ bool rangeMapContains(const RangeMap& ranges, return false; return bounds.first->first.woCompare(inclusiveLower) == 0 && - bounds.first->second.woCompare(exclusiveUpper) == 0; + bounds.first->second.getMaxKey().woCompare(exclusiveUpper) == 0; } string rangeToString(const BSONObj& inclusiveLower, const BSONObj& exclusiveUpper) { @@ -134,4 +137,5 @@ string overlapToString(RangeVector overlap) { } return ss.str(); } -} + +} // namespace mongo |