diff options
author | gregs <greg@10gen.com> | 2011-03-30 16:52:55 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-04-20 12:06:57 -0400 |
commit | d29d02b69473c568cecc12360102ede3a0bc41f5 (patch) | |
tree | 5d2b38653ca474b7c86002f3a8a9a96d8cf93274 | |
parent | 2e3f27c3f9654205ecbea2ce28367c138b7282d0 (diff) | |
download | mongo-d29d02b69473c568cecc12360102ede3a0bc41f5.tar.gz |
only add covered matcher manually if a matcher does not exist SERVER-1742
-rw-r--r-- | db/cursor.h | 2 | ||||
-rw-r--r-- | db/geo/2d.cpp | 7 | ||||
-rw-r--r-- | db/query.cpp | 2 | ||||
-rw-r--r-- | db/queryoptimizer.h | 3 |
4 files changed, 12 insertions, 2 deletions
diff --git a/db/cursor.h b/db/cursor.h index 9797d668dbc..d17b698b6f1 100644 --- a/db/cursor.h +++ b/db/cursor.h @@ -113,6 +113,8 @@ namespace mongo { // The implementation may return different matchers depending on the // position of the cursor. If matcher() is nonzero at the start, // matcher() should be checked each time advance() is called. + // Implementations which generate their own matcher should return this + // to avoid a matcher being set manually. virtual CoveredIndexMatcher *matcher() const { return 0; } // A convenience function for setting the value of matcher() manually diff --git a/db/geo/2d.cpp b/db/geo/2d.cpp index 934ee804982..d6c97f6173e 100644 --- a/db/geo/2d.cpp +++ b/db/geo/2d.cpp @@ -1144,6 +1144,10 @@ namespace mongo { virtual long long nscanned() { return _nscanned; } + virtual CoveredIndexMatcher *matcher() const { + return _s->_hopper->_matcher.get(); + } + shared_ptr<GeoSearch> _s; GeoHopper::Holder::iterator _cur; GeoHopper::Holder::iterator _end; @@ -1212,6 +1216,9 @@ namespace mongo { virtual DiskLoc currLoc() { assert(ok()); return _cur._loc; } virtual BSONObj currKey() const { return _cur._key; } + virtual CoveredIndexMatcher *matcher() const { + return _matcher.get(); + } virtual bool moreToDo() = 0; virtual void fillStack() = 0; diff --git a/db/query.cpp b/db/query.cpp index 7f23ac8aee3..671e7146898 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -1163,7 +1163,7 @@ namespace mongo { cc = new ClientCursor(queryOptions, multi, ns, jsobj.getOwned()); } else { - cursor->setMatcher( dqo.matcher() ); + if( ! cursor->matcher() ) cursor->setMatcher( dqo.matcher() ); cc = new ClientCursor( queryOptions, cursor, ns, jsobj.getOwned() ); } cursorid = cc->cursorid(); diff --git a/db/queryoptimizer.h b/db/queryoptimizer.h index cf3180a5bc8..ebd264e12a0 100644 --- a/db/queryoptimizer.h +++ b/db/queryoptimizer.h @@ -449,7 +449,8 @@ namespace mongo { auto_ptr< FieldRangeSet > frs( new FieldRangeSet( ns, query ) ); auto_ptr< FieldRangeSet > origFrs( new FieldRangeSet( *frs ) ); shared_ptr< Cursor > ret = QueryPlanSet( ns, frs, origFrs, query, sort ).getBestGuess()->newCursor(); - if ( !query.isEmpty() ) { + // If we don't already have a matcher, supply one. + if ( !query.isEmpty() && ! ret->matcher() ) { shared_ptr< CoveredIndexMatcher > matcher( new CoveredIndexMatcher( query, ret->indexKeyPattern() ) ); ret->setMatcher( matcher ); } |