summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_settings.cpp
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 00:22:50 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 10:56:02 -0400
commit9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch)
tree3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/query/query_settings.cpp
parent01965cf52bce6976637ecb8f4a622aeb05ab256a (diff)
downloadmongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/query/query_settings.cpp')
-rw-r--r--src/mongo/db/query/query_settings.cpp215
1 files changed, 110 insertions, 105 deletions
diff --git a/src/mongo/db/query/query_settings.cpp b/src/mongo/db/query/query_settings.cpp
index c6b2f34fcb8..487f34ebcf9 100644
--- a/src/mongo/db/query/query_settings.cpp
+++ b/src/mongo/db/query/query_settings.cpp
@@ -32,132 +32,137 @@
namespace mongo {
- using std::vector;
-
- //
- // HintOverride
- //
-
- AllowedIndices::AllowedIndices(const std::vector<BSONObj>& indexKeyPatterns) {
- for (std::vector<BSONObj>::const_iterator i = indexKeyPatterns.begin();
- i != indexKeyPatterns.end(); ++i) {
- const BSONObj& indexKeyPattern = *i;
- this->indexKeyPatterns.push_back(indexKeyPattern.getOwned());
- }
+using std::vector;
+
+//
+// HintOverride
+//
+
+AllowedIndices::AllowedIndices(const std::vector<BSONObj>& indexKeyPatterns) {
+ for (std::vector<BSONObj>::const_iterator i = indexKeyPatterns.begin();
+ i != indexKeyPatterns.end();
+ ++i) {
+ const BSONObj& indexKeyPattern = *i;
+ this->indexKeyPatterns.push_back(indexKeyPattern.getOwned());
}
-
- AllowedIndices::~AllowedIndices() { }
-
- //
- // AllowedIndexEntry
- //
-
- AllowedIndexEntry::AllowedIndexEntry(const BSONObj& query, const BSONObj& sort,
- const BSONObj& projection,
- const std::vector<BSONObj>& indexKeyPatterns)
- : query(query.getOwned()),
- sort(sort.getOwned()),
- projection(projection.getOwned()) {
- for (std::vector<BSONObj>::const_iterator i = indexKeyPatterns.begin();
- i != indexKeyPatterns.end(); ++i) {
- const BSONObj& indexKeyPattern = *i;
- this->indexKeyPatterns.push_back(indexKeyPattern.getOwned());
- }
- }
-
- AllowedIndexEntry::~AllowedIndexEntry() { }
-
- AllowedIndexEntry* AllowedIndexEntry::clone() const {
- AllowedIndexEntry* entry = new AllowedIndexEntry(query, sort, projection, indexKeyPatterns);
- return entry;
+}
+
+AllowedIndices::~AllowedIndices() {}
+
+//
+// AllowedIndexEntry
+//
+
+AllowedIndexEntry::AllowedIndexEntry(const BSONObj& query,
+ const BSONObj& sort,
+ const BSONObj& projection,
+ const std::vector<BSONObj>& indexKeyPatterns)
+ : query(query.getOwned()), sort(sort.getOwned()), projection(projection.getOwned()) {
+ for (std::vector<BSONObj>::const_iterator i = indexKeyPatterns.begin();
+ i != indexKeyPatterns.end();
+ ++i) {
+ const BSONObj& indexKeyPattern = *i;
+ this->indexKeyPatterns.push_back(indexKeyPattern.getOwned());
}
+}
- //
- // QuerySettings
- //
-
- QuerySettings::QuerySettings() { }
-
- QuerySettings::~QuerySettings() {
- _clear();
- }
+AllowedIndexEntry::~AllowedIndexEntry() {}
- bool QuerySettings::getAllowedIndices(const PlanCacheKey& key,
- AllowedIndices** allowedIndicesOut) const {
- invariant(allowedIndicesOut);
+AllowedIndexEntry* AllowedIndexEntry::clone() const {
+ AllowedIndexEntry* entry = new AllowedIndexEntry(query, sort, projection, indexKeyPatterns);
+ return entry;
+}
- stdx::lock_guard<stdx::mutex> cacheLock(_mutex);
- AllowedIndexEntryMap::const_iterator cacheIter = _allowedIndexEntryMap.find(key);
+//
+// QuerySettings
+//
- // Nothing to do if key does not exist in query settings.
- if (cacheIter == _allowedIndexEntryMap.end()) {
- *allowedIndicesOut = NULL;
- return false;
- }
+QuerySettings::QuerySettings() {}
- AllowedIndexEntry* entry = cacheIter->second;
+QuerySettings::~QuerySettings() {
+ _clear();
+}
- // Create a AllowedIndices from entry.
- *allowedIndicesOut = new AllowedIndices(entry->indexKeyPatterns);
+bool QuerySettings::getAllowedIndices(const PlanCacheKey& key,
+ AllowedIndices** allowedIndicesOut) const {
+ invariant(allowedIndicesOut);
- return true;
- }
+ stdx::lock_guard<stdx::mutex> cacheLock(_mutex);
+ AllowedIndexEntryMap::const_iterator cacheIter = _allowedIndexEntryMap.find(key);
- std::vector<AllowedIndexEntry*> QuerySettings::getAllAllowedIndices() const {
- stdx::lock_guard<stdx::mutex> cacheLock(_mutex);
- vector<AllowedIndexEntry*> entries;
- for (AllowedIndexEntryMap::const_iterator i = _allowedIndexEntryMap.begin(); i != _allowedIndexEntryMap.end(); ++i) {
- AllowedIndexEntry* entry = i->second;
- entries.push_back(entry->clone());
- }
- return entries;
+ // Nothing to do if key does not exist in query settings.
+ if (cacheIter == _allowedIndexEntryMap.end()) {
+ *allowedIndicesOut = NULL;
+ return false;
}
- void QuerySettings::setAllowedIndices(const CanonicalQuery& canonicalQuery,
- const PlanCacheKey& key,
- const std::vector<BSONObj>& indexes) {
- const LiteParsedQuery& lpq = canonicalQuery.getParsed();
- const BSONObj& query = lpq.getFilter();
- const BSONObj& sort = lpq.getSort();
- const BSONObj& projection = lpq.getProj();
- AllowedIndexEntry* entry = new AllowedIndexEntry(query, sort, projection, indexes);
-
- stdx::lock_guard<stdx::mutex> cacheLock(_mutex);
- AllowedIndexEntryMap::iterator i = _allowedIndexEntryMap.find(key);
- // Replace existing entry.
- if (i != _allowedIndexEntryMap.end()) {
- AllowedIndexEntry* entry = i->second;
- delete entry;
- }
- _allowedIndexEntryMap[key] = entry;
- }
+ AllowedIndexEntry* entry = cacheIter->second;
- void QuerySettings::removeAllowedIndices(const PlanCacheKey& key) {
- stdx::lock_guard<stdx::mutex> cacheLock(_mutex);
- AllowedIndexEntryMap::iterator i = _allowedIndexEntryMap.find(key);
+ // Create a AllowedIndices from entry.
+ *allowedIndicesOut = new AllowedIndices(entry->indexKeyPatterns);
- // Nothing to do if key does not exist in query settings.
- if (i == _allowedIndexEntryMap.end()) {
- return;
- }
+ return true;
+}
- // Free up resources and delete entry.
+std::vector<AllowedIndexEntry*> QuerySettings::getAllAllowedIndices() const {
+ stdx::lock_guard<stdx::mutex> cacheLock(_mutex);
+ vector<AllowedIndexEntry*> entries;
+ for (AllowedIndexEntryMap::const_iterator i = _allowedIndexEntryMap.begin();
+ i != _allowedIndexEntryMap.end();
+ ++i) {
+ AllowedIndexEntry* entry = i->second;
+ entries.push_back(entry->clone());
+ }
+ return entries;
+}
+
+void QuerySettings::setAllowedIndices(const CanonicalQuery& canonicalQuery,
+ const PlanCacheKey& key,
+ const std::vector<BSONObj>& indexes) {
+ const LiteParsedQuery& lpq = canonicalQuery.getParsed();
+ const BSONObj& query = lpq.getFilter();
+ const BSONObj& sort = lpq.getSort();
+ const BSONObj& projection = lpq.getProj();
+ AllowedIndexEntry* entry = new AllowedIndexEntry(query, sort, projection, indexes);
+
+ stdx::lock_guard<stdx::mutex> cacheLock(_mutex);
+ AllowedIndexEntryMap::iterator i = _allowedIndexEntryMap.find(key);
+ // Replace existing entry.
+ if (i != _allowedIndexEntryMap.end()) {
AllowedIndexEntry* entry = i->second;
- _allowedIndexEntryMap.erase(i);
delete entry;
}
+ _allowedIndexEntryMap[key] = entry;
+}
- void QuerySettings::clearAllowedIndices() {
- stdx::lock_guard<stdx::mutex> cacheLock(_mutex);
- _clear();
+void QuerySettings::removeAllowedIndices(const PlanCacheKey& key) {
+ stdx::lock_guard<stdx::mutex> cacheLock(_mutex);
+ AllowedIndexEntryMap::iterator i = _allowedIndexEntryMap.find(key);
+
+ // Nothing to do if key does not exist in query settings.
+ if (i == _allowedIndexEntryMap.end()) {
+ return;
}
- void QuerySettings::_clear() {
- for (AllowedIndexEntryMap::const_iterator i = _allowedIndexEntryMap.begin(); i != _allowedIndexEntryMap.end(); ++i) {
- AllowedIndexEntry* entry = i->second;
- delete entry;
- }
- _allowedIndexEntryMap.clear();
+ // Free up resources and delete entry.
+ AllowedIndexEntry* entry = i->second;
+ _allowedIndexEntryMap.erase(i);
+ delete entry;
+}
+
+void QuerySettings::clearAllowedIndices() {
+ stdx::lock_guard<stdx::mutex> cacheLock(_mutex);
+ _clear();
+}
+
+void QuerySettings::_clear() {
+ for (AllowedIndexEntryMap::const_iterator i = _allowedIndexEntryMap.begin();
+ i != _allowedIndexEntryMap.end();
+ ++i) {
+ AllowedIndexEntry* entry = i->second;
+ delete entry;
}
+ _allowedIndexEntryMap.clear();
+}
} // namespace mongo