diff options
author | Kevin Matulef <matulef@gmail.com> | 2012-12-27 03:50:15 -0500 |
---|---|---|
committer | Kevin Matulef <matulef@gmail.com> | 2012-12-27 03:51:48 -0500 |
commit | a02754295ab258f2d10f1c1d668c3f24c633afb1 (patch) | |
tree | e5875f8255a65ac9665fa13091a34cfe31ff45f7 /src/mongo/db/keypattern.h | |
parent | db368e2aa0e520e835416c3dde8668da7dd1366f (diff) | |
download | mongo-a02754295ab258f2d10f1c1d668c3f24c633afb1.tar.gz |
SERVER-7668 append MinKey instead of null when extending tag boundary
Diffstat (limited to 'src/mongo/db/keypattern.h')
-rw-r--r-- | src/mongo/db/keypattern.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mongo/db/keypattern.h b/src/mongo/db/keypattern.h index 2bf02dd7bc6..fae49bb931a 100644 --- a/src/mongo/db/keypattern.h +++ b/src/mongo/db/keypattern.h @@ -74,6 +74,31 @@ namespace mongo { return _pattern.isPrefixOf( other.toBSON() ); } + /* Takes a BSONObj whose field names are a prefix of the fields in this keyPattern, and + * outputs a new bound with MinKey values appended to match the fields in this keyPattern + * (or MaxKey values for descending -1 fields). This is useful in sharding for + * calculating chunk boundaries when tag ranges are specified on a prefix of the actual + * shard key, or for calculating index bounds when the shard key is a prefix of the actual + * index used. + * + * @param makeUpperInclusive If true, then MaxKeys instead of MinKeys will be appended, so + * that the output bound will compare *greater* than the bound being extended (note that + * -1's in the keyPattern will swap MinKey/MaxKey vals. See examples). + * + * Examples: + * If this keyPattern is {a : 1} + * extendRangeBound( {a : 55}, false) --> {a : 55} + * + * If this keyPattern is {a : 1, b : 1} + * extendRangeBound( {a : 55}, false) --> {a : 55, b : MinKey} + * extendRangeBound( {a : 55}, true ) --> {a : 55, b : MaxKey} + * + * If this keyPattern is {a : 1, b : -1} + * extendRangeBound( {a : 55}, false) --> {a : 55, b : MaxKey} + * extendRangeBound( {a : 55}, true ) --> {a : 55, b : MinKey} + */ + BSONObj extendRangeBound( const BSONObj& bound , bool makeUpperInclusive ) const; + /** * Returns true if this KeyPattern contains any computed values, (e.g. {a : "hashed"}), * and false if this KeyPattern consists of only ascending/descending fields |