mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
compile sharding
This commit is contained in:
parent
144919657e
commit
c8e0f33f3f
@ -593,7 +593,7 @@ namespace mongo {
|
||||
if ( !order.isEmpty() || ( hint && !hint->eoo() ) || !min.isEmpty() || !max.isEmpty() || !_fros.getSpecial().empty() ) {
|
||||
_or = false;
|
||||
}
|
||||
if ( _or && _fros.uselessOr() ) {
|
||||
if ( _or && uselessOr() ) {
|
||||
_or = false;
|
||||
}
|
||||
// if _or == false, don't use or clauses for index selection
|
||||
@ -630,7 +630,27 @@ namespace mongo {
|
||||
ret = runOpOnce( *ret );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
bool MultiPlanScanner::uselessOr() const {
|
||||
vector< BSONObj > ret;
|
||||
_fros.allClausesSimplified( ret );
|
||||
for( vector< BSONObj >::const_iterator i = ret.begin(); i != ret.end(); ++i ) {
|
||||
bool useful = false;
|
||||
NamespaceDetails::IndexIterator j = nsdetails( _ns )->ii();
|
||||
while( j.more() ) {
|
||||
IndexDetails &id = j.next();
|
||||
if ( id.getSpec().suitability( *i, BSONObj() ) != USELESS ) {
|
||||
useful = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !useful ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool indexWorks( const BSONObj &idxPattern, const BSONObj &sampleKey, int direction, int firstSignificantField ) {
|
||||
BSONObjIterator p( idxPattern );
|
||||
|
@ -274,6 +274,7 @@ namespace mongo {
|
||||
void assertNotOr() const {
|
||||
massert( 13266, "not implemented for $or query", !_or );
|
||||
}
|
||||
bool uselessOr() const;
|
||||
const char * _ns;
|
||||
bool _or;
|
||||
BSONObj _query;
|
||||
|
@ -621,24 +621,6 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
|
||||
bool FieldRangeOrSet::uselessOr() const {
|
||||
for( list< FieldRangeSet >::const_iterator i = _orSets.begin(); i != _orSets.end(); ++i ) {
|
||||
bool useful = false;
|
||||
NamespaceDetails::IndexIterator j = nsdetails( _baseSet.ns() )->ii();
|
||||
while( j.more() ) {
|
||||
IndexDetails &id = j.next();
|
||||
if ( id.getSpec().suitability( i->simplifiedQuery(), BSONObj() ) != USELESS ) {
|
||||
useful = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !useful ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
FieldRange *FieldRangeSet::trivialRange_ = 0;
|
||||
FieldRange &FieldRangeSet::trivialRange() {
|
||||
if ( trivialRange_ == 0 )
|
||||
|
@ -244,7 +244,6 @@ namespace mongo {
|
||||
public:
|
||||
FieldRangeOrSet( const char *ns, const BSONObj &query , bool optimize=true );
|
||||
// if there's a useless or clause, we won't use or ranges to help with scanning
|
||||
bool uselessOr() const;
|
||||
bool orFinished() const { return _orFound && _orSets.empty(); }
|
||||
// removes first or clause, and removes the field ranges it covers from all subsequent or clauses
|
||||
// this could invalidate the result of the last topFrs()
|
||||
@ -269,6 +268,11 @@ namespace mongo {
|
||||
*ret &= _orSets.front();
|
||||
return ret;
|
||||
}
|
||||
void allClausesSimplified( vector< BSONObj > &ret ) const {
|
||||
for( list< FieldRangeSet >::const_iterator i = _orSets.begin(); i != _orSets.end(); ++i ) {
|
||||
ret.push_back( i->simplifiedQuery() );
|
||||
}
|
||||
}
|
||||
string getSpecial() const { return _baseSet.getSpecial(); }
|
||||
private:
|
||||
FieldRangeSet _baseSet;
|
||||
|
Loading…
Reference in New Issue
Block a user