summaryrefslogtreecommitdiff
path: root/src/mongo/db/queryutil.h
diff options
context:
space:
mode:
authorKevin Matulef <matulef@gmail.com>2012-10-15 02:25:12 -0400
committerKevin Matulef <matulef@gmail.com>2012-10-15 02:39:24 -0400
commit16a8e0484cfbe69c674ed6f3b7609fdc1518b50e (patch)
treef1bffbb58be9225fccc1d7b9d42b7620b04097d8 /src/mongo/db/queryutil.h
parent02e0dc4015276b787dcfc448304d978a06bec51d (diff)
downloadmongo-16a8e0484cfbe69c674ed6f3b7609fdc1518b50e.tar.gz
SERVER-2001 KeyPattern class; utilities for more general index & shard key specs
The KeyPattern class is an abstraction for defining more general expression-based keys (both index keys and shard keys). This class provide some utility functions for extracting keys based on an expression, and computing range bounds based on an expression. This patch lays the groundwork and begins to make use of KeyPatterns. The idea is that to implement more general key expressions, we will only need to enhance the functions in this class.
Diffstat (limited to 'src/mongo/db/queryutil.h')
-rw-r--r--src/mongo/db/queryutil.h33
1 files changed, 7 insertions, 26 deletions
diff --git a/src/mongo/db/queryutil.h b/src/mongo/db/queryutil.h
index bdea78b7361..32bf3541e88 100644
--- a/src/mongo/db/queryutil.h
+++ b/src/mongo/db/queryutil.h
@@ -25,6 +25,9 @@ namespace mongo {
extern const int MaxBytesToReturnToClientAtOnce;
+ //maximum number of intervals produced by $in queries.
+ static const unsigned MAX_IN_COMBINATIONS = 4000000;
+
/* This is for languages whose "objects" are not well ordered (JSON is well ordered).
[ { a : ... } , { b : ... } ] -> { a : ..., b : ... }
*/
@@ -381,15 +384,6 @@ namespace mongo {
// _elemMatchContext for the FieldRange on 'a.b' is the query
// element having field name '$elemMatch'.
};
-
- /**
- * A BoundList contains intervals specified by inclusive start
- * and end bounds. The intervals should be nonoverlapping and occur in
- * the specified direction of traversal. For example, given a simple index {i:1}
- * and direction +1, one valid BoundList is: (1, 2); (4, 6). The same BoundList
- * would be valid for index {i:-1} with direction -1.
- */
- typedef vector<pair<BSONObj,BSONObj> > BoundList;
class QueryPattern;
@@ -477,18 +471,6 @@ namespace mongo {
const FieldRangeSet &operator-=( const FieldRangeSet &other );
/** @return intersection of 'this' with 'other'. */
const FieldRangeSet &operator&=( const FieldRangeSet &other );
-
- /**
- * @return an ordered list of bounds generated using an index key pattern
- * and traversal direction.
- *
- * The value of matchPossible() should be true, otherwise this function
- * may @throw.
- *
- * NOTE This function is deprecated in the query optimizer and only
- * currently used by sharding code.
- */
- BoundList indexBounds( const BSONObj &keyPattern, int direction ) const;
/**
* @return - A new FieldRangeSet based on this FieldRangeSet, but with only
@@ -597,17 +579,16 @@ namespace mongo {
* already been scanned.
*/
FieldRangeSetPair &operator-=( const FieldRangeSet &scanned );
-
- BoundList shardKeyIndexBounds( const BSONObj &keyPattern ) const {
- return _singleKey.indexBounds( keyPattern, 1 );
- }
- bool matchPossibleForShardKey( const BSONObj &keyPattern ) const {
+ bool matchPossibleForSingleKeyFRS( const BSONObj &keyPattern ) const {
return _singleKey.matchPossibleForIndex( keyPattern );
}
BSONObj originalQuery() const { return _singleKey.originalQuery(); }
+ const FieldRangeSet getSingleKeyFRS() const { return _singleKey; }
+ const FieldRangeSet getMultiKeyFRS() const { return _singleKey; }
+
string toString() const;
private:
FieldRangeSetPair( const FieldRangeSet &singleKey, const FieldRangeSet &multiKey )