diff options
Diffstat (limited to 'src/mongo/db/query/count_request.h')
-rw-r--r-- | src/mongo/db/query/count_request.h | 103 |
1 files changed, 58 insertions, 45 deletions
diff --git a/src/mongo/db/query/count_request.h b/src/mongo/db/query/count_request.h index 0e9eb25ee30..42b654a7896 100644 --- a/src/mongo/db/query/count_request.h +++ b/src/mongo/db/query/count_request.h @@ -36,59 +36,72 @@ namespace mongo { - template<typename T> class StatusWith; +template <typename T> +class StatusWith; +/** + * A description of a request for a count operation. Copyable. + */ +class CountRequest { +public: /** - * A description of a request for a count operation. Copyable. + * Construct an empty request. */ - class CountRequest { - public: - - /** - * Construct an empty request. - */ - CountRequest(const std::string& fullNs, BSONObj query); - - const std::string& getNs() const { return _fullNs; } - const BSONObj getQuery() const { return _query; } - - long long getLimit() const { return _limit.value_or(0); } - void setLimit(long long limit) { _limit = limit; } - - long long getSkip() const { return _skip.value_or(0); } - void setSkip(long long skip) { _skip = skip; } + CountRequest(const std::string& fullNs, BSONObj query); + + const std::string& getNs() const { + return _fullNs; + } + const BSONObj getQuery() const { + return _query; + } + + long long getLimit() const { + return _limit.value_or(0); + } + void setLimit(long long limit) { + _limit = limit; + } + + long long getSkip() const { + return _skip.value_or(0); + } + void setSkip(long long skip) { + _skip = skip; + } + + const BSONObj getHint() const { + return _hint.value_or(BSONObj()); + } + void setHint(BSONObj hint); - const BSONObj getHint() const { return _hint.value_or(BSONObj()); } - void setHint(BSONObj hint); - - /** - * Constructs a BSON representation of this request, which can be used for sending it in - * commands. - */ - BSONObj toBSON() const; + /** + * Constructs a BSON representation of this request, which can be used for sending it in + * commands. + */ + BSONObj toBSON() const; - /** - * Construct a CountRequest from the command specification and db name. - */ - static StatusWith<CountRequest> parseFromBSON(const std::string& dbname, - const BSONObj& cmdObj); + /** + * Construct a CountRequest from the command specification and db name. + */ + static StatusWith<CountRequest> parseFromBSON(const std::string& dbname, const BSONObj& cmdObj); - private: - // Namespace to operate on (e.g. "foo.bar"). - const std::string _fullNs; +private: + // Namespace to operate on (e.g. "foo.bar"). + const std::string _fullNs; - // A predicate describing the set of documents to count. - const BSONObj _query; + // A predicate describing the set of documents to count. + const BSONObj _query; - // Optional. An integer limiting the number of documents to count. - boost::optional<long long> _limit; + // Optional. An integer limiting the number of documents to count. + boost::optional<long long> _limit; - // Optional. An integer indicating to not include the first n documents in the count. - boost::optional<long long> _skip; + // Optional. An integer indicating to not include the first n documents in the count. + boost::optional<long long> _skip; - // Optional. Indicates to the query planner that it should generate a count plan using a - // particular index. - boost::optional<BSONObj> _hint; - }; + // Optional. Indicates to the query planner that it should generate a count plan using a + // particular index. + boost::optional<BSONObj> _hint; +}; -} // namespace mongo +} // namespace mongo |