diff options
author | Aaron <aaron@10gen.com> | 2010-06-01 16:21:21 -0700 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2010-06-01 16:21:21 -0700 |
commit | e327eff2618d2caa9afda5c3eacb440cef23e4cd (patch) | |
tree | f6eed2182d33cb7254b32cdecac69ec46d2a3d26 /db/queryutil.h | |
parent | eb9e26c66e7676f6e7b73eeb01b1b3c2bb7bb6d6 (diff) | |
download | mongo-e327eff2618d2caa9afda5c3eacb440cef23e4cd.tar.gz |
SERVER-109 reinstate FieldRangeOrSet, make FieldRangeSet a parameter to QueryPlanSet
Diffstat (limited to 'db/queryutil.h')
-rw-r--r-- | db/queryutil.h | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/db/queryutil.h b/db/queryutil.h index f872b69465a..87f8b0750b5 100644 --- a/db/queryutil.h +++ b/db/queryutil.h @@ -208,40 +208,40 @@ namespace mongo { }; // generages FieldRangeSet objects, accounting for or clauses -// class FieldRangeOrSet { -// public: -// FieldRangeOrSet( const char *ns, const BSONObj &query , bool optimize=true ); -// // if there's a trivial or clause, we won't use or ranges to help with scanning -// bool trivialOr() const { -// for( list< FieldRangeSet >::const_iterator i = _orSets.begin(); i != _orSets.end(); ++i ) { -// if ( i->nNontrivialRanges() == 0 ) { -// return true; -// } -// } -// return false; -// } -// bool orFinished() const { return _orFound && _orSets.empty(); } -// // removes first or clause, and removes the field ranges it covers from all subsequent or clauses -// void popOrClause() { -// massert( 13274, "no or clause to pop", !orFinished() ); -// const FieldRangeSet &toPop = _orSets.front(); -// list< FieldRangeSet >::iterator i = _orSets.begin(); -// ++i; -// while( i != _orSets.end() ) { -// *i -= toPop; -// if( !i->matchPossible() ) { -// i = _orSets.erase( i ); -// } else { -// ++i; -// } -// } -// _orSets.pop_front(); -// } -// private: -// FieldRangeSet _baseSet; -// list< FieldRangeSet > _orSets; -// bool _orFound; -// }; + class FieldRangeOrSet { + public: + FieldRangeOrSet( const char *ns, const BSONObj &query , bool optimize=true ); + // if there's a trivial or clause, we won't use or ranges to help with scanning + bool trivialOr() const { + for( list< FieldRangeSet >::const_iterator i = _orSets.begin(); i != _orSets.end(); ++i ) { + if ( i->nNontrivialRanges() == 0 ) { + return true; + } + } + return false; + } + bool orFinished() const { return _orFound && _orSets.empty(); } + // removes first or clause, and removes the field ranges it covers from all subsequent or clauses + void popOrClause() { + massert( 13274, "no or clause to pop", !orFinished() ); + const FieldRangeSet &toPop = _orSets.front(); + list< FieldRangeSet >::iterator i = _orSets.begin(); + ++i; + while( i != _orSets.end() ) { + *i -= toPop; + if( !i->matchPossible() ) { + i = _orSets.erase( i ); + } else { + ++i; + } + } + _orSets.pop_front(); + } + private: + FieldRangeSet _baseSet; + list< FieldRangeSet > _orSets; + bool _orFound; + }; /** used for doing field limiting |