summaryrefslogtreecommitdiff
path: root/src/mongo/db/keypattern.h
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2014-08-29 12:59:13 -0400
committerGreg Studer <greg@10gen.com>2014-09-03 12:13:12 -0400
commita39b938918e09bda67ea9e516101f43b9ef25a51 (patch)
tree269b9d0fa3986d175dc70c2f05893673faa00006 /src/mongo/db/keypattern.h
parent5d05a2b0767f2f6122ee509678e0df3fa36f94a7 (diff)
downloadmongo-a39b938918e09bda67ea9e516101f43b9ef25a51.tar.gz
SERVER-5022 cleanup keypattern.h and shardkey.h, remove dead code
Diffstat (limited to 'src/mongo/db/keypattern.h')
-rw-r--r--src/mongo/db/keypattern.h67
1 files changed, 6 insertions, 61 deletions
diff --git a/src/mongo/db/keypattern.h b/src/mongo/db/keypattern.h
index c4c8e849fd1..77e30b883d2 100644
--- a/src/mongo/db/keypattern.h
+++ b/src/mongo/db/keypattern.h
@@ -73,26 +73,17 @@ namespace mongo {
*/
BSONObj toBSON() const { return _pattern; }
- /*
- * Returns true if the given fieldname is the (dotted prefix of the) name of one
- * element of the (potentially) compound key described by this KeyPattern.
- */
- bool hasField( const StringData& fieldname ) const {
- return _prefixes.find( fieldname ) != _prefixes.end();
- }
-
- /*
- * 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 ]; }
-
/**
* Is the provided key pattern the index over the ID field?
* The always required ID index is always {_id: 1} or {_id: -1}.
*/
static bool isIdKeyPattern(const BSONObj& pattern);
+ /**
+ * Is the provided key pattern ordered increasing or decreasing or not?
+ */
+ static bool isOrderedKeyPattern(const BSONObj& pattern);
+
/* 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
@@ -118,21 +109,6 @@ namespace mongo {
*/
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
- * (e.g. {a : 1, b : -1}). With our current index expression language, "special" patterns
- * are any patterns that are not a simple list of field names and 1/-1 values.
- */
- 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;
-
std::string toString() const{ return toBSON().toString(); }
/**
@@ -192,41 +168,10 @@ namespace mongo {
* means some fields are unsatisfied, an empty BoundList could return.
*
*/
- static BoundList keyBounds( const BSONObj& keyPattern, const IndexBounds& indexBounds );
-
- static bool isHashed( const BSONElement& fieldExpression ) {
- return mongoutils::str::equals( fieldExpression.valuestrsafe() , "hashed" );
- }
+ static BoundList flattenBounds( const BSONObj& keyPattern, const IndexBounds& indexBounds );
private:
BSONObj _pattern;
-
- // Each field in the '_pattern' may be itself a dotted field. We store all the prefixes
- // of each field here. For instance, if a pattern is { 'a.b.c': 1, x: 1 }, we'll store
- // here 'a', 'a.b', 'a.b.c', and 'x'.
- //
- // Since we're indexing into '_pattern's field names, it must stay constant after
- // constructed.
- struct PrefixHasher {
- size_t operator()( const StringData& strData ) const {
- size_t result = 0;
- const char* p = strData.rawData();
- for (size_t len = strData.size(); len > 0; len-- ) {
- result = ( result * 131 ) + *p++;
- }
- return result;
- }
- };
- unordered_set<StringData, PrefixHasher> _prefixes;
-
- bool isAscending( const BSONElement& fieldExpression ) const {
- return ( fieldExpression.isNumber() && fieldExpression.numberInt() == 1 );
- }
-
- bool isDescending( const BSONElement& fieldExpression ) const {
- return ( fieldExpression.isNumber() && fieldExpression.numberInt() == -1 );
- }
-
};
} // namespace mongo