void ParsedQuery::init( const BSONObj& q ) { _reset(); uassert( 10105 , "bad skip value in query", _ntoskip >= 0); if ( _ntoreturn < 0 ) { /* _ntoreturn greater than zero is simply a hint on how many objects to send back per "cursor batch". A negative number indicates a hard limit. */ _wantMore = false; _ntoreturn = -_ntoreturn; } BSONElement e = q["query"]; if ( ! e.isABSONObj() ) e = q["$query"]; if ( e.isABSONObj() ) { _filter = e.embeddedObject().getOwned(); _initTop( q ); } else { _filter = q.getOwned(); } _hasReadPref = q.hasField(Query::ReadPrefField.name()); }
void ParsedQuery::init( const BSONObj& q ) { _reset(); uassert( 10105 , "bad skip value in query", _ntoskip >= 0); if ( _ntoreturn < 0 ) { /* _ntoreturn greater than zero is simply a hint on how many objects to send back per "cursor batch". A negative number indicates a hard limit. */ _wantMore = false; _ntoreturn = -_ntoreturn; } BSONElement e = q["query"]; if ( ! e.isABSONObj() ) e = q["$query"]; if ( e.isABSONObj() ) { _filter = e.embeddedObject(); _initTop( q ); } else { _filter = q; } _filter = _filter.getOwned(); // // Parse options that are valid for both queries and commands // // $readPreference _hasReadPref = q.hasField(Query::ReadPrefField.name()); // $maxTimeMS BSONElement maxTimeMSElt = q.getField("$maxTimeMS"); if (!maxTimeMSElt.eoo()) { uassert(16987, mongoutils::str::stream() << "$maxTimeMS must be a number type, instead found type: " << maxTimeMSElt.type(), maxTimeMSElt.isNumber()); } // If $maxTimeMS was not specified, _maxTimeMS is set to 0 (special value for "allow to // run indefinitely"). long long maxTimeMSLongLong = maxTimeMSElt.safeNumberLong(); uassert(16988, "$maxTimeMS out of range [0,2147483647]", maxTimeMSLongLong >= 0 && maxTimeMSLongLong <= INT_MAX); _maxTimeMS = static_cast<int>(maxTimeMSLongLong); }