summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/index_filter_commands.cpp
diff options
context:
space:
mode:
authorDavid Hatch <david.hatch@mongodb.com>2016-07-22 15:03:05 -0400
committerDavid Hatch <david.hatch@mongodb.com>2016-08-02 17:36:40 -0400
commita6ed9e2e39e7860d04a7249dc7f68a085903b6bd (patch)
treed8b430d135cfcb8a28f22b6c0b3de6d997bf3ab8 /src/mongo/db/commands/index_filter_commands.cpp
parent5f9ba2374bd1ec479b150518456b5c786c313845 (diff)
downloadmongo-a6ed9e2e39e7860d04a7249dc7f68a085903b6bd.tar.gz
SERVER-24239 Refactor QuerySettings to use values instead of unowned pointer.
Diffstat (limited to 'src/mongo/db/commands/index_filter_commands.cpp')
-rw-r--r--src/mongo/db/commands/index_filter_commands.cpp40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/mongo/db/commands/index_filter_commands.cpp b/src/mongo/db/commands/index_filter_commands.cpp
index f07115c9705..b8961decc76 100644
--- a/src/mongo/db/commands/index_filter_commands.cpp
+++ b/src/mongo/db/commands/index_filter_commands.cpp
@@ -32,9 +32,9 @@
#include <sstream>
#include <string>
+#include <vector>
#include "mongo/base/init.h"
-#include "mongo/base/owned_pointer_vector.h"
#include "mongo/base/status.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/catalog/collection.h"
@@ -214,22 +214,20 @@ Status ListFilters::list(const QuerySettings& querySettings, BSONObjBuilder* bob
// }
// }
BSONArrayBuilder hintsBuilder(bob->subarrayStart("filters"));
- OwnedPointerVector<AllowedIndexEntry> entries;
- entries.mutableVector() = querySettings.getAllAllowedIndices();
- for (vector<AllowedIndexEntry*>::const_iterator i = entries.begin(); i != entries.end(); ++i) {
- AllowedIndexEntry* entry = *i;
- invariant(entry);
+ std::vector<AllowedIndexEntry> entries = querySettings.getAllAllowedIndices();
+ for (vector<AllowedIndexEntry>::const_iterator i = entries.begin(); i != entries.end(); ++i) {
+ AllowedIndexEntry entry = *i;
BSONObjBuilder hintBob(hintsBuilder.subobjStart());
- hintBob.append("query", entry->query);
- hintBob.append("sort", entry->sort);
- hintBob.append("projection", entry->projection);
- if (!entry->collation.isEmpty()) {
- hintBob.append("collation", entry->collation);
+ hintBob.append("query", entry.query);
+ hintBob.append("sort", entry.sort);
+ hintBob.append("projection", entry.projection);
+ if (!entry.collation.isEmpty()) {
+ hintBob.append("collation", entry.collation);
}
BSONArrayBuilder indexesBuilder(hintBob.subarrayStart("indexes"));
- for (vector<BSONObj>::const_iterator j = entry->indexKeyPatterns.begin();
- j != entry->indexKeyPatterns.end();
+ for (vector<BSONObj>::const_iterator j = entry.indexKeyPatterns.begin();
+ j != entry.indexKeyPatterns.end();
++j) {
const BSONObj& index = *j;
indexesBuilder.append(index);
@@ -302,8 +300,7 @@ Status ClearFilters::clear(OperationContext* txn,
// Get entries from query settings. We need to remove corresponding entries from the plan
// cache shortly.
- OwnedPointerVector<AllowedIndexEntry> entries;
- entries.mutableVector() = querySettings->getAllAllowedIndices();
+ std::vector<AllowedIndexEntry> entries = querySettings->getAllAllowedIndices();
// OK to proceed with clearing entire cache.
querySettings->clearAllowedIndices();
@@ -321,16 +318,15 @@ Status ClearFilters::clear(OperationContext* txn,
// Only way that PlanCache::remove() can fail is when the query shape has been removed from
// the cache by some other means (re-index, collection info reset, ...). This is OK since
// that's the intended effect of calling the remove() function with the key from the hint entry.
- for (vector<AllowedIndexEntry*>::const_iterator i = entries.begin(); i != entries.end(); ++i) {
- AllowedIndexEntry* entry = *i;
- invariant(entry);
+ for (vector<AllowedIndexEntry>::const_iterator i = entries.begin(); i != entries.end(); ++i) {
+ AllowedIndexEntry entry = *i;
// Create canonical query.
auto qr = stdx::make_unique<QueryRequest>(nss);
- qr->setFilter(entry->query);
- qr->setSort(entry->sort);
- qr->setProj(entry->projection);
- qr->setCollation(entry->collation);
+ qr->setFilter(entry.query);
+ qr->setSort(entry.sort);
+ qr->setProj(entry.projection);
+ qr->setCollation(entry.collation);
auto statusWithCQ = CanonicalQuery::canonicalize(txn, std::move(qr), extensionsCallback);
invariantOK(statusWithCQ.getStatus());
std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue());