diff --git a/db/queryoptimizer.cpp b/db/queryoptimizer.cpp index 0b84557929d..15c7807c9bf 100644 --- a/db/queryoptimizer.cpp +++ b/db/queryoptimizer.cpp @@ -743,14 +743,14 @@ doneCheckOrder: _ns( ns ), _or( !query.getField( "$or" ).eoo() ), _query( query.getOwned() ), - _fros( ns, _query ), + _org( ns, _query ), _i(), _honorRecordedPlan( honorRecordedPlan ), _bestGuessOnly( bestGuessOnly ), _hint( ( hint && !hint->eoo() ) ? hint->wrap() : BSONObj() ), _mayYield( mayYield ), _tableScanned() { - if ( !order.isEmpty() || !min.isEmpty() || !max.isEmpty() || !_fros.getSpecial().empty() ) { + if ( !order.isEmpty() || !min.isEmpty() || !max.isEmpty() || !_org.getSpecial().empty() ) { _or = false; } if ( _or && uselessOr( _hint.firstElement() ) ) { @@ -775,8 +775,8 @@ doneCheckOrder: return _currentQps->runOp( op ); } ++_i; - auto_ptr frsp( _fros.topFrsp() ); - auto_ptr originalFrsp( _fros.topFrspOriginal() ); + auto_ptr frsp( _org.topFrsp() ); + auto_ptr originalFrsp( _org.topFrspOriginal() ); BSONElement hintElt = _hint.firstElement(); _currentQps.reset( new QueryPlanSet( _ns, frsp, originalFrsp, _query, BSONObj(), &hintElt, _honorRecordedPlan, BSONObj(), BSONObj(), _bestGuessOnly, _mayYield ) ); shared_ptr ret( _currentQps->runOp( op ) ); @@ -784,7 +784,7 @@ doneCheckOrder: _tableScanned = true; } else { // If the full table was scanned, don't bother popping the last or clause. - _fros.popOrClause( ret->qp().nsd(), ret->qp().idxNo(), ret->qp().indexed() ? ret->qp().indexKey() : BSONObj() ); + _org.popOrClause( ret->qp().nsd(), ret->qp().idxNo(), ret->qp().indexed() ? ret->qp().indexKey() : BSONObj() ); } return ret; } @@ -807,9 +807,9 @@ doneCheckOrder: if ( !id ) { return true; } - return QueryUtilIndexed::uselessOr( _fros, nsd, nsd->idxNo( *id ) ); + return QueryUtilIndexed::uselessOr( _org, nsd, nsd->idxNo( *id ) ); } - return QueryUtilIndexed::uselessOr( _fros, nsd, -1 ); + return QueryUtilIndexed::uselessOr( _org, nsd, -1 ); } MultiCursor::MultiCursor( const char *ns, const BSONObj &pattern, const BSONObj &order, shared_ptr op, bool mayYield ) @@ -1090,8 +1090,8 @@ doneCheckOrder: return make_pair( BSONObj(), 0 ); } - bool QueryUtilIndexed::uselessOr( const FieldRangeOrSet &fros, NamespaceDetails *d, int hintIdx ) { - for( list::const_iterator i = fros._originalOrSets.begin(); i != fros._originalOrSets.end(); ++i ) { + bool QueryUtilIndexed::uselessOr( const OrRangeGenerator &org, NamespaceDetails *d, int hintIdx ) { + for( list::const_iterator i = org._originalOrSets.begin(); i != org._originalOrSets.end(); ++i ) { if ( hintIdx != -1 ) { if ( !indexUseful( *i, d, hintIdx, BSONObj() ) ) { return true; diff --git a/db/queryoptimizer.h b/db/queryoptimizer.h index ae9cf7e30a1..8406f609db5 100644 --- a/db/queryoptimizer.h +++ b/db/queryoptimizer.h @@ -321,7 +321,7 @@ namespace mongo { } /** @return true iff more $or clauses need to be scanned. */ - bool mayRunMore() const { return _or ? ( !_tableScanned && !_fros.orFinished() ) : _i == 0; } + bool mayRunMore() const { return _or ? ( !_tableScanned && !_org.orFinished() ) : _i == 0; } /** @return non-$or version of explain output. */ BSONObj oldExplain() const { assertNotOr(); return _currentQps->explain(); } /** @return true iff this is not a $or query and a plan is selected based on previous success of this plan. */ @@ -341,7 +341,7 @@ namespace mongo { const char * _ns; bool _or; BSONObj _query; - FieldRangeOrSet _fros; + OrRangeGenerator _org; auto_ptr _currentQps; int _i; bool _honorRecordedPlan; @@ -447,7 +447,7 @@ namespace mongo { static void clearIndexesForPatterns( const FieldRangeSetPair &frsp, const BSONObj &order ); /** Return a recorded best index for the single or multi key pattern. */ static pair< BSONObj, long long > bestIndexForPatterns( const FieldRangeSetPair &frsp, const BSONObj &order ); - static bool uselessOr( const FieldRangeOrSet& fros, NamespaceDetails *d, int hintIdx ); + static bool uselessOr( const OrRangeGenerator& org, NamespaceDetails *d, int hintIdx ); }; } // namespace mongo diff --git a/db/queryutil-inl.h b/db/queryutil-inl.h index d36f949438f..2c3a757b385 100644 --- a/db/queryutil-inl.h +++ b/db/queryutil-inl.h @@ -115,7 +115,7 @@ namespace mongo { return ret; } - inline FieldRangeSetPair *FieldRangeOrSet::topFrsp() const { + inline FieldRangeSetPair *OrRangeGenerator::topFrsp() const { FieldRangeSetPair *ret = new FieldRangeSetPair( _baseSet ); if (_orSets.size()) { *ret &= _orSets.front(); @@ -123,7 +123,7 @@ namespace mongo { return ret; } - inline FieldRangeSetPair *FieldRangeOrSet::topFrspOriginal() const { + inline FieldRangeSetPair *OrRangeGenerator::topFrspOriginal() const { FieldRangeSetPair *ret = new FieldRangeSetPair( _baseSet ); if (_originalOrSets.size()) { *ret &= _originalOrSets.front(); diff --git a/db/queryutil.cpp b/db/queryutil.cpp index ec2c7f981c0..131f3cbc853 100644 --- a/db/queryutil.cpp +++ b/db/queryutil.cpp @@ -1322,7 +1322,7 @@ namespace mongo { return b.obj(); } - FieldRangeOrSet::FieldRangeOrSet( const char *ns, const BSONObj &query , bool optimize ) + OrRangeGenerator::OrRangeGenerator( const char *ns, const BSONObj &query , bool optimize ) : _baseSet( ns, query, optimize ), _orFound() { BSONObjIterator i( _baseSet.originalQuery() ); @@ -1345,11 +1345,11 @@ namespace mongo { } } - void FieldRangeOrSet::assertMayPopOrClause() { + void OrRangeGenerator::assertMayPopOrClause() { massert( 13274, "no or clause to pop", !orFinished() ); } - void FieldRangeOrSet::popOrClause( NamespaceDetails *nsd, int idxNo, const BSONObj &keyPattern ) { + void OrRangeGenerator::popOrClause( NamespaceDetails *nsd, int idxNo, const BSONObj &keyPattern ) { assertMayPopOrClause(); auto_ptr holder; const FieldRangeSet *toDiff = &_originalOrSets.front().frsForIndex( nsd, idxNo ); @@ -1361,7 +1361,7 @@ namespace mongo { popOrClause( toDiff, nsd, idxNo, keyPattern ); } - void FieldRangeOrSet::popOrClauseSingleKey() { + void OrRangeGenerator::popOrClauseSingleKey() { assertMayPopOrClause(); FieldRangeSet *toDiff = &_originalOrSets.front()._singleKey; popOrClause( toDiff ); @@ -1377,7 +1377,7 @@ namespace mongo { * empty we do not constrain the previous clause's ranges using index keys, * which may reduce opportunities for range elimination. */ - void FieldRangeOrSet::popOrClause( const FieldRangeSet *toDiff, NamespaceDetails *d, int idxNo, const BSONObj &keyPattern ) { + void OrRangeGenerator::popOrClause( const FieldRangeSet *toDiff, NamespaceDetails *d, int idxNo, const BSONObj &keyPattern ) { list::iterator i = _orSets.begin(); list::iterator j = _originalOrSets.begin(); ++i; diff --git a/db/queryutil.h b/db/queryutil.h index e0e33a72097..62a1bdf5edd 100644 --- a/db/queryutil.h +++ b/db/queryutil.h @@ -130,7 +130,7 @@ namespace mongo { */ class FieldRangeSet { public: - friend class FieldRangeOrSet; + friend class OrRangeGenerator; friend class FieldRangeVector; FieldRangeSet( const char *ns, const BSONObj &query , bool singleKey , bool optimize=true ); @@ -277,7 +277,7 @@ namespace mongo { BSONObj simplifiedQueryForIndex( NamespaceDetails *d, int idxNo, const BSONObj &keyPattern ) const; FieldRangeSet _singleKey; FieldRangeSet _multiKey; - friend class FieldRangeOrSet; + friend class OrRangeGenerator; friend struct QueryUtilIndexed; }; @@ -373,9 +373,9 @@ namespace mongo { * for the current $or clause, in some cases by excluding ranges that were * included in a previous clause. */ - class FieldRangeOrSet { + class OrRangeGenerator { public: - FieldRangeOrSet( const char *ns, const BSONObj &query , bool optimize=true ); + OrRangeGenerator( const char *ns, const BSONObj &query , bool optimize=true ); /** * @return true iff we are done scanning $or clauses. if there's a diff --git a/s/chunk.cpp b/s/chunk.cpp index e63c38bae44..05227c02164 100644 --- a/s/chunk.cpp +++ b/s/chunk.cpp @@ -728,9 +728,9 @@ namespace mongo { rwlock lk( _lock , false ); //TODO look into FieldRangeSetOr - FieldRangeOrSet fros(_ns.c_str(), query, false); + OrRangeGenerator org(_ns.c_str(), query, false); - const string special = fros.getSpecial(); + const string special = org.getSpecial(); if (special == "2d") { BSONForEach(field, query) { if (getGtLtOp(field) == BSONObj::opNEAR) { @@ -745,7 +745,7 @@ namespace mongo { } do { - boost::scoped_ptr frsp (fros.topFrsp()); + boost::scoped_ptr frsp (org.topFrsp()); { // special case if most-significant field isn't in query FieldRange range = frsp->singleKeyRange(_key.key().firstElement().fieldName()); @@ -780,11 +780,11 @@ namespace mongo { //return; } - if (fros.moreOrClauses()) - fros.popOrClauseSingleKey(); + if (org.moreOrClauses()) + org.popOrClauseSingleKey(); } - while (fros.moreOrClauses()); + while (org.moreOrClauses()); } void ChunkManager::getShardsForRange(set& shards, const BSONObj& min, const BSONObj& max) {