diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/query/query_settings.h | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/query/query_settings.h')
-rw-r--r-- | src/mongo/db/query/query_settings.h | 193 |
1 files changed, 98 insertions, 95 deletions
diff --git a/src/mongo/db/query/query_settings.h b/src/mongo/db/query/query_settings.h index 29449167580..e1125320471 100644 --- a/src/mongo/db/query/query_settings.h +++ b/src/mongo/db/query/query_settings.h @@ -41,108 +41,111 @@ namespace mongo { +/** + * Holds allowed indices. + */ +class AllowedIndices { +private: + MONGO_DISALLOW_COPYING(AllowedIndices); + +public: + AllowedIndices(const std::vector<BSONObj>& indexKeyPatterns); + ~AllowedIndices(); + + // These are the index key patterns that + // we will use to override the indexes retrieved from + // the index catalog. + std::vector<BSONObj> indexKeyPatterns; +}; + +/** + * Value type for query settings. + * Holds: + * query shape (query, sort, projection) + * vector of index specs + */ +class AllowedIndexEntry { +private: + MONGO_DISALLOW_COPYING(AllowedIndexEntry); + +public: + AllowedIndexEntry(const BSONObj& query, + const BSONObj& sort, + const BSONObj& projection, + const std::vector<BSONObj>& indexKeyPatterns); + ~AllowedIndexEntry(); + AllowedIndexEntry* clone() const; + + // _query, _sort and _projection collectively + // represent the query shape that we are storing hint overrides for. + BSONObj query; + BSONObj sort; + BSONObj projection; + + // These are the index key patterns that + // we will use to override the indexes retrieved from + // the index catalog. + std::vector<BSONObj> indexKeyPatterns; +}; + +/** + * Holds the index filters in a collection. + */ +class QuerySettings { +private: + MONGO_DISALLOW_COPYING(QuerySettings); + +public: + QuerySettings(); + + ~QuerySettings(); + /** - * Holds allowed indices. + * Returns true and fills out allowedIndicesOut if a hint is set in the query settings + * for the query. + * Returns false and sets allowedIndicesOut to NULL otherwise. + * Caller owns AllowedIndices. */ - class AllowedIndices { - private: - MONGO_DISALLOW_COPYING(AllowedIndices); - public: - AllowedIndices(const std::vector<BSONObj>& indexKeyPatterns); - ~AllowedIndices(); - - // These are the index key patterns that - // we will use to override the indexes retrieved from - // the index catalog. - std::vector<BSONObj> indexKeyPatterns; - }; + bool getAllowedIndices(const PlanCacheKey& query, AllowedIndices** allowedIndicesOut) const; /** - * Value type for query settings. - * Holds: - * query shape (query, sort, projection) - * vector of index specs + * Returns copies all overrides for the collection.. + * Caller owns overrides in vector. */ - class AllowedIndexEntry { - private: - MONGO_DISALLOW_COPYING(AllowedIndexEntry); - public: - AllowedIndexEntry(const BSONObj& query, const BSONObj& sort, - const BSONObj& projection, - const std::vector<BSONObj>& indexKeyPatterns); - ~AllowedIndexEntry(); - AllowedIndexEntry* clone() const; - - // _query, _sort and _projection collectively - // represent the query shape that we are storing hint overrides for. - BSONObj query; - BSONObj sort; - BSONObj projection; - - // These are the index key patterns that - // we will use to override the indexes retrieved from - // the index catalog. - std::vector<BSONObj> indexKeyPatterns; - }; + std::vector<AllowedIndexEntry*> getAllAllowedIndices() const; + + /** + * Adds or replaces entry in query settings. + * If existing entry is found for the same key, + * frees resources for existing entry before replacing. + */ + void setAllowedIndices(const CanonicalQuery& canonicalQuery, + const PlanCacheKey& key, + const std::vector<BSONObj>& indexes); + + /** + * Removes single entry from query settings. No effect if query shape is not found. + */ + void removeAllowedIndices(const PlanCacheKey& canonicalQuery); + + /** + * Clears all allowed indices from query settings. + */ + void clearAllowedIndices(); + +private: + /** + * Clears entries without acquiring mutex. + */ + void _clear(); + + typedef unordered_map<PlanCacheKey, AllowedIndexEntry*> AllowedIndexEntryMap; + AllowedIndexEntryMap _allowedIndexEntryMap; /** - * Holds the index filters in a collection. + * Protects data in query settings. */ - class QuerySettings { - private: - MONGO_DISALLOW_COPYING(QuerySettings); - public: - QuerySettings(); - - ~QuerySettings(); - - /** - * Returns true and fills out allowedIndicesOut if a hint is set in the query settings - * for the query. - * Returns false and sets allowedIndicesOut to NULL otherwise. - * Caller owns AllowedIndices. - */ - bool getAllowedIndices(const PlanCacheKey& query, - AllowedIndices** allowedIndicesOut) const; - - /** - * Returns copies all overrides for the collection.. - * Caller owns overrides in vector. - */ - std::vector<AllowedIndexEntry*> getAllAllowedIndices() const; - - /** - * Adds or replaces entry in query settings. - * If existing entry is found for the same key, - * frees resources for existing entry before replacing. - */ - void setAllowedIndices(const CanonicalQuery& canonicalQuery, - const PlanCacheKey& key, - const std::vector<BSONObj>& indexes); - - /** - * Removes single entry from query settings. No effect if query shape is not found. - */ - void removeAllowedIndices(const PlanCacheKey& canonicalQuery); - - /** - * Clears all allowed indices from query settings. - */ - void clearAllowedIndices(); - - private: - /** - * Clears entries without acquiring mutex. - */ - void _clear(); - - typedef unordered_map<PlanCacheKey, AllowedIndexEntry*> AllowedIndexEntryMap; - AllowedIndexEntryMap _allowedIndexEntryMap; - - /** - * Protects data in query settings. - */ - mutable stdx::mutex _mutex; - }; + mutable stdx::mutex _mutex; +}; } // namespace mongo |