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/db/keypattern.h | |
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/db/keypattern.h')
-rw-r--r-- | src/mongo/db/keypattern.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mongo/db/keypattern.h b/src/mongo/db/keypattern.h index fa957d0c4a7..b8c96ba88e8 100644 --- a/src/mongo/db/keypattern.h +++ b/src/mongo/db/keypattern.h @@ -60,6 +60,12 @@ namespace mongo { bool hasField( const char* fieldname ) const { return _pattern.hasField( fieldname ); } /* + * Gets the element of this pattern corresponding to the given fieldname. + * Returns eoo if none exists. + */ + BSONElement getField( const char* fieldname ) const { return _pattern[ fieldname ]; } + + /* * Returns true if the key described by this KeyPattern is a prefix of * the (potentially) compound key described by 'other' */ @@ -75,6 +81,13 @@ namespace mongo { */ bool isSpecial() const; + /** + * Returns true if the quantities stored in this KeyPattern can be used to compute all the + * quantities in "other". Useful for determining whether an index based on one KeyPattern + * can be used as a covered index for a query based on another. + */ + bool isCoveredBy( const KeyPattern& other ) const; + string toString() const{ return toBSON().toString(); } /* Given a document, extracts the index key corresponding to this KeyPattern @@ -92,7 +105,6 @@ namespace mongo { */ BSONObj extractSingleKey( const BSONObj& doc ) const; - /**@param queryConstraints a FieldRangeSet, usually formed from parsing a query * @return an ordered list of bounds generated using this KeyPattern and the * constraints from the FieldRangeSet. This function is used in sharding to |