summaryrefslogtreecommitdiff
path: root/src/mongo/db/dbhelpers.h
diff options
context:
space:
mode:
authorKevin Matulef <matulef@gmail.com>2012-12-27 04:19:41 -0500
committerKevin Matulef <matulef@gmail.com>2012-12-27 04:19:52 -0500
commit871d874036a841253cd7c8d6b1d31f506d8099eb (patch)
tree00c6ac680574cb3d193f5a62ed7c7f48a37ec9af /src/mongo/db/dbhelpers.h
parenta02754295ab258f2d10f1c1d668c3f24c633afb1 (diff)
downloadmongo-871d874036a841253cd7c8d6b1d31f506d8099eb.tar.gz
SERVER-7668 further cleanup related to extending range bounds
This removes the complicated modifiedRangeBound method in dbhelpers.h/cpp and replaces it with calls to the extendRangeBound method defined in the previous SERVER-7668 patch, as well as the toKeyFormat method. The latter has been split into two functions, toKeyFormat and inferKeyPattern, which have more intuitive behavior.
Diffstat (limited to 'src/mongo/db/dbhelpers.h')
-rw-r--r--src/mongo/db/dbhelpers.h37
1 files changed, 8 insertions, 29 deletions
diff --git a/src/mongo/db/dbhelpers.h b/src/mongo/db/dbhelpers.h
index ff479bc1d11..9474289bfc6 100644
--- a/src/mongo/db/dbhelpers.h
+++ b/src/mongo/db/dbhelpers.h
@@ -108,38 +108,17 @@ namespace mongo {
// TODO: this should be somewhere else probably
/* Takes object o, and returns a new object with the
- * same field elements but the names stripped out. Also,
- * fills in "key" with an ascending keyPattern that matches o
+ * same field elements but the names stripped out.
* Example:
- * o = {a : 5 , b : 6} -->
- * sets key= {a : 1, b :1}, returns {"" : 5, "" : 6}
+ * o = {a : 5 , b : 6} --> {"" : 5, "" : 6}
*/
- static BSONObj toKeyFormat( const BSONObj& o , BSONObj& key );
-
- /* Takes a BSONObj indicating the min or max boundary of a range,
- * and a keyPattern corresponding to an index that is useful
- * for locating items in the range, and returns an "extension"
- * of the bound, modified to fit the given pattern. In other words,
- * it appends MinKey or MaxKey values to the bound, so that the extension
- * has the same number of fields as keyPattern.
- * minOrMax should be -1/+1 to indicate whether the extension
- * corresponds to the min or max bound for the range.
- * Also, strips out the field names to put the bound in key format.
- * Examples:
- * {a : 55}, {a :1}, -1 --> {"" : 55}
- * {a : 55}, {a : 1, b : 1}, -1 -> {"" : 55, "" : minKey}
- * {a : 55}, {a : 1, b : 1}, 1 -> {"" : 55, "" : maxKey}
- * {a : 55}, {a : 1, b : -1}, -1 -> {"" : 55, "" : maxKey}
- * {a : 55}, {a : 1, b : -1}, 1 -> {"" : 55, "" : minKey}
- *
- * This function is useful for modifying chunk ranges in sharding,
- * when the shard key is a prefix of the index actually used
- * (also useful when the shard key is equal to the index used,
- * since it strips out the field names).
+ static BSONObj toKeyFormat( const BSONObj& o );
+
+ /* Takes object o, and infers an ascending keyPattern with the same fields as o
+ * Example:
+ * o = {a : 5 , b : 6} --> {a : 1 , b : 1 }
*/
- static BSONObj modifiedRangeBound( const BSONObj& bound ,
- const BSONObj& keyPattern ,
- int minOrMax );
+ static BSONObj inferKeyPattern( const BSONObj& o );
class RemoveCallback {
public: