summaryrefslogtreecommitdiff
path: root/src/mongo/s/collection_metadata.cpp
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2013-08-13 12:35:55 -0400
committerGreg Studer <greg@10gen.com>2013-08-13 12:35:55 -0400
commit5c03be3aca41801c807ed49666020c4a8088549d (patch)
tree9f0c35f358b3ebde81f34720f535272dfb81295b /src/mongo/s/collection_metadata.cpp
parent5c94494146e1f38c81a497ac7300b65d85456cc7 (diff)
downloadmongo-5c03be3aca41801c807ed49666020c4a8088549d.tar.gz
Revert "SERVER-8869 command to merge co-located chunks"
This reverts commit a58ae77d0e5035cb4b541751dbe042e9173deea5.
Diffstat (limited to 'src/mongo/s/collection_metadata.cpp')
-rw-r--r--src/mongo/s/collection_metadata.cpp43
1 files changed, 17 insertions, 26 deletions
diff --git a/src/mongo/s/collection_metadata.cpp b/src/mongo/s/collection_metadata.cpp
index e997e4a4a04..367c332428b 100644
--- a/src/mongo/s/collection_metadata.cpp
+++ b/src/mongo/s/collection_metadata.cpp
@@ -464,27 +464,28 @@ namespace mongo {
return isPending;
}
- bool CollectionMetadata::getNextChunk( const BSONObj& lookupKey, ChunkType* chunk ) const {
-
- RangeMap::const_iterator upperChunkIt = _chunksMap.upper_bound( lookupKey );
- RangeMap::const_iterator lowerChunkIt = upperChunkIt;
- if ( upperChunkIt != _chunksMap.begin() ) --lowerChunkIt;
- else lowerChunkIt = _chunksMap.end();
-
- if ( lowerChunkIt != _chunksMap.end() &&
- lowerChunkIt->second.woCompare( lookupKey ) > 0 ) {
- chunk->setMin( lowerChunkIt->first );
- chunk->setMax( lowerChunkIt->second );
+ bool CollectionMetadata::getNextChunk(const BSONObj& lookupKey,
+ ChunkType* chunk) const {
+ if (_chunksMap.empty()) {
return true;
}
- if ( upperChunkIt != _chunksMap.end() ) {
- chunk->setMin( upperChunkIt->first );
- chunk->setMax( upperChunkIt->second );
- return true;
+ RangeMap::const_iterator it;
+ if (lookupKey.isEmpty()) {
+ it = _chunksMap.begin();
+ chunk->setMin(it->first);
+ chunk->setMax(it->second);
+ return _chunksMap.size() == 1;
}
- return false;
+ it = _chunksMap.upper_bound(lookupKey);
+ if (it != _chunksMap.end()) {
+ chunk->setMin(it->first);
+ chunk->setMax(it->second);
+ return false;
+ }
+
+ return true;
}
BSONObj CollectionMetadata::toBSON() const {
@@ -649,16 +650,6 @@ namespace mongo {
return true;
}
- bool CollectionMetadata::isValidKey( const BSONObj& key ) const {
- BSONObjIterator it( _keyPattern );
- BSONObjBuilder maxKeyB;
- while ( it.more() ) {
- BSONElement next = it.next();
- if ( !key.hasField( next.fieldName() ) ) return false;
- }
- return key.nFields() == _keyPattern.nFields();
- }
-
void CollectionMetadata::fillRanges() {
if (_chunksMap.empty())
return;