summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2015-02-09 14:08:26 -0500
committerDavid Storch <david.storch@10gen.com>2015-02-10 09:47:24 -0500
commit40e5c7f39b967411bba4733c445f408f906a26b5 (patch)
tree0068e16e90ca7bc5fde47fbc634937c3cd0b0b27
parenta3aad22dfdef9ee9078d2fc3b54530adb73189a8 (diff)
downloadmongo-40e5c7f39b967411bba4733c445f408f906a26b5.tar.gz
SERVER-17051 remove runCount() function
This special count path was used only by the DBDirectClient and is no longer needed.
-rw-r--r--src/mongo/db/commands/count.cpp91
-rw-r--r--src/mongo/db/commands/mr.cpp8
-rw-r--r--src/mongo/db/dbdirectclient.cpp34
-rw-r--r--src/mongo/db/dbdirectclient.h8
4 files changed, 5 insertions, 136 deletions
diff --git a/src/mongo/db/commands/count.cpp b/src/mongo/db/commands/count.cpp
index 23ff7875eaf..9b23d0cc216 100644
--- a/src/mongo/db/commands/count.cpp
+++ b/src/mongo/db/commands/count.cpp
@@ -229,95 +229,4 @@ namespace mongo {
} cmdCount;
-
- static long long applySkipLimit(long long num, const BSONObj& cmd) {
- BSONElement s = cmd["skip"];
- BSONElement l = cmd["limit"];
-
- if (s.isNumber()) {
- num = num - s.numberLong();
- if (num < 0) {
- num = 0;
- }
- }
-
- if (l.isNumber()) {
- long long limit = l.numberLong();
- if (limit < 0) {
- limit = -limit;
- }
-
- // 0 means no limit.
- if (limit < num && limit != 0) {
- num = limit;
- }
- }
-
- return num;
- }
-
- long long runCount(OperationContext* txn,
- const string& ns,
- const BSONObj &cmd,
- string &err,
- int &errCode) {
-
- AutoGetCollectionForRead ctx(txn, ns);
-
- Collection* collection = ctx.getCollection();
- if (NULL == collection) {
- err = "ns missing";
- return -1;
- }
-
- const NamespaceString nss(ns);
-
- CountRequest request;
- CmdCount* countComm = static_cast<CmdCount*>(Command::findCommand("count"));
- Status parseStatus = countComm->parseRequest(nss.db().toString(), cmd, &request);
- if (!parseStatus.isOK()) {
- err = parseStatus.reason();
- errCode = parseStatus.code();
- return -1;
- }
-
- if (request.query.isEmpty()) {
- return applySkipLimit(collection->numRecords(txn), cmd);
- }
-
- PlanExecutor* rawExec;
- Status getExecStatus = getExecutorCount(txn,
- collection,
- request,
- PlanExecutor::YIELD_AUTO,
- &rawExec);
- if (!getExecStatus.isOK()) {
- err = getExecStatus.reason();
- errCode = getExecStatus.code();
- return -1;
- }
-
- scoped_ptr<PlanExecutor> exec(rawExec);
-
- // Store the plan summary string in CurOp.
- if (NULL != txn->getCurOp()) {
- txn->getCurOp()->debug().planSummary = Explain::getPlanSummary(exec.get());
- }
-
- Status execPlanStatus = exec->executePlan();
- if (!execPlanStatus.isOK()) {
- err = execPlanStatus.reason();
- errCode = execPlanStatus.code();
- return -2;
- }
-
- // Plan is done executing. We just need to pull the count out of the root stage.
- invariant(STAGE_COUNT == exec->getRootStage()->stageType());
- CountStage* countStage = static_cast<CountStage*>(exec->getRootStage());
- const CountStats* countStats =
- static_cast<const CountStats*>(countStage->getSpecificStats());
-
- return countStats->nCounted;
- }
-
} // namespace mongo
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index cae4ca7b97b..7f61d5aa3eb 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -1007,9 +1007,12 @@ namespace mongo {
BSONObj prev;
BSONList all;
+ Collection* coll = getCollectionOrUassert(ctx->getDb(), _config.incLong);
+ invariant(coll);
+
verify(pm == op->setMessage("m/r: (3/3) final reduce to collection",
"M/R: (3/3) Final Reduce Progress",
- _db.count(_config.incLong, BSONObj(), QueryOption_SlaveOk)));
+ coll->numRecords(_txn)));
const NamespaceString nss(_config.incLong);
const WhereCallbackReal whereCallback(_txn, nss.db());
@@ -1023,9 +1026,6 @@ namespace mongo {
whereCallback).isOK());
std::auto_ptr<CanonicalQuery> cq(cqRaw);
- Collection* coll = getCollectionOrUassert(ctx->getDb(), _config.incLong);
- invariant(coll);
-
PlanExecutor* rawExec;
verify(getExecutor(_txn,
coll,
diff --git a/src/mongo/db/dbdirectclient.cpp b/src/mongo/db/dbdirectclient.cpp
index b0d673b5de1..fa60a6c33c1 100644
--- a/src/mongo/db/dbdirectclient.cpp
+++ b/src/mongo/db/dbdirectclient.cpp
@@ -171,38 +171,4 @@ namespace mongo {
const HostAndPort DBDirectClient::dummyHost("0.0.0.0", 0);
- extern long long runCount(OperationContext* txn,
- const string& ns,
- const BSONObj &cmd,
- string &err,
- int &errCode);
-
- unsigned long long DBDirectClient::count(const string& ns,
- const BSONObj& query,
- int options,
- int limit,
- int skip) {
-
- if (skip < 0) {
- warning() << "setting negative skip value: " << skip
- << " to zero in query: " << query << endl;
- skip = 0;
- }
-
- string errmsg;
- int errCode;
- long long res = runCount(_txn,
- ns,
- _countCmd(ns, query, options, limit, skip),
- errmsg,
- errCode);
-
- if (res == -1) {
- // namespace doesn't exist
- return 0;
- }
- massert(errCode, str::stream() << "count failed in DBDirectClient: " << errmsg, res >= 0);
- return (unsigned long long)res;
- }
-
} // namespace mongo
diff --git a/src/mongo/db/dbdirectclient.h b/src/mongo/db/dbdirectclient.h
index 0a8b5122dd0..8dfffda71a9 100644
--- a/src/mongo/db/dbdirectclient.h
+++ b/src/mongo/db/dbdirectclient.h
@@ -88,13 +88,7 @@ namespace mongo {
virtual void killCursor(long long cursorID);
virtual bool callRead(Message& toSend, Message& response);
-
- virtual unsigned long long count(const std::string &ns,
- const BSONObj& query = BSONObj(),
- int options = 0,
- int limit = 0,
- int skip = 0);
-
+
virtual ConnectionString::ConnectionType type() const;
double getSoTimeout() const;