diff options
author | Kevin Matulef <matulef@gmail.com> | 2012-10-16 06:08:17 -0400 |
---|---|---|
committer | Kevin Matulef <matulef@gmail.com> | 2012-10-16 06:31:07 -0400 |
commit | 7db66f228efe5fa604f94fcb06e850f09920a711 (patch) | |
tree | e9449ff4cd524b8819a85d2d6939c06e7281f66f /src/mongo/s/d_chunk_manager.cpp | |
parent | 58925e7afbf6f02bf604f80519922d1728ce152d (diff) | |
download | mongo-7db66f228efe5fa604f94fcb06e850f09920a711.tar.gz |
SERVER-2001 filter queries on mongod using new key extraction path
Queries on mongod must filter out documents that do not currently belong
to the shard. The belongsToMe function now uses the new key extraction
path to make this determination. An optimization is also added to the
clientcursor class so that it can make this determination using a
covered index if available.
Diffstat (limited to 'src/mongo/s/d_chunk_manager.cpp')
-rw-r--r-- | src/mongo/s/d_chunk_manager.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mongo/s/d_chunk_manager.cpp b/src/mongo/s/d_chunk_manager.cpp index b5f890f1559..d1d9286e720 100644 --- a/src/mongo/s/d_chunk_manager.cpp +++ b/src/mongo/s/d_chunk_manager.cpp @@ -244,22 +244,24 @@ namespace mongo { if ( _rangesMap.size() == 0 ) return false; - return _belongsToMe( cc->extractFields( _key , true ) ); + KeyPattern pat( _key ); + return _belongsToMe( cc->extractKey( pat ) ); } - bool ShardChunkManager::belongsToMe( const BSONObj& obj ) const { + bool ShardChunkManager::belongsToMe( const BSONObj& doc ) const { if ( _rangesMap.size() == 0 ) return false; - return _belongsToMe( obj.extractFields( _key , true ) ); + KeyPattern pat( _key ); + return _belongsToMe( pat.extractSingleKey( doc ) ); } - bool ShardChunkManager::_belongsToMe( const BSONObj& x ) const { - RangeMap::const_iterator it = _rangesMap.upper_bound( x ); + bool ShardChunkManager::_belongsToMe( const BSONObj& point ) const { + RangeMap::const_iterator it = _rangesMap.upper_bound( point ); if ( it != _rangesMap.begin() ) it--; - bool good = contains( it->first , it->second , x ); + bool good = contains( it->first , it->second , point ); #if 0 if ( ! good ) { |