diff options
author | Aaron <aaron@10gen.com> | 2009-02-19 15:04:10 -0500 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2009-02-19 15:04:10 -0500 |
commit | 3f61af1a47ee2aa54cfac08f9146028925a20c95 (patch) | |
tree | f02ce944df9406144b029b77c464fba8320f4157 /db | |
parent | d1475ffba2399cab543d8eb4c1ce94ba649ab283 (diff) | |
download | mongo-3f61af1a47ee2aa54cfac08f9146028925a20c95.tar.gz |
Build start and end keys checkpoint
Diffstat (limited to 'db')
-rw-r--r-- | db/queryoptimizer.cpp | 8 | ||||
-rw-r--r-- | db/queryoptimizer.h | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/db/queryoptimizer.cpp b/db/queryoptimizer.cpp index 74b121cf101..343b75affd4 100644 --- a/db/queryoptimizer.cpp +++ b/db/queryoptimizer.cpp @@ -170,11 +170,15 @@ namespace mongo { bool stillOptimalIndexedQueryCount = true; set< string > orderFieldsUnindexed; order.getFieldNames( orderFieldsUnindexed ); + BSONObjBuilder lowKeyBuilder; + BSONObjBuilder highKeyBuilder; while( i.more() ) { BSONElement e = i.next(); if ( e.eoo() ) break; const FieldBound &fb = fbs.bound( e.fieldName() ); + lowKeyBuilder.appendAs( fb.lower(), "" ); + highKeyBuilder.appendAs( fb.upper(), "" ); if ( fb.nontrivial() ) ++indexedQueryCount; if ( stillOptimalIndexedQueryCount ) { @@ -202,6 +206,10 @@ namespace mongo { if ( exactIndexedQueryCount == fbs.nNontrivialBounds() ) exactKeyMatch_ = true; } + BSONObj lowKey = lowKeyBuilder.obj(); + BSONObj highKey = highKeyBuilder.obj(); + startKey_ = ( direction_ >= 0 ) ? lowKey : highKey; + endKey_ = ( direction_ >= 0 ) ? highKey : lowKey; } QueryPlanSet::QueryPlanSet( const char *ns, const BSONObj &query, const BSONObj &order, const BSONElement *hint ) : diff --git a/db/queryoptimizer.h b/db/queryoptimizer.h index a492336f8f2..cd8b228069b 100644 --- a/db/queryoptimizer.h +++ b/db/queryoptimizer.h @@ -86,12 +86,16 @@ namespace mongo { /* True if keyMatch() is true, and all matches will be equal according to woEqual() */ bool exactKeyMatch() const { return exactKeyMatch_; } int direction() const { return direction_; } + BSONObj startKey() const { return startKey_; } + BSONObj endKey() const { return endKey_; } private: bool optimal_; bool scanAndOrderRequired_; bool keyMatch_; bool exactKeyMatch_; int direction_; + BSONObj startKey_; + BSONObj endKey_; }; class QueryPlanSet { |