summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/distinct.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/commands/distinct.cpp')
-rw-r--r--src/mongo/db/commands/distinct.cpp42
1 files changed, 15 insertions, 27 deletions
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp
index ce582933d7a..27769ffcfee 100644
--- a/src/mongo/db/commands/distinct.cpp
+++ b/src/mongo/db/commands/distinct.cpp
@@ -39,9 +39,9 @@
#include "mongo/db/commands.h"
#include "mongo/db/instance.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/query/get_runner.h"
+#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/query_planner_common.h"
-#include "mongo/db/query/type_explain.h"
+#include "mongo/db/query/explain.h"
#include "mongo/util/timer.h"
namespace mongo {
@@ -98,10 +98,6 @@ namespace mongo {
BSONArrayBuilder arr( bb );
BSONElementSet values;
- long long nscanned = 0; // locations looked at
- long long nscannedObjects = 0; // full objects looked at
- long long n = 0; // matches
-
Client::ReadContext ctx(txn, ns);
Collection* collection = ctx.ctx().db()->getCollection( txn, ns );
@@ -114,21 +110,20 @@ namespace mongo {
return true;
}
- Runner* rawRunner;
- Status status = getRunnerDistinct(txn, collection, query, key, &rawRunner);
+ PlanExecutor* rawExec;
+ Status status = getExecutorDistinct(txn, collection, query, key, &rawExec);
if (!status.isOK()) {
uasserted(17216, mongoutils::str::stream() << "Can't get runner for query "
<< query << ": " << status.toString());
return 0;
}
- auto_ptr<Runner> runner(rawRunner);
- const ScopedRunnerRegistration safety(runner.get());
+ auto_ptr<PlanExecutor> exec(rawExec);
+ const ScopedExecutorRegistration safety(exec.get());
- string cursorName;
BSONObj obj;
Runner::RunnerState state;
- while (Runner::RUNNER_ADVANCED == (state = runner->getNext(&obj, NULL))) {
+ while (Runner::RUNNER_ADVANCED == (state = exec->getNext(&obj, NULL))) {
// Distinct expands arrays.
//
// If our query is covered, each value of the key should be in the index key and
@@ -150,17 +145,10 @@ namespace mongo {
values.insert(x);
}
}
- TypeExplain* bareExplain;
- Status res = runner->getInfo(&bareExplain, NULL);
- if (res.isOK()) {
- auto_ptr<TypeExplain> explain(bareExplain);
- if (explain->isCursorSet()) {
- cursorName = explain->getCursor();
- }
- n = explain->getN();
- nscanned = explain->getNScanned();
- nscannedObjects = explain->getNScannedObjects();
- }
+
+ // Get summary information about the plan.
+ PlanSummaryStats stats;
+ Explain::getSummaryStats(exec.get(), &stats);
verify( start == bb.buf() );
@@ -168,11 +156,11 @@ namespace mongo {
{
BSONObjBuilder b;
- b.appendNumber( "n" , n );
- b.appendNumber( "nscanned" , nscanned );
- b.appendNumber( "nscannedObjects" , nscannedObjects );
+ b.appendNumber( "n" , stats.nReturned );
+ b.appendNumber( "nscanned" , stats.totalKeysExamined );
+ b.appendNumber( "nscannedObjects" , stats.totalDocsExamined );
b.appendNumber( "timems" , t.millis() );
- b.append( "cursor" , cursorName );
+ b.append( "planSummary" , stats.summaryStr );
result.append( "stats" , b.obj() );
}