summaryrefslogtreecommitdiff
path: root/src/mongo/db/keypattern.cpp
diff options
context:
space:
mode:
authorKevin Matulef <matulef@gmail.com>2012-10-16 06:08:17 -0400
committerKevin Matulef <matulef@gmail.com>2012-10-16 06:31:07 -0400
commit7db66f228efe5fa604f94fcb06e850f09920a711 (patch)
treee9449ff4cd524b8819a85d2d6939c06e7281f66f /src/mongo/db/keypattern.cpp
parent58925e7afbf6f02bf604f80519922d1728ce152d (diff)
downloadmongo-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/db/keypattern.cpp')
-rw-r--r--src/mongo/db/keypattern.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/db/keypattern.cpp b/src/mongo/db/keypattern.cpp
index 1f3fd6233ec..96229b70fd8 100644
--- a/src/mongo/db/keypattern.cpp
+++ b/src/mongo/db/keypattern.cpp
@@ -47,6 +47,20 @@ namespace mongo {
return false;
}
+ bool KeyPattern::isCoveredBy( const KeyPattern& other ) const {
+ BSONForEach( e, _pattern ) {
+ BSONElement otherfield = other.getField( e.fieldName() );
+ if ( otherfield.eoo() ){
+ return false;
+ }
+
+ if ( otherfield.numberInt() != 1 && otherfield.numberInt() != -1 && otherfield != e ){
+ return false;
+ }
+ }
+ return true;
+ }
+
typedef vector<pair<BSONObj,BSONObj> >::const_iterator BoundListIter;
BoundList KeyPattern::keyBounds( const FieldRangeSet& queryConstraints ) const {