summaryrefslogtreecommitdiff
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
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.
-rw-r--r--src/mongo/db/commands/list_collections.cpp4
-rw-r--r--src/mongo/db/commands/list_indexes.cpp4
-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
-rw-r--r--src/mongo/db/query/stage_types.h2
-rw-r--r--src/mongo/dbtests/query_stage_fetch.cpp6
-rw-r--r--src/mongo/dbtests/query_stage_limit_skip.cpp8
-rw-r--r--src/mongo/dbtests/query_stage_sort.cpp10
11 files changed, 58 insertions, 56 deletions
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp
index 73202ada937..a3e0839df95 100644
--- a/src/mongo/db/commands/list_collections.cpp
+++ b/src/mongo/db/commands/list_collections.cpp
@@ -40,7 +40,7 @@
#include "mongo/db/client.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands.h"
-#include "mongo/db/exec/mock_stage.h"
+#include "mongo/db/exec/queued_data_stage.h"
#include "mongo/db/exec/working_set.h"
#include "mongo/db/global_environment_experiment.h"
#include "mongo/db/query/find_constants.h"
@@ -101,7 +101,7 @@ namespace mongo {
}
std::auto_ptr<WorkingSet> ws(new WorkingSet());
- std::auto_ptr<MockStage> root(new MockStage(ws.get()));
+ std::auto_ptr<QueuedDataStage> root(new QueuedDataStage(ws.get()));
for ( std::list<std::string>::const_iterator i = names.begin(); i != names.end(); ++i ) {
string ns = *i;
diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp
index 859d37116fc..227567e9054 100644
--- a/src/mongo/db/commands/list_indexes.cpp
+++ b/src/mongo/db/commands/list_indexes.cpp
@@ -37,7 +37,7 @@
#include "mongo/db/client.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands.h"
-#include "mongo/db/exec/mock_stage.h"
+#include "mongo/db/exec/queued_data_stage.h"
#include "mongo/db/exec/working_set.h"
#include "mongo/db/global_environment_experiment.h"
#include "mongo/db/query/find_constants.h"
@@ -119,7 +119,7 @@ namespace mongo {
cce->getAllIndexes( txn, &indexNames );
std::auto_ptr<WorkingSet> ws(new WorkingSet());
- std::auto_ptr<MockStage> root(new MockStage(ws.get()));
+ std::auto_ptr<QueuedDataStage> root(new QueuedDataStage(ws.get()));
for ( size_t i = 0; i < indexNames.size(); i++ ) {
BSONObj indexSpec = cce->getIndexSpec( txn, indexNames[i] );
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());
diff --git a/src/mongo/db/query/stage_types.h b/src/mongo/db/query/stage_types.h
index 788f7ce94bf..83574b4292d 100644
--- a/src/mongo/db/query/stage_types.h
+++ b/src/mongo/db/query/stage_types.h
@@ -74,7 +74,6 @@ namespace mongo {
STAGE_IDHACK,
STAGE_IXSCAN,
STAGE_LIMIT,
- STAGE_MOCK,
// Implements parallelCollectionScan.
STAGE_MULTI_ITERATOR,
@@ -87,6 +86,7 @@ namespace mongo {
// Stage for running aggregation pipelines.
STAGE_PIPELINE_PROXY,
+ STAGE_QUEUED_DATA,
STAGE_SHARDING_FILTER,
STAGE_SKIP,
STAGE_SORT,
diff --git a/src/mongo/dbtests/query_stage_fetch.cpp b/src/mongo/dbtests/query_stage_fetch.cpp
index 6926f7de8cd..8b55f57d51e 100644
--- a/src/mongo/dbtests/query_stage_fetch.cpp
+++ b/src/mongo/dbtests/query_stage_fetch.cpp
@@ -37,7 +37,7 @@
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/fetch.h"
#include "mongo/db/exec/plan_stage.h"
-#include "mongo/db/exec/mock_stage.h"
+#include "mongo/db/exec/queued_data_stage.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/operation_context_impl.h"
@@ -107,7 +107,7 @@ namespace QueryStageFetch {
ASSERT_EQUALS(size_t(1), locs.size());
// Create a mock stage that returns the WSM.
- auto_ptr<MockStage> mockStage(new MockStage(&ws));
+ auto_ptr<QueuedDataStage> mockStage(new QueuedDataStage(&ws));
// Mock data.
{
@@ -169,7 +169,7 @@ namespace QueryStageFetch {
ASSERT_EQUALS(size_t(1), locs.size());
// Create a mock stage that returns the WSM.
- auto_ptr<MockStage> mockStage(new MockStage(&ws));
+ auto_ptr<QueuedDataStage> mockStage(new QueuedDataStage(&ws));
// Mock data.
{
diff --git a/src/mongo/dbtests/query_stage_limit_skip.cpp b/src/mongo/dbtests/query_stage_limit_skip.cpp
index cdb8b3dd935..edb745a2d69 100644
--- a/src/mongo/dbtests/query_stage_limit_skip.cpp
+++ b/src/mongo/dbtests/query_stage_limit_skip.cpp
@@ -34,8 +34,8 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/db/exec/limit.h"
-#include "mongo/db/exec/mock_stage.h"
#include "mongo/db/exec/plan_stage.h"
+#include "mongo/db/exec/queued_data_stage.h"
#include "mongo/db/exec/skip.h"
#include "mongo/db/instance.h"
#include "mongo/db/json.h"
@@ -49,9 +49,9 @@ namespace {
static const int N = 50;
- /* Populate a MockStage and return it. Caller owns it. */
- MockStage* getMS(WorkingSet* ws) {
- auto_ptr<MockStage> ms(new MockStage(ws));
+ /* Populate a QueuedDataStage and return it. Caller owns it. */
+ QueuedDataStage* getMS(WorkingSet* ws) {
+ auto_ptr<QueuedDataStage> ms(new QueuedDataStage(ws));
// Put N ADVANCED results into the mock stage, and some other stalling results (YIELD/TIME).
for (int i = 0; i < N; ++i) {
diff --git a/src/mongo/dbtests/query_stage_sort.cpp b/src/mongo/dbtests/query_stage_sort.cpp
index d182a91e12f..bb3ef814899 100644
--- a/src/mongo/dbtests/query_stage_sort.cpp
+++ b/src/mongo/dbtests/query_stage_sort.cpp
@@ -30,8 +30,8 @@
#include "mongo/db/catalog/database.h"
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/exec/fetch.h"
-#include "mongo/db/exec/mock_stage.h"
#include "mongo/db/exec/plan_stage.h"
+#include "mongo/db/exec/queued_data_stage.h"
#include "mongo/db/exec/sort.h"
#include "mongo/db/json.h"
#include "mongo/db/query/plan_executor.h"
@@ -77,7 +77,7 @@ namespace QueryStageSortTests {
/**
* We feed a mix of (key, unowned, owned) data to the sort stage.
*/
- void insertVarietyOfObjects(MockStage* ms, Collection* coll) {
+ void insertVarietyOfObjects(QueuedDataStage* ms, Collection* coll) {
set<RecordId> locs;
getLocs(&locs, coll);
@@ -111,7 +111,7 @@ namespace QueryStageSortTests {
*/
void sortAndCheck(int direction, Collection* coll) {
WorkingSet* ws = new WorkingSet();
- MockStage* ms = new MockStage(ws);
+ QueuedDataStage* ms = new QueuedDataStage(ws);
// Insert a mix of the various types of data.
insertVarietyOfObjects(ms, coll);
@@ -274,7 +274,7 @@ namespace QueryStageSortTests {
// Build the mock scan stage which feeds the data.
WorkingSet ws;
- auto_ptr<MockStage> ms(new MockStage(&ws));
+ auto_ptr<QueuedDataStage> ms(new QueuedDataStage(&ws));
insertVarietyOfObjects(ms.get(), coll);
SortStageParams params;
@@ -359,7 +359,7 @@ namespace QueryStageSortTests {
}
WorkingSet* ws = new WorkingSet();
- MockStage* ms = new MockStage(ws);
+ QueuedDataStage* ms = new QueuedDataStage(ws);
for (int i = 0; i < numObj(); ++i) {
WorkingSetMember member;