diff options
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 |