diff options
author | Aaron <aaron@10gen.com> | 2012-03-12 20:59:51 -0700 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2012-03-22 15:51:58 -0700 |
commit | 70bc2ce86c6b950d83e062c80129c4bb7103d79b (patch) | |
tree | a5365e64626afc9a9256181d2f63b3ca4f33d2c2 /src/mongo/db | |
parent | e4340b9c4338ee7829624a237e1b71d418852af8 (diff) | |
download | mongo-70bc2ce86c6b950d83e062c80129c4bb7103d79b.tar.gz |
Make MatchDetails a class.
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/commands/distinct.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/geo/2d.cpp | 4 | ||||
-rwxr-xr-x | src/mongo/db/matcher.cpp | 26 | ||||
-rw-r--r-- | src/mongo/db/matcher.h | 26 | ||||
-rw-r--r-- | src/mongo/db/matcher_covered.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/ops/query.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/ops/update.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/queryoptimizercursorimpl.cpp | 2 |
8 files changed, 40 insertions, 28 deletions
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp index fb72eb197dd..1ad2cb99b79 100644 --- a/src/mongo/db/commands/distinct.cpp +++ b/src/mongo/db/commands/distinct.cpp @@ -123,7 +123,7 @@ namespace mongo { } } - if ( loadedObject || md._loadedObject ) + if ( loadedObject || md.loadedObject() ) nscannedObjects++; cursor->advance(); diff --git a/src/mongo/db/geo/2d.cpp b/src/mongo/db/geo/2d.cpp index 2fba3fcc2d8..f49d67db5de 100644 --- a/src/mongo/db/geo/2d.cpp +++ b/src/mongo/db/geo/2d.cpp @@ -1042,7 +1042,7 @@ namespace mongo { _matchesPerfd++; - if ( details._loadedObject ) + if ( details.loadedObject() ) _objectsLoaded++; if ( ! good ) { @@ -1054,7 +1054,7 @@ namespace mongo { _matched[ node.recordLoc ] = true; - if ( ! details._loadedObject ) // don't double count + if ( ! details.loadedObject() ) // don't double count _objectsLoaded++; } diff --git a/src/mongo/db/matcher.cpp b/src/mongo/db/matcher.cpp index c49b5e84771..a6ba719d51e 100755 --- a/src/mongo/db/matcher.cpp +++ b/src/mongo/db/matcher.cpp @@ -178,6 +178,22 @@ namespace mongo { (_compareOp == BSONObj::NIN && _myset->count( staticNull.firstElement()) == 0 ); } + MatchDetails::MatchDetails() { + reset(); + } + + void MatchDetails::reset() { + _loadedObject = false; + _elemMatchKey = 0; + } + + string MatchDetails::toString() const { + stringstream ss; + ss << "loadedObject: " << _loadedObject << " "; + ss << "elemMatchKey: " << ( _elemMatchKey ? _elemMatchKey : "NULL" ) << " "; + return ss.str(); + } + void Matcher::addRegex(const char *fieldName, const char *regex, const char *flags, bool isNot) { RegexMatcher rm; @@ -729,7 +745,7 @@ namespace mongo { if (valuesMatch(z, toMatch, compareOp, em) ) { // "field.<n>" array notation was used if ( details ) - details->_elemMatchKey = z.fieldName(); + details->setElemMatchKey( z.fieldName() ); return 1; } } @@ -739,7 +755,7 @@ namespace mongo { int cmp = matchesDotted(fieldName, toMatch, eo, compareOp, em, false, details ); if ( cmp > 0 ) { if ( details ) - details->_elemMatchKey = z.fieldName(); + details->setElemMatchKey( z.fieldName() ); return 1; } else if ( cmp < 0 ) { @@ -780,14 +796,14 @@ namespace mongo { if ( z.type() == Object ) { if ( em._subMatcher->matches( z.embeddedObject() ) ) { if ( details ) - details->_elemMatchKey = z.fieldName(); + details->setElemMatchKey( z.fieldName() ); return 1; } } else if ( em._subMatcherOnPrimitives ) { if ( z.type() && em._subMatcher->matches( z.wrap( "" ) ) ) { if ( details ) - details->_elemMatchKey = z.fieldName(); + details->setElemMatchKey( z.fieldName() ); return 1; } } @@ -795,7 +811,7 @@ namespace mongo { else { if ( valuesMatch( z, toMatch, compareOp, em) ) { if ( details ) - details->_elemMatchKey = z.fieldName(); + details->setElemMatchKey( z.fieldName() ); return 1; } } diff --git a/src/mongo/db/matcher.h b/src/mongo/db/matcher.h index a07e40bc4aa..80dbfc45b56 100644 --- a/src/mongo/db/matcher.h +++ b/src/mongo/db/matcher.h @@ -87,23 +87,19 @@ namespace mongo { class Where; // used for $where javascript eval class DiskLoc; - struct MatchDetails { - MatchDetails() { - reset(); - } + class MatchDetails { + public: + MatchDetails(); + void reset(); + string toString() const; - void reset() { - _loadedObject = false; - _elemMatchKey = 0; - } - - string toString() const { - stringstream ss; - ss << "loadedObject: " << _loadedObject << " "; - ss << "elemMatchKey: " << ( _elemMatchKey ? _elemMatchKey : "NULL" ) << " "; - return ss.str(); - } + bool loadedObject() const { return _loadedObject; } + const char *elemMatchKey() const { return _elemMatchKey; } + void setLoadedObject( bool loadedObject ) { _loadedObject = loadedObject; } + void setElemMatchKey( const char *elemMatchKey ) { _elemMatchKey = elemMatchKey; } + + private: bool _loadedObject; const char * _elemMatchKey; // warning, this may go out of scope if matched object does }; diff --git a/src/mongo/db/matcher_covered.cpp b/src/mongo/db/matcher_covered.cpp index d3724d78614..04101ca96ab 100644 --- a/src/mongo/db/matcher_covered.cpp +++ b/src/mongo/db/matcher_covered.cpp @@ -74,7 +74,7 @@ namespace mongo { } if ( details ) - details->_loadedObject = true; + details->setLoadedObject( true ); bool res = _docMatcher->matches(recLoc.obj() , details ); LOG(5) << "CoveredIndexMatcher _docMatcher->matches() returns " << res << endl; diff --git a/src/mongo/db/ops/query.cpp b/src/mongo/db/ops/query.cpp index 7588324bbfe..4c746f8b71d 100644 --- a/src/mongo/db/ops/query.cpp +++ b/src/mongo/db/ops/query.cpp @@ -591,7 +591,7 @@ namespace mongo { if ( _cursor->currentMatches( &details ) ) { return true; } - _explain->noteIterate( false, false, details._loadedObject, false ); + _explain->noteIterate( false, false, details.loadedObject(), false ); return false; } diff --git a/src/mongo/db/ops/update.cpp b/src/mongo/db/ops/update.cpp index d3116f1b950..2a08682ff71 100644 --- a/src/mongo/db/ops/update.cpp +++ b/src/mongo/db/ops/update.cpp @@ -1182,8 +1182,8 @@ namespace mongo { bool forceRewrite = false; auto_ptr<ModSet> mymodset; - if ( details._elemMatchKey && mods->hasDynamicArray() ) { - useMods = mods->fixDynamicArray( details._elemMatchKey ); + if ( details.elemMatchKey() && mods->hasDynamicArray() ) { + useMods = mods->fixDynamicArray( details.elemMatchKey() ); mymodset.reset( useMods ); forceRewrite = true; } diff --git a/src/mongo/db/queryoptimizercursorimpl.cpp b/src/mongo/db/queryoptimizercursorimpl.cpp index 24a46a2580a..0e488992c7c 100644 --- a/src/mongo/db/queryoptimizercursorimpl.cpp +++ b/src/mongo/db/queryoptimizercursorimpl.cpp @@ -193,7 +193,7 @@ namespace mongo { if ( _explainPlanInfo ) { bool countableMatch = newMatch && _matchCounter.wouldCountMatch( _c->currLoc() ); _explainPlanInfo->noteIterate( countableMatch, - countableMatch || myDetails._loadedObject, *_c ); + countableMatch || myDetails.loadedObject(), *_c ); } if ( details ) *details = myDetails; |