summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/limit.cpp
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 00:22:50 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 10:56:02 -0400
commit9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch)
tree3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/exec/limit.cpp
parent01965cf52bce6976637ecb8f4a622aeb05ab256a (diff)
downloadmongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/exec/limit.cpp')
-rw-r--r--src/mongo/db/exec/limit.cpp170
1 files changed, 83 insertions, 87 deletions
diff --git a/src/mongo/db/exec/limit.cpp b/src/mongo/db/exec/limit.cpp
index c766d07c650..a62f6e863e3 100644
--- a/src/mongo/db/exec/limit.cpp
+++ b/src/mongo/db/exec/limit.cpp
@@ -34,103 +34,99 @@
namespace mongo {
- using std::unique_ptr;
- using std::vector;
-
- // static
- const char* LimitStage::kStageType = "LIMIT";
-
- LimitStage::LimitStage(int limit, WorkingSet* ws, PlanStage* child)
- : _ws(ws),
- _child(child),
- _numToReturn(limit),
- _commonStats(kStageType) {
- _specificStats.limit = _numToReturn;
- }
+using std::unique_ptr;
+using std::vector;
- LimitStage::~LimitStage() { }
+// static
+const char* LimitStage::kStageType = "LIMIT";
- bool LimitStage::isEOF() { return (0 == _numToReturn) || _child->isEOF(); }
+LimitStage::LimitStage(int limit, WorkingSet* ws, PlanStage* child)
+ : _ws(ws), _child(child), _numToReturn(limit), _commonStats(kStageType) {
+ _specificStats.limit = _numToReturn;
+}
- PlanStage::StageState LimitStage::work(WorkingSetID* out) {
- ++_commonStats.works;
+LimitStage::~LimitStage() {}
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
+bool LimitStage::isEOF() {
+ return (0 == _numToReturn) || _child->isEOF();
+}
- if (0 == _numToReturn) {
- // We've returned as many results as we're limited to.
- return PlanStage::IS_EOF;
- }
+PlanStage::StageState LimitStage::work(WorkingSetID* out) {
+ ++_commonStats.works;
- WorkingSetID id = WorkingSet::INVALID_ID;
- StageState status = _child->work(&id);
+ // Adds the amount of time taken by work() to executionTimeMillis.
+ ScopedTimer timer(&_commonStats.executionTimeMillis);
- if (PlanStage::ADVANCED == status) {
- *out = id;
- --_numToReturn;
- ++_commonStats.advanced;
- return PlanStage::ADVANCED;
- }
- else if (PlanStage::FAILURE == status || PlanStage::DEAD == status) {
- *out = id;
- // If a stage fails, it may create a status WSM to indicate why it
- // failed, in which case 'id' is valid. If ID is invalid, we
- // create our own error message.
- if (WorkingSet::INVALID_ID == id) {
- mongoutils::str::stream ss;
- ss << "limit stage failed to read in results from child";
- Status status(ErrorCodes::InternalError, ss);
- *out = WorkingSetCommon::allocateStatusMember( _ws, status);
- }
- return status;
- }
- else if (PlanStage::NEED_TIME == status) {
- ++_commonStats.needTime;
- }
- else if (PlanStage::NEED_YIELD == status) {
- ++_commonStats.needYield;
- *out = id;
- }
-
- return status;
+ if (0 == _numToReturn) {
+ // We've returned as many results as we're limited to.
+ return PlanStage::IS_EOF;
}
- void LimitStage::saveState() {
- ++_commonStats.yields;
- _child->saveState();
- }
-
- void LimitStage::restoreState(OperationContext* opCtx) {
- ++_commonStats.unyields;
- _child->restoreState(opCtx);
- }
-
- void LimitStage::invalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) {
- ++_commonStats.invalidates;
- _child->invalidate(txn, dl, type);
- }
-
- vector<PlanStage*> LimitStage::getChildren() const {
- vector<PlanStage*> children;
- children.push_back(_child.get());
- return children;
- }
-
- 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();
- }
-
- const CommonStats* LimitStage::getCommonStats() const {
- return &_commonStats;
+ WorkingSetID id = WorkingSet::INVALID_ID;
+ StageState status = _child->work(&id);
+
+ if (PlanStage::ADVANCED == status) {
+ *out = id;
+ --_numToReturn;
+ ++_commonStats.advanced;
+ return PlanStage::ADVANCED;
+ } else if (PlanStage::FAILURE == status || PlanStage::DEAD == status) {
+ *out = id;
+ // If a stage fails, it may create a status WSM to indicate why it
+ // failed, in which case 'id' is valid. If ID is invalid, we
+ // create our own error message.
+ if (WorkingSet::INVALID_ID == id) {
+ mongoutils::str::stream ss;
+ ss << "limit stage failed to read in results from child";
+ Status status(ErrorCodes::InternalError, ss);
+ *out = WorkingSetCommon::allocateStatusMember(_ws, status);
+ }
+ return status;
+ } else if (PlanStage::NEED_TIME == status) {
+ ++_commonStats.needTime;
+ } else if (PlanStage::NEED_YIELD == status) {
+ ++_commonStats.needYield;
+ *out = id;
}
- const SpecificStats* LimitStage::getSpecificStats() const {
- return &_specificStats;
- }
+ return status;
+}
+
+void LimitStage::saveState() {
+ ++_commonStats.yields;
+ _child->saveState();
+}
+
+void LimitStage::restoreState(OperationContext* opCtx) {
+ ++_commonStats.unyields;
+ _child->restoreState(opCtx);
+}
+
+void LimitStage::invalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) {
+ ++_commonStats.invalidates;
+ _child->invalidate(txn, dl, type);
+}
+
+vector<PlanStage*> LimitStage::getChildren() const {
+ vector<PlanStage*> children;
+ children.push_back(_child.get());
+ return children;
+}
+
+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();
+}
+
+const CommonStats* LimitStage::getCommonStats() const {
+ return &_commonStats;
+}
+
+const SpecificStats* LimitStage::getSpecificStats() const {
+ return &_specificStats;
+}
} // namespace mongo