summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2015-01-09 11:23:15 -0500
committerJason Rassi <rassi@10gen.com>2015-01-12 12:40:45 -0500
commit2468153c690dbe8312a10829d3cd7565ed90c1e1 (patch)
tree5f4bd3d5326face3d7f6a30b48dae5fbcd0253e2 /src/mongo/db/exec
parentae7a1a999b9352948cb49dfaf80a4ad3c7eabd5d (diff)
downloadmongo-2468153c690dbe8312a10829d3cd7565ed90c1e1.tar.gz
SERVER-16659 Rename MockStage to QueuedDataStage
It is no longer the case that this stage is only used for testing.
Diffstat (limited to 'src/mongo/db/exec')
-rw-r--r--src/mongo/db/exec/SConscript6
-rw-r--r--src/mongo/db/exec/queued_data_stage.cpp (renamed from src/mongo/db/exec/mock_stage.cpp)33
-rw-r--r--src/mongo/db/exec/queued_data_stage.h (renamed from src/mongo/db/exec/mock_stage.h)19
-rw-r--r--src/mongo/db/exec/queued_data_stage_test.cpp (renamed from src/mongo/db/exec/mock_stage_test.cpp)12
-rw-r--r--src/mongo/db/exec/sort_test.cpp10
5 files changed, 41 insertions, 39 deletions
diff --git a/src/mongo/db/exec/SConscript b/src/mongo/db/exec/SConscript
index ed4aefd510f..37e91bd8476 100644
--- a/src/mongo/db/exec/SConscript
+++ b/src/mongo/db/exec/SConscript
@@ -52,7 +52,6 @@ env.Library(
"keep_mutations.cpp",
"limit.cpp",
"merge_sort.cpp",
- "mock_stage.cpp",
"multi_iterator.cpp",
"multi_plan.cpp",
"near.cpp",
@@ -61,6 +60,7 @@ env.Library(
"pipeline_proxy.cpp",
"projection.cpp",
"projection_exec.cpp",
+ "queued_data_stage.cpp",
"shard_filter.cpp",
"skip.cpp",
"sort.cpp",
@@ -77,9 +77,9 @@ env.Library(
)
env.CppUnitTest(
- target = "mock_stage_test",
+ target = "queued_data_stage_test",
source = [
- "mock_stage_test.cpp",
+ "queued_data_stage_test.cpp",
],
LIBDEPS = [
"exec",
diff --git a/src/mongo/db/exec/mock_stage.cpp b/src/mongo/db/exec/queued_data_stage.cpp
index c40265399f2..3d3ab327601 100644
--- a/src/mongo/db/exec/mock_stage.cpp
+++ b/src/mongo/db/exec/queued_data_stage.cpp
@@ -26,20 +26,21 @@
* it in the license file.
*/
-#include "mongo/db/exec/mock_stage.h"
+#include "mongo/db/exec/queued_data_stage.h"
+
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set_common.h"
namespace mongo {
- const char* MockStage::kStageType = "MOCK";
+ const char* QueuedDataStage::kStageType = "QUEUED_DATA";
- MockStage::MockStage(WorkingSet* ws)
+ QueuedDataStage::QueuedDataStage(WorkingSet* ws)
: _ws(ws),
_commonStats(kStageType)
{}
- PlanStage::StageState MockStage::work(WorkingSetID* out) {
+ PlanStage::StageState QueuedDataStage::work(WorkingSetID* out) {
++_commonStats.works;
// Adds the amount of time taken by work() to executionTimeMillis.
@@ -62,37 +63,39 @@ namespace mongo {
return state;
}
- bool MockStage::isEOF() { return _results.empty(); }
+ bool QueuedDataStage::isEOF() { return _results.empty(); }
- void MockStage::saveState() {
+ void QueuedDataStage::saveState() {
++_commonStats.yields;
}
- void MockStage::restoreState(OperationContext* opCtx) {
+ void QueuedDataStage::restoreState(OperationContext* opCtx) {
++_commonStats.unyields;
}
- void MockStage::invalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) {
+ void QueuedDataStage::invalidate(OperationContext* txn,
+ const RecordId& dl,
+ InvalidationType type) {
++_commonStats.invalidates;
}
- PlanStageStats* MockStage::getStats() {
+ PlanStageStats* QueuedDataStage::getStats() {
_commonStats.isEOF = isEOF();
- auto_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_MOCK));
+ auto_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_QUEUED_DATA));
ret->specific.reset(new MockStats(_specificStats));
return ret.release();
}
- const CommonStats* MockStage::getCommonStats() { return &_commonStats; }
+ const CommonStats* QueuedDataStage::getCommonStats() { return &_commonStats; }
- const SpecificStats* MockStage::getSpecificStats() { return &_specificStats; }
+ const SpecificStats* QueuedDataStage::getSpecificStats() { return &_specificStats; }
- void MockStage::pushBack(const PlanStage::StageState state) {
+ void QueuedDataStage::pushBack(const PlanStage::StageState state) {
invariant(PlanStage::ADVANCED != state);
_results.push(state);
}
- void MockStage::pushBack(const WorkingSetMember& member) {
+ void QueuedDataStage::pushBack(const WorkingSetMember& member) {
_results.push(PlanStage::ADVANCED);
WorkingSetID id = _ws->allocate();
@@ -103,7 +106,7 @@ namespace mongo {
_members.push(id);
}
- vector<PlanStage*> MockStage::getChildren() const {
+ vector<PlanStage*> QueuedDataStage::getChildren() const {
vector<PlanStage*> empty;
return empty;
}
diff --git a/src/mongo/db/exec/mock_stage.h b/src/mongo/db/exec/queued_data_stage.h
index 57bd337bf21..b17566f1b1e 100644
--- a/src/mongo/db/exec/mock_stage.h
+++ b/src/mongo/db/exec/queued_data_stage.h
@@ -38,18 +38,17 @@ namespace mongo {
class RecordId;
/**
- * MockStage is a data-producing stage that is used for testing. Unlike the other two leaf
- * stages (CollectionScan and IndexScan) MockStage does not require any underlying storage
- * layer.
+ * QueuedDataStage is a data-producing stage. Unlike the other two leaf stages (CollectionScan
+ * and IndexScan) QueuedDataStage does not require any underlying storage layer.
*
- * A MockStage is "programmed" by pushing return values from work() onto its internal queue.
- * Calls to MockStage::work() pop values off that queue and return them in FIFO order,
- * annotating the working set with data when appropriate.
+ * A QueuedDataStage is "programmed" by pushing return values from work() onto its internal
+ * queue. Calls to QueuedDataStage::work() pop values off that queue and return them in FIFO
+ * order, annotating the working set with data when appropriate.
*/
- class MockStage : public PlanStage {
+ class QueuedDataStage : public PlanStage {
public:
- MockStage(WorkingSet* ws);
- virtual ~MockStage() { }
+ QueuedDataStage(WorkingSet* ws);
+ virtual ~QueuedDataStage() { }
virtual StageState work(WorkingSetID* out);
@@ -64,7 +63,7 @@ namespace mongo {
virtual std::vector<PlanStage*> getChildren() const;
- virtual StageType stageType() const { return STAGE_MOCK; }
+ virtual StageType stageType() const { return STAGE_QUEUED_DATA; }
//
// Exec stats
diff --git a/src/mongo/db/exec/mock_stage_test.cpp b/src/mongo/db/exec/queued_data_stage_test.cpp
index a7f7ec8652f..98d74ce894c 100644
--- a/src/mongo/db/exec/mock_stage_test.cpp
+++ b/src/mongo/db/exec/queued_data_stage_test.cpp
@@ -27,10 +27,10 @@
*/
//
-// This file contains tests for mongo/db/exec/mock_stage.cpp
+// This file contains tests for mongo/db/exec/queued_data_stage.cpp
//
-#include "mongo/db/exec/mock_stage.h"
+#include "mongo/db/exec/queued_data_stage.h"
#include "mongo/db/exec/working_set.h"
#include "mongo/unittest/unittest.h"
@@ -41,9 +41,9 @@ namespace {
//
// Basic test that we get out valid stats objects.
//
- TEST(MockStageTest, getValidStats) {
+ TEST(QueuedDataStageTest, getValidStats) {
WorkingSet ws;
- auto_ptr<MockStage> mock(new MockStage(&ws));
+ auto_ptr<QueuedDataStage> mock(new QueuedDataStage(&ws));
const CommonStats* commonStats = mock->getCommonStats();
ASSERT_EQUALS(commonStats->works, static_cast<size_t>(0));
const SpecificStats* specificStats = mock->getSpecificStats();
@@ -55,10 +55,10 @@ namespace {
//
// Test that our stats are updated as we perform operations.
//
- TEST(MockStageTest, validateStats) {
+ TEST(QueuedDataStageTest, validateStats) {
WorkingSet ws;
WorkingSetID wsID;
- auto_ptr<MockStage> mock(new MockStage(&ws));
+ auto_ptr<QueuedDataStage> mock(new QueuedDataStage(&ws));
// make sure that we're at all zero
const CommonStats* stats = mock->getCommonStats();
diff --git a/src/mongo/db/exec/sort_test.cpp b/src/mongo/db/exec/sort_test.cpp
index c890fb4dd15..3f627346f11 100644
--- a/src/mongo/db/exec/sort_test.cpp
+++ b/src/mongo/db/exec/sort_test.cpp
@@ -32,8 +32,8 @@
#include "mongo/db/exec/sort.h"
+#include "mongo/db/exec/queued_data_stage.h"
#include "mongo/db/json.h"
-#include "mongo/db/exec/mock_stage.h"
#include "mongo/unittest/unittest.h"
using namespace mongo;
@@ -44,8 +44,8 @@ namespace {
TEST(SortStageTest, SortEmptyWorkingSet) {
WorkingSet ws;
- // MockStage will be owned by SortStage.
- MockStage* ms = new MockStage(&ws);
+ // QueuedDataStage will be owned by SortStage.
+ QueuedDataStage* ms = new QueuedDataStage(&ws);
SortStageParams params;
SortStage sort(params, &ws, ms);
@@ -84,8 +84,8 @@ namespace {
// so it's fine to declare
WorkingSet ws;
- // MockStage will be owned by SortStage.
- MockStage* ms = new MockStage(&ws);
+ // QueuedDataStage will be owned by SortStage.
+ QueuedDataStage* ms = new QueuedDataStage(&ws);
BSONObj inputObj = fromjson(inputStr);
BSONElement inputElt = inputObj.getField("input");
ASSERT(inputElt.isABSONObj());