summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorQingyang Chen <qingyang.chen@10gen.com>2015-06-25 13:50:50 -0400
committerQingyang Chen <qingyang.chen@10gen.com>2015-06-29 16:05:26 -0400
commit9d72fd0f2f18b66423b9107e30cf2792656d2eab (patch)
tree20a29314d23e781d0e01ce9a8e877294abe6a6de /src/mongo/db
parentd7466fbe4ec1be205945170f038bbc37737abcb1 (diff)
downloadmongo-9d72fd0f2f18b66423b9107e30cf2792656d2eab.tar.gz
SERVER-16889.5 PlanExecutor::getStats() and PlanStage::getStats() return unique_ptr
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/exec/and_hash.cpp12
-rw-r--r--src/mongo/db/exec/and_hash.h2
-rw-r--r--src/mongo/db/exec/and_sorted.cpp12
-rw-r--r--src/mongo/db/exec/and_sorted.h2
-rw-r--r--src/mongo/db/exec/cached_plan.cpp16
-rw-r--r--src/mongo/db/exec/cached_plan.h2
-rw-r--r--src/mongo/db/exec/collection_scan.cpp10
-rw-r--r--src/mongo/db/exec/collection_scan.h2
-rw-r--r--src/mongo/db/exec/count.cpp13
-rw-r--r--src/mongo/db/exec/count.h2
-rw-r--r--src/mongo/db/exec/count_scan.cpp12
-rw-r--r--src/mongo/db/exec/count_scan.h2
-rw-r--r--src/mongo/db/exec/delete.cpp12
-rw-r--r--src/mongo/db/exec/delete.h2
-rw-r--r--src/mongo/db/exec/distinct_scan.cpp10
-rw-r--r--src/mongo/db/exec/distinct_scan.h2
-rw-r--r--src/mongo/db/exec/eof.cpp7
-rw-r--r--src/mongo/db/exec/eof.h2
-rw-r--r--src/mongo/db/exec/fetch.cpp12
-rw-r--r--src/mongo/db/exec/fetch.h2
-rw-r--r--src/mongo/db/exec/group.cpp13
-rw-r--r--src/mongo/db/exec/group.h2
-rw-r--r--src/mongo/db/exec/idhack.cpp10
-rw-r--r--src/mongo/db/exec/idhack.h2
-rw-r--r--src/mongo/db/exec/index_scan.cpp10
-rw-r--r--src/mongo/db/exec/index_scan.h2
-rw-r--r--src/mongo/db/exec/keep_mutations.cpp12
-rw-r--r--src/mongo/db/exec/keep_mutations.h2
-rw-r--r--src/mongo/db/exec/limit.cpp12
-rw-r--r--src/mongo/db/exec/limit.h2
-rw-r--r--src/mongo/db/exec/merge_sort.cpp14
-rw-r--r--src/mongo/db/exec/merge_sort.h2
-rw-r--r--src/mongo/db/exec/multi_iterator.cpp15
-rw-r--r--src/mongo/db/exec/multi_iterator.h2
-rw-r--r--src/mongo/db/exec/multi_plan.cpp14
-rw-r--r--src/mongo/db/exec/multi_plan.h2
-rw-r--r--src/mongo/db/exec/near.cpp9
-rw-r--r--src/mongo/db/exec/near.h2
-rw-r--r--src/mongo/db/exec/oplogstart.cpp13
-rw-r--r--src/mongo/db/exec/oplogstart.h2
-rw-r--r--src/mongo/db/exec/or.cpp12
-rw-r--r--src/mongo/db/exec/or.h2
-rw-r--r--src/mongo/db/exec/pipeline_proxy.cpp13
-rw-r--r--src/mongo/db/exec/pipeline_proxy.h2
-rw-r--r--src/mongo/db/exec/plan_stage.h4
-rw-r--r--src/mongo/db/exec/projection.cpp16
-rw-r--r--src/mongo/db/exec/projection.h2
-rw-r--r--src/mongo/db/exec/queued_data_stage.cpp10
-rw-r--r--src/mongo/db/exec/queued_data_stage.h2
-rw-r--r--src/mongo/db/exec/shard_filter.cpp13
-rw-r--r--src/mongo/db/exec/shard_filter.h2
-rw-r--r--src/mongo/db/exec/skip.cpp12
-rw-r--r--src/mongo/db/exec/skip.h2
-rw-r--r--src/mongo/db/exec/sort.cpp14
-rw-r--r--src/mongo/db/exec/sort.h2
-rw-r--r--src/mongo/db/exec/subplan.cpp12
-rw-r--r--src/mongo/db/exec/subplan.h2
-rw-r--r--src/mongo/db/exec/text.cpp12
-rw-r--r--src/mongo/db/exec/text.h2
-rw-r--r--src/mongo/db/exec/update.cpp14
-rw-r--r--src/mongo/db/exec/update.h2
-rw-r--r--src/mongo/db/query/explain.cpp2
-rw-r--r--src/mongo/db/query/plan_executor.cpp12
-rw-r--r--src/mongo/db/query/plan_executor.h4
-rw-r--r--src/mongo/db/query/plan_ranker.cpp2
65 files changed, 255 insertions, 195 deletions
diff --git a/src/mongo/db/exec/and_hash.cpp b/src/mongo/db/exec/and_hash.cpp
index 71084b40a31..eb3d6412ca5 100644
--- a/src/mongo/db/exec/and_hash.cpp
+++ b/src/mongo/db/exec/and_hash.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/exec/working_set.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/mongoutils/str.h"
namespace {
@@ -46,6 +47,7 @@ namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
const size_t AndHashStage::kLookAheadWorks = 10;
@@ -502,19 +504,19 @@ vector<PlanStage*> AndHashStage::getChildren() const {
return _children;
}
-PlanStageStats* AndHashStage::getStats() {
+unique_ptr<PlanStageStats> AndHashStage::getStats() {
_commonStats.isEOF = isEOF();
_specificStats.memLimit = _maxMemUsage;
_specificStats.memUsage = _memUsage;
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_AND_HASH));
- ret->specific.reset(new AndHashStats(_specificStats));
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_AND_HASH);
+ ret->specific = make_unique<AndHashStats>(_specificStats);
for (size_t i = 0; i < _children.size(); ++i) {
- ret->children.push_back(_children[i]->getStats());
+ ret->children.push_back(_children[i]->getStats().release());
}
- return ret.release();
+ return ret;
}
const CommonStats* AndHashStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/and_hash.h b/src/mongo/db/exec/and_hash.h
index efe625619db..974c940acda 100644
--- a/src/mongo/db/exec/and_hash.h
+++ b/src/mongo/db/exec/and_hash.h
@@ -81,7 +81,7 @@ public:
return STAGE_AND_HASH;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/and_sorted.cpp b/src/mongo/db/exec/and_sorted.cpp
index 27966791c87..0d9beeea8bb 100644
--- a/src/mongo/db/exec/and_sorted.cpp
+++ b/src/mongo/db/exec/and_sorted.cpp
@@ -31,6 +31,7 @@
#include "mongo/db/exec/and_common-inl.h"
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set_common.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
@@ -38,6 +39,7 @@ namespace mongo {
using std::unique_ptr;
using std::numeric_limits;
using std::vector;
+using stdx::make_unique;
// static
const char* AndSortedStage::kStageType = "AND_SORTED";
@@ -300,16 +302,16 @@ vector<PlanStage*> AndSortedStage::getChildren() const {
return _children;
}
-PlanStageStats* AndSortedStage::getStats() {
+unique_ptr<PlanStageStats> AndSortedStage::getStats() {
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_AND_SORTED));
- ret->specific.reset(new AndSortedStats(_specificStats));
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_AND_SORTED);
+ ret->specific = make_unique<AndSortedStats>(_specificStats);
for (size_t i = 0; i < _children.size(); ++i) {
- ret->children.push_back(_children[i]->getStats());
+ ret->children.push_back(_children[i]->getStats().release());
}
- return ret.release();
+ return ret;
}
const CommonStats* AndSortedStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/and_sorted.h b/src/mongo/db/exec/and_sorted.h
index 3a25aa8456e..cda1fa52a28 100644
--- a/src/mongo/db/exec/and_sorted.h
+++ b/src/mongo/db/exec/and_sorted.h
@@ -71,7 +71,7 @@ public:
return STAGE_AND_SORTED;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/cached_plan.cpp b/src/mongo/db/exec/cached_plan.cpp
index 78894d28d35..6888b309039 100644
--- a/src/mongo/db/exec/cached_plan.cpp
+++ b/src/mongo/db/exec/cached_plan.cpp
@@ -44,6 +44,7 @@
#include "mongo/db/query/query_knobs.h"
#include "mongo/db/query/query_planner.h"
#include "mongo/db/query/stage_builder.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
@@ -327,14 +328,15 @@ std::vector<PlanStage*> CachedPlanStage::getChildren() const {
return {_root.get()};
}
-PlanStageStats* CachedPlanStage::getStats() {
+std::unique_ptr<PlanStageStats> CachedPlanStage::getStats() {
_commonStats.isEOF = isEOF();
- std::unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_CACHED_PLAN));
- ret->specific.reset(new CachedPlanStats(_specificStats));
- ret->children.push_back(_root->getStats());
+ std::unique_ptr<PlanStageStats> ret =
+ stdx::make_unique<PlanStageStats>(_commonStats, STAGE_CACHED_PLAN);
+ ret->specific = stdx::make_unique<CachedPlanStats>(_specificStats);
+ ret->children.push_back(_root->getStats().release());
- return ret.release();
+ return ret;
}
const CommonStats* CachedPlanStage::getCommonStats() const {
@@ -346,8 +348,8 @@ const SpecificStats* CachedPlanStage::getSpecificStats() const {
}
void CachedPlanStage::updatePlanCache() {
- std::unique_ptr<PlanCacheEntryFeedback> feedback(new PlanCacheEntryFeedback());
- feedback->stats.reset(getStats());
+ std::unique_ptr<PlanCacheEntryFeedback> feedback = stdx::make_unique<PlanCacheEntryFeedback>();
+ feedback->stats = std::move(getStats());
feedback->score = PlanRanker::scoreTree(feedback->stats.get());
PlanCache* cache = _collection->infoCache()->getPlanCache();
diff --git a/src/mongo/db/exec/cached_plan.h b/src/mongo/db/exec/cached_plan.h
index 937b18a8ad2..02f92350549 100644
--- a/src/mongo/db/exec/cached_plan.h
+++ b/src/mongo/db/exec/cached_plan.h
@@ -75,7 +75,7 @@ public:
return STAGE_CACHED_PLAN;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/collection_scan.cpp b/src/mongo/db/exec/collection_scan.cpp
index f0e09f31629..d7e138b99c8 100644
--- a/src/mongo/db/exec/collection_scan.cpp
+++ b/src/mongo/db/exec/collection_scan.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/storage/record_fetcher.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
@@ -48,6 +49,7 @@ namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* CollectionScan::kStageType = "COLLSCAN";
@@ -238,7 +240,7 @@ vector<PlanStage*> CollectionScan::getChildren() const {
return empty;
}
-PlanStageStats* CollectionScan::getStats() {
+unique_ptr<PlanStageStats> CollectionScan::getStats() {
// Add a BSON representation of the filter to the stats tree, if there is one.
if (NULL != _filter) {
BSONObjBuilder bob;
@@ -246,9 +248,9 @@ PlanStageStats* CollectionScan::getStats() {
_commonStats.filter = bob.obj();
}
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_COLLSCAN));
- ret->specific.reset(new CollectionScanStats(_specificStats));
- return ret.release();
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_COLLSCAN);
+ ret->specific = make_unique<CollectionScanStats>(_specificStats);
+ return ret;
}
const CommonStats* CollectionScan::getCommonStats() const {
diff --git a/src/mongo/db/exec/collection_scan.h b/src/mongo/db/exec/collection_scan.h
index ec3ffe63bea..e2a3349847f 100644
--- a/src/mongo/db/exec/collection_scan.h
+++ b/src/mongo/db/exec/collection_scan.h
@@ -67,7 +67,7 @@ public:
return STAGE_COLLSCAN;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/count.cpp b/src/mongo/db/exec/count.cpp
index 092c36dfc03..55e080d8c14 100644
--- a/src/mongo/db/exec/count.cpp
+++ b/src/mongo/db/exec/count.cpp
@@ -33,11 +33,13 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set_common.h"
+#include "mongo/stdx/memory.h"
namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* CountStage::kStageType = "COUNT";
@@ -193,15 +195,14 @@ vector<PlanStage*> CountStage::getChildren() const {
return children;
}
-PlanStageStats* CountStage::getStats() {
+unique_ptr<PlanStageStats> CountStage::getStats() {
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_COUNT));
- CountStats* countStats = new CountStats(_specificStats);
- ret->specific.reset(countStats);
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_COUNT);
+ ret->specific = make_unique<CountStats>(_specificStats);
if (_child.get()) {
- ret->children.push_back(_child->getStats());
+ ret->children.push_back(_child->getStats().release());
}
- return ret.release();
+ return ret;
}
const CommonStats* CountStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/count.h b/src/mongo/db/exec/count.h
index 6f5a5f4e203..1dbc4dfa0f4 100644
--- a/src/mongo/db/exec/count.h
+++ b/src/mongo/db/exec/count.h
@@ -68,7 +68,7 @@ public:
return STAGE_COUNT;
}
- PlanStageStats* getStats();
+ std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/count_scan.cpp b/src/mongo/db/exec/count_scan.cpp
index 23499102147..ccd2b7339c3 100644
--- a/src/mongo/db/exec/count_scan.cpp
+++ b/src/mongo/db/exec/count_scan.cpp
@@ -31,11 +31,13 @@
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/index/index_descriptor.h"
+#include "mongo/stdx/memory.h"
namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* CountScan::kStageType = "COUNT_SCAN";
@@ -160,14 +162,14 @@ vector<PlanStage*> CountScan::getChildren() const {
return empty;
}
-PlanStageStats* CountScan::getStats() {
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_COUNT_SCAN));
+unique_ptr<PlanStageStats> CountScan::getStats() {
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_COUNT_SCAN);
- CountScanStats* countStats = new CountScanStats(_specificStats);
+ unique_ptr<CountScanStats> countStats = make_unique<CountScanStats>(_specificStats);
countStats->keyPattern = _specificStats.keyPattern.getOwned();
- ret->specific.reset(countStats);
+ ret->specific = std::move(countStats);
- return ret.release();
+ return ret;
}
const CommonStats* CountScan::getCommonStats() const {
diff --git a/src/mongo/db/exec/count_scan.h b/src/mongo/db/exec/count_scan.h
index e00fa05e2f8..8d7afdef1b6 100644
--- a/src/mongo/db/exec/count_scan.h
+++ b/src/mongo/db/exec/count_scan.h
@@ -81,7 +81,7 @@ public:
return STAGE_COUNT_SCAN;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/delete.cpp b/src/mongo/db/exec/delete.cpp
index 31bb3aaf66f..7ff695d2180 100644
--- a/src/mongo/db/exec/delete.cpp
+++ b/src/mongo/db/exec/delete.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/op_observer.h"
#include "mongo/db/query/canonical_query.h"
#include "mongo/db/repl/replication_coordinator_global.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/log.h"
#include "mongo/util/scopeguard.h"
@@ -47,6 +48,7 @@ namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* DeleteStage::kStageType = "DELETE";
@@ -286,12 +288,12 @@ vector<PlanStage*> DeleteStage::getChildren() const {
return children;
}
-PlanStageStats* DeleteStage::getStats() {
+unique_ptr<PlanStageStats> DeleteStage::getStats() {
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_DELETE));
- ret->specific.reset(new DeleteStats(_specificStats));
- ret->children.push_back(_child->getStats());
- return ret.release();
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_DELETE);
+ ret->specific = make_unique<DeleteStats>(_specificStats);
+ ret->children.push_back(_child->getStats().release());
+ return ret;
}
const CommonStats* DeleteStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/delete.h b/src/mongo/db/exec/delete.h
index ef823781ef2..ab907557bc7 100644
--- a/src/mongo/db/exec/delete.h
+++ b/src/mongo/db/exec/delete.h
@@ -100,7 +100,7 @@ public:
return STAGE_DELETE;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/distinct_scan.cpp b/src/mongo/db/exec/distinct_scan.cpp
index 7cbe5db389e..82e87b180c0 100644
--- a/src/mongo/db/exec/distinct_scan.cpp
+++ b/src/mongo/db/exec/distinct_scan.cpp
@@ -34,11 +34,13 @@
#include "mongo/db/exec/working_set_computed_data.h"
#include "mongo/db/index/index_access_method.h"
#include "mongo/db/index/index_descriptor.h"
+#include "mongo/stdx/memory.h"
namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* DistinctScan::kStageType = "DISTINCT_SCAN";
@@ -153,10 +155,10 @@ vector<PlanStage*> DistinctScan::getChildren() const {
return empty;
}
-PlanStageStats* DistinctScan::getStats() {
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_DISTINCT_SCAN));
- ret->specific.reset(new DistinctScanStats(_specificStats));
- return ret.release();
+unique_ptr<PlanStageStats> DistinctScan::getStats() {
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_DISTINCT_SCAN);
+ ret->specific = make_unique<DistinctScanStats>(_specificStats);
+ return ret;
}
const CommonStats* DistinctScan::getCommonStats() const {
diff --git a/src/mongo/db/exec/distinct_scan.h b/src/mongo/db/exec/distinct_scan.h
index 10f850d5a2a..83b4da8c216 100644
--- a/src/mongo/db/exec/distinct_scan.h
+++ b/src/mongo/db/exec/distinct_scan.h
@@ -89,7 +89,7 @@ public:
return STAGE_DISTINCT_SCAN;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/eof.cpp b/src/mongo/db/exec/eof.cpp
index 4318e6ad9f6..a09eeaa9692 100644
--- a/src/mongo/db/exec/eof.cpp
+++ b/src/mongo/db/exec/eof.cpp
@@ -31,10 +31,13 @@
#include "mongo/db/exec/eof.h"
#include "mongo/db/exec/scoped_timer.h"
+#include "mongo/stdx/memory.h"
namespace mongo {
+using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* EOFStage::kStageType = "EOF";
@@ -71,9 +74,9 @@ vector<PlanStage*> EOFStage::getChildren() const {
return empty;
}
-PlanStageStats* EOFStage::getStats() {
+unique_ptr<PlanStageStats> EOFStage::getStats() {
_commonStats.isEOF = isEOF();
- return new PlanStageStats(_commonStats, STAGE_EOF);
+ return make_unique<PlanStageStats>(_commonStats, STAGE_EOF);
}
const CommonStats* EOFStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/eof.h b/src/mongo/db/exec/eof.h
index c81b6fdefc3..c8825ed085f 100644
--- a/src/mongo/db/exec/eof.h
+++ b/src/mongo/db/exec/eof.h
@@ -55,7 +55,7 @@ public:
return STAGE_EOF;
}
- PlanStageStats* getStats();
+ std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/fetch.cpp b/src/mongo/db/exec/fetch.cpp
index cab7655f2f0..c78ac905414 100644
--- a/src/mongo/db/exec/fetch.cpp
+++ b/src/mongo/db/exec/fetch.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/storage/record_fetcher.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/mongoutils/str.h"
@@ -43,6 +44,7 @@ namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* FetchStage::kStageType = "FETCH";
@@ -227,7 +229,7 @@ vector<PlanStage*> FetchStage::getChildren() const {
return children;
}
-PlanStageStats* FetchStage::getStats() {
+unique_ptr<PlanStageStats> FetchStage::getStats() {
_commonStats.isEOF = isEOF();
// Add a BSON representation of the filter to the stats tree, if there is one.
@@ -237,10 +239,10 @@ PlanStageStats* FetchStage::getStats() {
_commonStats.filter = bob.obj();
}
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_FETCH));
- ret->specific.reset(new FetchStats(_specificStats));
- ret->children.push_back(_child->getStats());
- return ret.release();
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_FETCH);
+ ret->specific = make_unique<FetchStats>(_specificStats);
+ ret->children.push_back(_child->getStats().release());
+ return ret;
}
const CommonStats* FetchStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/fetch.h b/src/mongo/db/exec/fetch.h
index 5fba058b730..292f3bac6b8 100644
--- a/src/mongo/db/exec/fetch.h
+++ b/src/mongo/db/exec/fetch.h
@@ -70,7 +70,7 @@ public:
return STAGE_FETCH;
}
- PlanStageStats* getStats();
+ std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/group.cpp b/src/mongo/db/exec/group.cpp
index 433b4802cdf..f9b657db9f8 100644
--- a/src/mongo/db/exec/group.cpp
+++ b/src/mongo/db/exec/group.cpp
@@ -35,11 +35,13 @@
#include "mongo/db/client_basic.h"
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set_common.h"
+#include "mongo/stdx/memory.h"
namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
namespace {
@@ -278,13 +280,12 @@ vector<PlanStage*> GroupStage::getChildren() const {
return children;
}
-PlanStageStats* GroupStage::getStats() {
+unique_ptr<PlanStageStats> GroupStage::getStats() {
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_GROUP));
- GroupStats* groupStats = new GroupStats(_specificStats);
- ret->specific.reset(groupStats);
- ret->children.push_back(_child->getStats());
- return ret.release();
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_GROUP);
+ ret->specific = make_unique<GroupStats>(_specificStats);
+ ret->children.push_back(_child->getStats().release());
+ return ret;
}
const CommonStats* GroupStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/group.h b/src/mongo/db/exec/group.h
index 49f5c881d84..6b7c0fd229c 100644
--- a/src/mongo/db/exec/group.h
+++ b/src/mongo/db/exec/group.h
@@ -100,7 +100,7 @@ public:
return STAGE_GROUP;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/idhack.cpp b/src/mongo/db/exec/idhack.cpp
index dd5c36622e1..51346ecfeb3 100644
--- a/src/mongo/db/exec/idhack.cpp
+++ b/src/mongo/db/exec/idhack.cpp
@@ -39,11 +39,13 @@
#include "mongo/db/index/btree_access_method.h"
#include "mongo/db/storage/record_fetcher.h"
#include "mongo/s/d_state.h"
+#include "mongo/stdx/memory.h"
namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* IDHackStage::kStageType = "IDHACK";
@@ -244,11 +246,11 @@ vector<PlanStage*> IDHackStage::getChildren() const {
return empty;
}
-PlanStageStats* IDHackStage::getStats() {
+unique_ptr<PlanStageStats> IDHackStage::getStats() {
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_IDHACK));
- ret->specific.reset(new IDHackStats(_specificStats));
- return ret.release();
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_IDHACK);
+ ret->specific = make_unique<IDHackStats>(_specificStats);
+ return ret;
}
const CommonStats* IDHackStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/idhack.h b/src/mongo/db/exec/idhack.h
index b4dc87c1b84..5377d83b643 100644
--- a/src/mongo/db/exec/idhack.h
+++ b/src/mongo/db/exec/idhack.h
@@ -73,7 +73,7 @@ public:
return STAGE_IDHACK;
}
- PlanStageStats* getStats();
+ std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/index_scan.cpp b/src/mongo/db/exec/index_scan.cpp
index b7a963d3fd8..396c8a32f54 100644
--- a/src/mongo/db/exec/index_scan.cpp
+++ b/src/mongo/db/exec/index_scan.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/index/index_access_method.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/query/index_bounds_builder.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/log.h"
namespace {
@@ -282,7 +283,7 @@ std::vector<PlanStage*> IndexScan::getChildren() const {
return {};
}
-PlanStageStats* IndexScan::getStats() {
+std::unique_ptr<PlanStageStats> IndexScan::getStats() {
// WARNING: this could be called even if the collection was dropped. Do not access any
// catalog information here.
@@ -302,9 +303,10 @@ PlanStageStats* IndexScan::getStats() {
_specificStats.direction = _params.direction;
}
- std::unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_IXSCAN));
- ret->specific.reset(new IndexScanStats(_specificStats));
- return ret.release();
+ std::unique_ptr<PlanStageStats> ret =
+ stdx::make_unique<PlanStageStats>(_commonStats, STAGE_IXSCAN);
+ ret->specific = stdx::make_unique<IndexScanStats>(_specificStats);
+ return ret;
}
const CommonStats* IndexScan::getCommonStats() const {
diff --git a/src/mongo/db/exec/index_scan.h b/src/mongo/db/exec/index_scan.h
index d415c3b985b..fded244ff9e 100644
--- a/src/mongo/db/exec/index_scan.h
+++ b/src/mongo/db/exec/index_scan.h
@@ -109,7 +109,7 @@ public:
return STAGE_IXSCAN;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/keep_mutations.cpp b/src/mongo/db/exec/keep_mutations.cpp
index c30d276782d..099052149ba 100644
--- a/src/mongo/db/exec/keep_mutations.cpp
+++ b/src/mongo/db/exec/keep_mutations.cpp
@@ -30,11 +30,13 @@
#include "mongo/db/exec/filter.h"
#include "mongo/db/exec/scoped_timer.h"
+#include "mongo/stdx/memory.h"
namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* KeepMutationsStage::kStageType = "KEEP_MUTATIONS";
@@ -140,12 +142,12 @@ vector<PlanStage*> KeepMutationsStage::getChildren() const {
return children;
}
-PlanStageStats* KeepMutationsStage::getStats() {
+unique_ptr<PlanStageStats> KeepMutationsStage::getStats() {
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_KEEP_MUTATIONS));
- // Takes ownership of the object returned from _child->getStats().
- ret->children.push_back(_child->getStats());
- return ret.release();
+ unique_ptr<PlanStageStats> ret =
+ make_unique<PlanStageStats>(_commonStats, STAGE_KEEP_MUTATIONS);
+ ret->children.push_back(_child->getStats().release());
+ return ret;
}
const CommonStats* KeepMutationsStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/keep_mutations.h b/src/mongo/db/exec/keep_mutations.h
index cbf9f75b928..8915d363971 100644
--- a/src/mongo/db/exec/keep_mutations.h
+++ b/src/mongo/db/exec/keep_mutations.h
@@ -62,7 +62,7 @@ public:
return STAGE_KEEP_MUTATIONS;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/limit.cpp b/src/mongo/db/exec/limit.cpp
index a62f6e863e3..adbe343eb46 100644
--- a/src/mongo/db/exec/limit.cpp
+++ b/src/mongo/db/exec/limit.cpp
@@ -30,12 +30,14 @@
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set_common.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* LimitStage::kStageType = "LIMIT";
@@ -113,12 +115,12 @@ vector<PlanStage*> LimitStage::getChildren() const {
return children;
}
-PlanStageStats* LimitStage::getStats() {
+unique_ptr<PlanStageStats> LimitStage::getStats() {
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_LIMIT));
- ret->specific.reset(new LimitStats(_specificStats));
- ret->children.push_back(_child->getStats());
- return ret.release();
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_LIMIT);
+ ret->specific = make_unique<LimitStats>(_specificStats);
+ ret->children.push_back(_child->getStats().release());
+ return ret;
}
const CommonStats* LimitStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/limit.h b/src/mongo/db/exec/limit.h
index 828b6e6c0d4..6a57f39eb6d 100644
--- a/src/mongo/db/exec/limit.h
+++ b/src/mongo/db/exec/limit.h
@@ -60,7 +60,7 @@ public:
return STAGE_LIMIT;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/merge_sort.cpp b/src/mongo/db/exec/merge_sort.cpp
index 7f0581da18c..a710171975a 100644
--- a/src/mongo/db/exec/merge_sort.cpp
+++ b/src/mongo/db/exec/merge_sort.cpp
@@ -31,14 +31,16 @@
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set.h"
#include "mongo/db/exec/working_set_common.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
-using std::unique_ptr;
using std::list;
using std::string;
+using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* MergeSortStage::kStageType = "SORT_MERGE";
@@ -267,17 +269,17 @@ vector<PlanStage*> MergeSortStage::getChildren() const {
return _children;
}
-PlanStageStats* MergeSortStage::getStats() {
+unique_ptr<PlanStageStats> MergeSortStage::getStats() {
_commonStats.isEOF = isEOF();
_specificStats.sortPattern = _pattern;
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_SORT_MERGE));
- ret->specific.reset(new MergeSortStats(_specificStats));
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_SORT_MERGE);
+ ret->specific = make_unique<MergeSortStats>(_specificStats);
for (size_t i = 0; i < _children.size(); ++i) {
- ret->children.push_back(_children[i]->getStats());
+ ret->children.push_back(_children[i]->getStats().release());
}
- return ret.release();
+ return ret;
}
const CommonStats* MergeSortStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/merge_sort.h b/src/mongo/db/exec/merge_sort.h
index 7ef6d960013..3a2700002a5 100644
--- a/src/mongo/db/exec/merge_sort.h
+++ b/src/mongo/db/exec/merge_sort.h
@@ -75,7 +75,7 @@ public:
return STAGE_SORT_MERGE;
}
- PlanStageStats* getStats();
+ std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/multi_iterator.cpp b/src/mongo/db/exec/multi_iterator.cpp
index fe955cb05af..d2c79b24ce8 100644
--- a/src/mongo/db/exec/multi_iterator.cpp
+++ b/src/mongo/db/exec/multi_iterator.cpp
@@ -33,10 +33,13 @@
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/storage/record_fetcher.h"
+#include "mongo/stdx/memory.h"
namespace mongo {
+using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
const char* MultiIteratorStage::kStageType = "MULTI_ITERATOR";
@@ -51,7 +54,7 @@ MultiIteratorStage::MultiIteratorStage(OperationContext* txn,
member->state = WorkingSetMember::LOC_AND_OWNED_OBJ;
}
-void MultiIteratorStage::addIterator(std::unique_ptr<RecordCursor> it) {
+void MultiIteratorStage::addIterator(unique_ptr<RecordCursor> it) {
_iterators.push_back(std::move(it));
}
@@ -142,11 +145,11 @@ vector<PlanStage*> MultiIteratorStage::getChildren() const {
return empty;
}
-PlanStageStats* MultiIteratorStage::getStats() {
- std::unique_ptr<PlanStageStats> ret(
- new PlanStageStats(CommonStats(kStageType), STAGE_MULTI_ITERATOR));
- ret->specific.reset(new CollectionScanStats());
- return ret.release();
+unique_ptr<PlanStageStats> MultiIteratorStage::getStats() {
+ unique_ptr<PlanStageStats> ret =
+ make_unique<PlanStageStats>(CommonStats(kStageType), STAGE_MULTI_ITERATOR);
+ ret->specific = make_unique<CollectionScanStats>();
+ return ret;
}
} // namespace mongo
diff --git a/src/mongo/db/exec/multi_iterator.h b/src/mongo/db/exec/multi_iterator.h
index ada4bc16c9a..011eb807bf7 100644
--- a/src/mongo/db/exec/multi_iterator.h
+++ b/src/mongo/db/exec/multi_iterator.h
@@ -65,7 +65,7 @@ public:
virtual void invalidate(OperationContext* txn, const RecordId& dl, InvalidationType type);
// Returns empty PlanStageStats object
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
// Not used.
virtual CommonStats* getCommonStats() const {
diff --git a/src/mongo/db/exec/multi_plan.cpp b/src/mongo/db/exec/multi_plan.cpp
index 7f82a8c3b5f..60906acc055 100644
--- a/src/mongo/db/exec/multi_plan.cpp
+++ b/src/mongo/db/exec/multi_plan.cpp
@@ -46,15 +46,17 @@
#include "mongo/db/query/plan_cache.h"
#include "mongo/db/query/plan_ranker.h"
#include "mongo/db/storage/record_fetcher.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/log.h"
namespace mongo {
-using std::unique_ptr;
using std::endl;
using std::list;
+using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* MultiPlanStage::kStageType = "MULTI_PLAN";
@@ -316,8 +318,8 @@ vector<PlanStageStats*> MultiPlanStage::generateCandidateStats() {
continue;
}
- PlanStageStats* stats = _candidates[ix].root->getStats();
- candidateStats.push_back(stats);
+ unique_ptr<PlanStageStats> stats = std::move(_candidates[ix].root->getStats());
+ candidateStats.push_back(stats.release());
}
return candidateStats.release();
@@ -487,7 +489,7 @@ vector<PlanStage*> MultiPlanStage::getChildren() const {
return children;
}
-PlanStageStats* MultiPlanStage::getStats() {
+unique_ptr<PlanStageStats> MultiPlanStage::getStats() {
if (bestPlanChosen()) {
return _candidates[_bestPlanIdx].root->getStats();
}
@@ -496,9 +498,7 @@ PlanStageStats* MultiPlanStage::getStats() {
}
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_MULTI_PLAN));
-
- return ret.release();
+ return make_unique<PlanStageStats>(_commonStats, STAGE_MULTI_PLAN);
}
const CommonStats* MultiPlanStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/multi_plan.h b/src/mongo/db/exec/multi_plan.h
index 28030fb8d34..33948ef3f53 100644
--- a/src/mongo/db/exec/multi_plan.h
+++ b/src/mongo/db/exec/multi_plan.h
@@ -80,7 +80,7 @@ public:
return STAGE_MULTI_PLAN;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/near.cpp b/src/mongo/db/exec/near.cpp
index 515120d86a6..2012ef4ff9f 100644
--- a/src/mongo/db/exec/near.cpp
+++ b/src/mongo/db/exec/near.cpp
@@ -32,11 +32,14 @@
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set_common.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/assert_util.h"
namespace mongo {
+using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
NearStage::NearStage(OperationContext* txn,
WorkingSet* workingSet,
@@ -342,10 +345,10 @@ vector<PlanStage*> NearStage::getChildren() const {
return children;
}
-PlanStageStats* NearStage::getStats() {
- PlanStageStats* statsClone = _stats->clone();
+unique_ptr<PlanStageStats> NearStage::getStats() {
+ unique_ptr<PlanStageStats> statsClone(_stats->clone());
for (size_t i = 0; i < _childrenIntervals.size(); ++i) {
- statsClone->children.push_back(_childrenIntervals[i]->covering->getStats());
+ statsClone->children.push_back(_childrenIntervals[i]->covering->getStats().release());
}
return statsClone;
}
diff --git a/src/mongo/db/exec/near.h b/src/mongo/db/exec/near.h
index 6468d5fcadb..310bae591bc 100644
--- a/src/mongo/db/exec/near.h
+++ b/src/mongo/db/exec/near.h
@@ -89,7 +89,7 @@ public:
virtual std::vector<PlanStage*> getChildren() const;
virtual StageType stageType() const;
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
virtual const SpecificStats* getSpecificStats() const;
diff --git a/src/mongo/db/exec/oplogstart.cpp b/src/mongo/db/exec/oplogstart.cpp
index d05ddfc2f44..3bff2fb885c 100644
--- a/src/mongo/db/exec/oplogstart.cpp
+++ b/src/mongo/db/exec/oplogstart.cpp
@@ -32,10 +32,13 @@
#include "mongo/db/catalog/database.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
+#include "mongo/stdx/memory.h"
namespace mongo {
+using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
const char* OplogStart::kStageType = "OPLOG_START";
@@ -209,11 +212,11 @@ void OplogStart::restoreState(OperationContext* opCtx) {
}
}
-PlanStageStats* OplogStart::getStats() {
- std::unique_ptr<PlanStageStats> ret(
- new PlanStageStats(CommonStats(kStageType), STAGE_OPLOG_START));
- ret->specific.reset(new CollectionScanStats());
- return ret.release();
+unique_ptr<PlanStageStats> OplogStart::getStats() {
+ unique_ptr<PlanStageStats> ret =
+ make_unique<PlanStageStats>(CommonStats(kStageType), STAGE_OPLOG_START);
+ ret->specific = make_unique<CollectionScanStats>();
+ return ret;
}
vector<PlanStage*> OplogStart::getChildren() const {
diff --git a/src/mongo/db/exec/oplogstart.h b/src/mongo/db/exec/oplogstart.h
index 193233a6215..98ec934ba61 100644
--- a/src/mongo/db/exec/oplogstart.h
+++ b/src/mongo/db/exec/oplogstart.h
@@ -77,7 +77,7 @@ public:
virtual std::vector<PlanStage*> getChildren() const;
// Returns empty PlanStageStats object
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
//
// Exec stats -- do not call these for the oplog start stage.
diff --git a/src/mongo/db/exec/or.cpp b/src/mongo/db/exec/or.cpp
index 2513635db1d..b0902d683d3 100644
--- a/src/mongo/db/exec/or.cpp
+++ b/src/mongo/db/exec/or.cpp
@@ -31,12 +31,14 @@
#include "mongo/db/exec/filter.h"
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set_common.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* OrStage::kStageType = "OR";
@@ -176,7 +178,7 @@ vector<PlanStage*> OrStage::getChildren() const {
return _children;
}
-PlanStageStats* OrStage::getStats() {
+unique_ptr<PlanStageStats> OrStage::getStats() {
_commonStats.isEOF = isEOF();
// Add a BSON representation of the filter to the stats tree, if there is one.
@@ -186,13 +188,13 @@ PlanStageStats* OrStage::getStats() {
_commonStats.filter = bob.obj();
}
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_OR));
- ret->specific.reset(new OrStats(_specificStats));
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_OR);
+ ret->specific = make_unique<OrStats>(_specificStats);
for (size_t i = 0; i < _children.size(); ++i) {
- ret->children.push_back(_children[i]->getStats());
+ ret->children.push_back(_children[i]->getStats().release());
}
- return ret.release();
+ return ret;
}
const CommonStats* OrStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/or.h b/src/mongo/db/exec/or.h
index 6e9250db9bd..e2bf02d491a 100644
--- a/src/mongo/db/exec/or.h
+++ b/src/mongo/db/exec/or.h
@@ -64,7 +64,7 @@ public:
return STAGE_OR;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/pipeline_proxy.cpp b/src/mongo/db/exec/pipeline_proxy.cpp
index 9ca0fe788b5..95a95f3cbb6 100644
--- a/src/mongo/db/exec/pipeline_proxy.cpp
+++ b/src/mongo/db/exec/pipeline_proxy.cpp
@@ -33,12 +33,15 @@
#include "mongo/db/pipeline/document_source.h"
#include "mongo/db/pipeline/expression_context.h"
+#include "mongo/stdx/memory.h"
namespace mongo {
using boost::intrusive_ptr;
using std::shared_ptr;
+using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
const char* PipelineProxyStage::kStageType = "PIPELINE_PROXY";
@@ -115,11 +118,11 @@ vector<PlanStage*> PipelineProxyStage::getChildren() const {
return empty;
}
-PlanStageStats* PipelineProxyStage::getStats() {
- std::unique_ptr<PlanStageStats> ret(
- new PlanStageStats(CommonStats(kStageType), STAGE_PIPELINE_PROXY));
- ret->specific.reset(new CollectionScanStats());
- return ret.release();
+unique_ptr<PlanStageStats> PipelineProxyStage::getStats() {
+ unique_ptr<PlanStageStats> ret =
+ make_unique<PlanStageStats>(CommonStats(kStageType), STAGE_PIPELINE_PROXY);
+ ret->specific = make_unique<CollectionScanStats>();
+ return ret;
}
boost::optional<BSONObj> PipelineProxyStage::getNextBson() {
diff --git a/src/mongo/db/exec/pipeline_proxy.h b/src/mongo/db/exec/pipeline_proxy.h
index ac501b70191..f40674fff38 100644
--- a/src/mongo/db/exec/pipeline_proxy.h
+++ b/src/mongo/db/exec/pipeline_proxy.h
@@ -73,7 +73,7 @@ public:
std::shared_ptr<PlanExecutor> getChildExecutor();
// Returns empty PlanStageStats object
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
// Not used.
virtual CommonStats* getCommonStats() const {
diff --git a/src/mongo/db/exec/plan_stage.h b/src/mongo/db/exec/plan_stage.h
index a096664b01d..289c99cc936 100644
--- a/src/mongo/db/exec/plan_stage.h
+++ b/src/mongo/db/exec/plan_stage.h
@@ -252,10 +252,8 @@ public:
*
* Creates plan stats tree which has the same topology as the original execution tree,
* but has a separate lifetime.
- *
- * Caller owns returned pointer.
*/
- virtual PlanStageStats* getStats() = 0;
+ virtual std::unique_ptr<PlanStageStats> getStats() = 0;
/**
* Get the CommonStats for this stage. The pointer is *not* owned by the caller.
diff --git a/src/mongo/db/exec/projection.cpp b/src/mongo/db/exec/projection.cpp
index 65ab6a1323c..50c2f71239e 100644
--- a/src/mongo/db/exec/projection.cpp
+++ b/src/mongo/db/exec/projection.cpp
@@ -36,14 +36,16 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/record_id.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
-using std::unique_ptr;
using std::endl;
+using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
static const char* kIdField = "_id";
@@ -258,16 +260,16 @@ vector<PlanStage*> ProjectionStage::getChildren() const {
return children;
}
-PlanStageStats* ProjectionStage::getStats() {
+unique_ptr<PlanStageStats> ProjectionStage::getStats() {
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_PROJECTION));
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_PROJECTION);
- ProjectionStats* projStats = new ProjectionStats(_specificStats);
+ unique_ptr<ProjectionStats> projStats = make_unique<ProjectionStats>(_specificStats);
projStats->projObj = _projObj;
- ret->specific.reset(projStats);
+ ret->specific = std::move(projStats);
- ret->children.push_back(_child->getStats());
- return ret.release();
+ ret->children.push_back(_child->getStats().release());
+ return ret;
}
const CommonStats* ProjectionStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/projection.h b/src/mongo/db/exec/projection.h
index b09ef956cd2..1810f727ce6 100644
--- a/src/mongo/db/exec/projection.h
+++ b/src/mongo/db/exec/projection.h
@@ -92,7 +92,7 @@ public:
return STAGE_PROJECTION;
}
- PlanStageStats* getStats();
+ std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/queued_data_stage.cpp b/src/mongo/db/exec/queued_data_stage.cpp
index 1fffe7aba86..031460dc394 100644
--- a/src/mongo/db/exec/queued_data_stage.cpp
+++ b/src/mongo/db/exec/queued_data_stage.cpp
@@ -30,11 +30,13 @@
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set_common.h"
+#include "mongo/stdx/memory.h"
namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
const char* QueuedDataStage::kStageType = "QUEUED_DATA";
@@ -80,11 +82,11 @@ void QueuedDataStage::invalidate(OperationContext* txn, const RecordId& dl, Inva
++_commonStats.invalidates;
}
-PlanStageStats* QueuedDataStage::getStats() {
+unique_ptr<PlanStageStats> QueuedDataStage::getStats() {
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_QUEUED_DATA));
- ret->specific.reset(new MockStats(_specificStats));
- return ret.release();
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_QUEUED_DATA);
+ ret->specific = make_unique<MockStats>(_specificStats);
+ return ret;
}
const CommonStats* QueuedDataStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/queued_data_stage.h b/src/mongo/db/exec/queued_data_stage.h
index 89185f6d751..62a2d8d7bac 100644
--- a/src/mongo/db/exec/queued_data_stage.h
+++ b/src/mongo/db/exec/queued_data_stage.h
@@ -71,7 +71,7 @@ public:
// Exec stats
//
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/shard_filter.cpp b/src/mongo/db/exec/shard_filter.cpp
index 8f2f3005df1..d65ef0c0f10 100644
--- a/src/mongo/db/exec/shard_filter.cpp
+++ b/src/mongo/db/exec/shard_filter.cpp
@@ -34,12 +34,14 @@
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set_common.h"
#include "mongo/s/shard_key_pattern.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/log.h"
namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* ShardFilterStage::kStageType = "SHARDING_FILTER";
@@ -146,12 +148,13 @@ vector<PlanStage*> ShardFilterStage::getChildren() const {
return children;
}
-PlanStageStats* ShardFilterStage::getStats() {
+unique_ptr<PlanStageStats> ShardFilterStage::getStats() {
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_SHARDING_FILTER));
- ret->children.push_back(_child->getStats());
- ret->specific.reset(new ShardingFilterStats(_specificStats));
- return ret.release();
+ unique_ptr<PlanStageStats> ret =
+ make_unique<PlanStageStats>(_commonStats, STAGE_SHARDING_FILTER);
+ ret->children.push_back(_child->getStats().release());
+ ret->specific = make_unique<ShardingFilterStats>(_specificStats);
+ return ret;
}
const CommonStats* ShardFilterStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/shard_filter.h b/src/mongo/db/exec/shard_filter.h
index 07b5d000bbb..cc99525bfcc 100644
--- a/src/mongo/db/exec/shard_filter.h
+++ b/src/mongo/db/exec/shard_filter.h
@@ -89,7 +89,7 @@ public:
return STAGE_SHARDING_FILTER;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/skip.cpp b/src/mongo/db/exec/skip.cpp
index 33e66178af0..2ce7925add9 100644
--- a/src/mongo/db/exec/skip.cpp
+++ b/src/mongo/db/exec/skip.cpp
@@ -29,12 +29,14 @@
#include "mongo/db/exec/skip.h"
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set_common.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* SkipStage::kStageType = "SKIP";
@@ -114,13 +116,13 @@ vector<PlanStage*> SkipStage::getChildren() const {
return children;
}
-PlanStageStats* SkipStage::getStats() {
+unique_ptr<PlanStageStats> SkipStage::getStats() {
_commonStats.isEOF = isEOF();
_specificStats.skip = _toSkip;
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_SKIP));
- ret->specific.reset(new SkipStats(_specificStats));
- ret->children.push_back(_child->getStats());
- return ret.release();
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_SKIP);
+ ret->specific = make_unique<SkipStats>(_specificStats);
+ ret->children.push_back(_child->getStats().release());
+ return ret;
}
const CommonStats* SkipStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/skip.h b/src/mongo/db/exec/skip.h
index f03d0135186..547b3bf3885 100644
--- a/src/mongo/db/exec/skip.h
+++ b/src/mongo/db/exec/skip.h
@@ -59,7 +59,7 @@ public:
return STAGE_SKIP;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/sort.cpp b/src/mongo/db/exec/sort.cpp
index 7aeef7ee68b..246462f953c 100644
--- a/src/mongo/db/exec/sort.cpp
+++ b/src/mongo/db/exec/sort.cpp
@@ -41,13 +41,15 @@
#include "mongo/db/query/lite_parsed_query.h"
#include "mongo/db/query/query_knobs.h"
#include "mongo/db/query/query_planner.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/log.h"
namespace mongo {
-using std::unique_ptr;
using std::endl;
+using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* SortStage::kStageType = "SORT";
@@ -455,7 +457,7 @@ vector<PlanStage*> SortStage::getChildren() const {
return children;
}
-PlanStageStats* SortStage::getStats() {
+unique_ptr<PlanStageStats> SortStage::getStats() {
_commonStats.isEOF = isEOF();
const size_t maxBytes = static_cast<size_t>(internalQueryExecMaxBlockingSortBytes);
_specificStats.memLimit = maxBytes;
@@ -463,10 +465,10 @@ PlanStageStats* SortStage::getStats() {
_specificStats.limit = _limit;
_specificStats.sortPattern = _pattern.getOwned();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_SORT));
- ret->specific.reset(new SortStats(_specificStats));
- ret->children.push_back(_child->getStats());
- return ret.release();
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_SORT);
+ ret->specific = make_unique<SortStats>(_specificStats);
+ ret->children.push_back(_child->getStats().release());
+ return ret;
}
const CommonStats* SortStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/sort.h b/src/mongo/db/exec/sort.h
index b04a3d07e43..289ab0772b0 100644
--- a/src/mongo/db/exec/sort.h
+++ b/src/mongo/db/exec/sort.h
@@ -158,7 +158,7 @@ public:
return STAGE_SORT;
}
- PlanStageStats* getStats();
+ std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/subplan.cpp b/src/mongo/db/exec/subplan.cpp
index 517ab49825a..352dd5ca36c 100644
--- a/src/mongo/db/exec/subplan.cpp
+++ b/src/mongo/db/exec/subplan.cpp
@@ -41,13 +41,15 @@
#include "mongo/db/query/planner_access.h"
#include "mongo/db/query/query_planner.h"
#include "mongo/db/query/stage_builder.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/log.h"
namespace mongo {
-using std::unique_ptr;
using std::endl;
+using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* SubplanStage::kStageType = "SUBPLAN";
@@ -505,11 +507,11 @@ vector<PlanStage*> SubplanStage::getChildren() const {
return children;
}
-PlanStageStats* SubplanStage::getStats() {
+unique_ptr<PlanStageStats> SubplanStage::getStats() {
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_SUBPLAN));
- ret->children.push_back(_child->getStats());
- return ret.release();
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_SUBPLAN);
+ ret->children.push_back(_child->getStats().release());
+ return ret;
}
bool SubplanStage::branchPlannedFromCache(size_t i) const {
diff --git a/src/mongo/db/exec/subplan.h b/src/mongo/db/exec/subplan.h
index ca831a1856e..fe0d322db56 100644
--- a/src/mongo/db/exec/subplan.h
+++ b/src/mongo/db/exec/subplan.h
@@ -86,7 +86,7 @@ public:
return STAGE_SUBPLAN;
}
- PlanStageStats* getStats();
+ std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/text.cpp b/src/mongo/db/exec/text.cpp
index 933e2b6aba2..2f2a41726e8 100644
--- a/src/mongo/db/exec/text.cpp
+++ b/src/mongo/db/exec/text.cpp
@@ -38,12 +38,14 @@
#include "mongo/db/exec/working_set_computed_data.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/query/internal_plans.h"
+#include "mongo/stdx/memory.h"
namespace mongo {
-using std::unique_ptr;
using std::string;
+using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
// static
const char* TextStage::kStageType = "TEXT";
@@ -177,7 +179,7 @@ vector<PlanStage*> TextStage::getChildren() const {
return empty;
}
-PlanStageStats* TextStage::getStats() {
+unique_ptr<PlanStageStats> TextStage::getStats() {
_commonStats.isEOF = isEOF();
// Add a BSON representation of the filter to the stats tree, if there is one.
@@ -187,9 +189,9 @@ PlanStageStats* TextStage::getStats() {
_commonStats.filter = bob.obj();
}
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_TEXT));
- ret->specific.reset(new TextStats(_specificStats));
- return ret.release();
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_TEXT);
+ ret->specific = make_unique<TextStats>(_specificStats);
+ return ret;
}
const CommonStats* TextStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/text.h b/src/mongo/db/exec/text.h
index 9e64621cbb7..f28b575570d 100644
--- a/src/mongo/db/exec/text.h
+++ b/src/mongo/db/exec/text.h
@@ -118,7 +118,7 @@ public:
return STAGE_TEXT;
}
- PlanStageStats* getStats();
+ std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/exec/update.cpp b/src/mongo/db/exec/update.cpp
index 021e074e197..f1552888fdb 100644
--- a/src/mongo/db/exec/update.cpp
+++ b/src/mongo/db/exec/update.cpp
@@ -41,14 +41,16 @@
#include "mongo/db/ops/update_lifecycle.h"
#include "mongo/db/query/explain.h"
#include "mongo/db/repl/replication_coordinator_global.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/log.h"
#include "mongo/util/scopeguard.h"
namespace mongo {
-using std::unique_ptr;
using std::string;
+using std::unique_ptr;
using std::vector;
+using stdx::make_unique;
namespace mb = mutablebson;
@@ -1013,12 +1015,12 @@ vector<PlanStage*> UpdateStage::getChildren() const {
return children;
}
-PlanStageStats* UpdateStage::getStats() {
+unique_ptr<PlanStageStats> UpdateStage::getStats() {
_commonStats.isEOF = isEOF();
- unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_UPDATE));
- ret->specific.reset(new UpdateStats(_specificStats));
- ret->children.push_back(_child->getStats());
- return ret.release();
+ unique_ptr<PlanStageStats> ret = make_unique<PlanStageStats>(_commonStats, STAGE_UPDATE);
+ ret->specific = make_unique<UpdateStats>(_specificStats);
+ ret->children.push_back(_child->getStats().release());
+ return ret;
}
const CommonStats* UpdateStage::getCommonStats() const {
diff --git a/src/mongo/db/exec/update.h b/src/mongo/db/exec/update.h
index a891e2df9d8..b0dda4ffc4c 100644
--- a/src/mongo/db/exec/update.h
+++ b/src/mongo/db/exec/update.h
@@ -94,7 +94,7 @@ public:
return STAGE_UPDATE;
}
- virtual PlanStageStats* getStats();
+ virtual std::unique_ptr<PlanStageStats> getStats();
virtual const CommonStats* getCommonStats() const;
diff --git a/src/mongo/db/query/explain.cpp b/src/mongo/db/query/explain.cpp
index 72c149f162b..8b0ef755a7a 100644
--- a/src/mongo/db/query/explain.cpp
+++ b/src/mongo/db/query/explain.cpp
@@ -565,7 +565,7 @@ void Explain::explainStages(PlanExecutor* exec,
// is high enough and there was a runoff between multiple plans.
unique_ptr<PlanStageStats> winningStatsTrial;
if (verbosity >= ExplainCommon::EXEC_ALL_PLANS && NULL != mps) {
- winningStatsTrial.reset(exec->getStats());
+ winningStatsTrial = std::move(exec->getStats());
invariant(winningStatsTrial.get());
}
diff --git a/src/mongo/db/query/plan_executor.cpp b/src/mongo/db/query/plan_executor.cpp
index 4290830709c..26edbc2ae60 100644
--- a/src/mongo/db/query/plan_executor.cpp
+++ b/src/mongo/db/query/plan_executor.cpp
@@ -92,7 +92,7 @@ StatusWith<unique_ptr<PlanExecutor>> PlanExecutor::make(OperationContext* opCtx,
StatusWith<unique_ptr<PlanExecutor>> PlanExecutor::make(OperationContext* opCtx,
unique_ptr<WorkingSet> ws,
unique_ptr<PlanStage> rt,
- const std::string& ns,
+ const string& ns,
YieldPolicy yieldPolicy) {
return PlanExecutor::make(
opCtx, std::move(ws), std::move(rt), nullptr, nullptr, nullptr, ns, yieldPolicy);
@@ -134,7 +134,7 @@ StatusWith<unique_ptr<PlanExecutor>> PlanExecutor::make(OperationContext* txn,
unique_ptr<QuerySolution> qs,
unique_ptr<CanonicalQuery> cq,
const Collection* collection,
- const std::string& ns,
+ const string& ns,
YieldPolicy yieldPolicy) {
unique_ptr<PlanExecutor> exec(new PlanExecutor(
txn, std::move(ws), std::move(rt), std::move(qs), std::move(cq), collection, ns));
@@ -154,7 +154,7 @@ PlanExecutor::PlanExecutor(OperationContext* opCtx,
unique_ptr<QuerySolution> qs,
unique_ptr<CanonicalQuery> cq,
const Collection* collection,
- const std::string& ns)
+ const string& ns)
: _opCtx(opCtx),
_collection(collection),
_cq(std::move(cq)),
@@ -213,7 +213,7 @@ Status PlanExecutor::pickBestPlan(YieldPolicy policy) {
PlanExecutor::~PlanExecutor() {}
// static
-std::string PlanExecutor::statestr(ExecState s) {
+string PlanExecutor::statestr(ExecState s) {
if (PlanExecutor::ADVANCED == s) {
return "ADVANCED";
} else if (PlanExecutor::IS_EOF == s) {
@@ -238,7 +238,7 @@ CanonicalQuery* PlanExecutor::getCanonicalQuery() const {
return _cq.get();
}
-PlanStageStats* PlanExecutor::getStats() const {
+unique_ptr<PlanStageStats> PlanExecutor::getStats() const {
return _root->getStats();
}
@@ -464,7 +464,7 @@ void PlanExecutor::deregisterExec() {
_safety.reset();
}
-void PlanExecutor::kill(std::string reason) {
+void PlanExecutor::kill(string reason) {
_killReason = std::move(reason);
_collection = NULL;
diff --git a/src/mongo/db/query/plan_executor.h b/src/mongo/db/query/plan_executor.h
index b0000cee181..83e0c7eb6cd 100644
--- a/src/mongo/db/query/plan_executor.h
+++ b/src/mongo/db/query/plan_executor.h
@@ -217,11 +217,11 @@ public:
/**
* Generates a tree of stats objects with a separate lifetime from the execution
- * stage tree wrapped by this PlanExecutor. The caller owns the returned pointer.
+ * stage tree wrapped by this PlanExecutor.
*
* This is OK even if we were killed.
*/
- PlanStageStats* getStats() const;
+ std::unique_ptr<PlanStageStats> getStats() const;
//
// Methods that just pass down to the PlanStage tree.
diff --git a/src/mongo/db/query/plan_ranker.cpp b/src/mongo/db/query/plan_ranker.cpp
index cd2fbde6b03..84af0fb6f39 100644
--- a/src/mongo/db/query/plan_ranker.cpp
+++ b/src/mongo/db/query/plan_ranker.cpp
@@ -83,7 +83,7 @@ size_t PlanRanker::pickBestPlan(const vector<CandidatePlan>& candidates, PlanRan
// because multi plan runner will need its own stats
// trees for explain.
for (size_t i = 0; i < candidates.size(); ++i) {
- statTrees.push_back(candidates[i].root->getStats());
+ statTrees.push_back(candidates[i].root->getStats().release());
}
// Holds (score, candidateInndex).