diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/exec/or.cpp | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/exec/or.cpp')
-rw-r--r-- | src/mongo/db/exec/or.cpp | 247 |
1 files changed, 124 insertions, 123 deletions
diff --git a/src/mongo/db/exec/or.cpp b/src/mongo/db/exec/or.cpp index a7d370c41fa..2513635db1d 100644 --- a/src/mongo/db/exec/or.cpp +++ b/src/mongo/db/exec/or.cpp @@ -35,171 +35,172 @@ namespace mongo { - using std::unique_ptr; - using std::vector; +using std::unique_ptr; +using std::vector; - // static - const char* OrStage::kStageType = "OR"; +// static +const char* OrStage::kStageType = "OR"; - OrStage::OrStage(WorkingSet* ws, bool dedup, const MatchExpression* filter) - : _ws(ws), _filter(filter), _currentChild(0), _dedup(dedup), _commonStats(kStageType) { } +OrStage::OrStage(WorkingSet* ws, bool dedup, const MatchExpression* filter) + : _ws(ws), _filter(filter), _currentChild(0), _dedup(dedup), _commonStats(kStageType) {} - OrStage::~OrStage() { - for (size_t i = 0; i < _children.size(); ++i) { - delete _children[i]; - } +OrStage::~OrStage() { + for (size_t i = 0; i < _children.size(); ++i) { + delete _children[i]; } +} - void OrStage::addChild(PlanStage* child) { _children.push_back(child); } - - bool OrStage::isEOF() { return _currentChild >= _children.size(); } +void OrStage::addChild(PlanStage* child) { + _children.push_back(child); +} - PlanStage::StageState OrStage::work(WorkingSetID* out) { - ++_commonStats.works; +bool OrStage::isEOF() { + return _currentChild >= _children.size(); +} - // Adds the amount of time taken by work() to executionTimeMillis. - ScopedTimer timer(&_commonStats.executionTimeMillis); +PlanStage::StageState OrStage::work(WorkingSetID* out) { + ++_commonStats.works; - if (isEOF()) { return PlanStage::IS_EOF; } + // Adds the amount of time taken by work() to executionTimeMillis. + ScopedTimer timer(&_commonStats.executionTimeMillis); - WorkingSetID id = WorkingSet::INVALID_ID; - StageState childStatus = _children[_currentChild]->work(&id); + if (isEOF()) { + return PlanStage::IS_EOF; + } - if (PlanStage::ADVANCED == childStatus) { - WorkingSetMember* member = _ws->get(id); + WorkingSetID id = WorkingSet::INVALID_ID; + StageState childStatus = _children[_currentChild]->work(&id); - // If we're deduping (and there's something to dedup by) - if (_dedup && member->hasLoc()) { - ++_specificStats.dupsTested; + if (PlanStage::ADVANCED == childStatus) { + WorkingSetMember* member = _ws->get(id); - // ...and we've seen the RecordId before - if (_seen.end() != _seen.find(member->loc)) { - // ...drop it. - ++_specificStats.dupsDropped; - _ws->free(id); - ++_commonStats.needTime; - return PlanStage::NEED_TIME; - } - else { - // Otherwise, note that we've seen it. - _seen.insert(member->loc); - } - } + // If we're deduping (and there's something to dedup by) + if (_dedup && member->hasLoc()) { + ++_specificStats.dupsTested; - if (Filter::passes(member, _filter)) { - // Match! return it. - *out = id; - ++_commonStats.advanced; - return PlanStage::ADVANCED; - } - else { - // Does not match, try again. + // ...and we've seen the RecordId before + if (_seen.end() != _seen.find(member->loc)) { + // ...drop it. + ++_specificStats.dupsDropped; _ws->free(id); ++_commonStats.needTime; return PlanStage::NEED_TIME; + } else { + // Otherwise, note that we've seen it. + _seen.insert(member->loc); } } - else if (PlanStage::IS_EOF == childStatus) { - // Done with _currentChild, move to the next one. - ++_currentChild; - // Maybe we're out of children. - if (isEOF()) { - return PlanStage::IS_EOF; - } - else { - ++_commonStats.needTime; - return PlanStage::NEED_TIME; - } - } - else if (PlanStage::FAILURE == childStatus || PlanStage::DEAD == childStatus) { + if (Filter::passes(member, _filter)) { + // Match! return it. *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 << "OR stage failed to read in results from child " << _currentChild; - Status status(ErrorCodes::InternalError, ss); - *out = WorkingSetCommon::allocateStatusMember( _ws, status); - } - return childStatus; + ++_commonStats.advanced; + return PlanStage::ADVANCED; + } else { + // Does not match, try again. + _ws->free(id); + ++_commonStats.needTime; + return PlanStage::NEED_TIME; } - else if (PlanStage::NEED_TIME == childStatus) { + } else if (PlanStage::IS_EOF == childStatus) { + // Done with _currentChild, move to the next one. + ++_currentChild; + + // Maybe we're out of children. + if (isEOF()) { + return PlanStage::IS_EOF; + } else { ++_commonStats.needTime; + return PlanStage::NEED_TIME; } - else if (PlanStage::NEED_YIELD == childStatus) { - ++_commonStats.needYield; - *out = id; + } else if (PlanStage::FAILURE == childStatus || PlanStage::DEAD == childStatus) { + *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 << "OR stage failed to read in results from child " << _currentChild; + Status status(ErrorCodes::InternalError, ss); + *out = WorkingSetCommon::allocateStatusMember(_ws, status); } - - // NEED_TIME, ERROR, NEED_YIELD, pass them up. return childStatus; + } else if (PlanStage::NEED_TIME == childStatus) { + ++_commonStats.needTime; + } else if (PlanStage::NEED_YIELD == childStatus) { + ++_commonStats.needYield; + *out = id; } - void OrStage::saveState() { - ++_commonStats.yields; - for (size_t i = 0; i < _children.size(); ++i) { - _children[i]->saveState(); - } - } + // NEED_TIME, ERROR, NEED_YIELD, pass them up. + return childStatus; +} - void OrStage::restoreState(OperationContext* opCtx) { - ++_commonStats.unyields; - for (size_t i = 0; i < _children.size(); ++i) { - _children[i]->restoreState(opCtx); - } +void OrStage::saveState() { + ++_commonStats.yields; + for (size_t i = 0; i < _children.size(); ++i) { + _children[i]->saveState(); } +} - void OrStage::invalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) { - ++_commonStats.invalidates; +void OrStage::restoreState(OperationContext* opCtx) { + ++_commonStats.unyields; + for (size_t i = 0; i < _children.size(); ++i) { + _children[i]->restoreState(opCtx); + } +} - if (isEOF()) { return; } +void OrStage::invalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) { + ++_commonStats.invalidates; - for (size_t i = 0; i < _children.size(); ++i) { - _children[i]->invalidate(txn, dl, type); - } - - // If we see DL again it is not the same record as it once was so we still want to - // return it. - if (_dedup && INVALIDATION_DELETION == type) { - unordered_set<RecordId, RecordId::Hasher>::iterator it = _seen.find(dl); - if (_seen.end() != it) { - ++_specificStats.locsForgotten; - _seen.erase(dl); - } - } + if (isEOF()) { + return; } - vector<PlanStage*> OrStage::getChildren() const { - return _children; + for (size_t i = 0; i < _children.size(); ++i) { + _children[i]->invalidate(txn, dl, type); } - PlanStageStats* OrStage::getStats() { - _commonStats.isEOF = isEOF(); - - // Add a BSON representation of the filter to the stats tree, if there is one. - if (NULL != _filter) { - BSONObjBuilder bob; - _filter->toBSON(&bob); - _commonStats.filter = bob.obj(); + // If we see DL again it is not the same record as it once was so we still want to + // return it. + if (_dedup && INVALIDATION_DELETION == type) { + unordered_set<RecordId, RecordId::Hasher>::iterator it = _seen.find(dl); + if (_seen.end() != it) { + ++_specificStats.locsForgotten; + _seen.erase(dl); } + } +} - unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_OR)); - ret->specific.reset(new OrStats(_specificStats)); - for (size_t i = 0; i < _children.size(); ++i) { - ret->children.push_back(_children[i]->getStats()); - } +vector<PlanStage*> OrStage::getChildren() const { + return _children; +} - return ret.release(); - } +PlanStageStats* OrStage::getStats() { + _commonStats.isEOF = isEOF(); - const CommonStats* OrStage::getCommonStats() const { - return &_commonStats; + // Add a BSON representation of the filter to the stats tree, if there is one. + if (NULL != _filter) { + BSONObjBuilder bob; + _filter->toBSON(&bob); + _commonStats.filter = bob.obj(); } - const SpecificStats* OrStage::getSpecificStats() const { - return &_specificStats; + unique_ptr<PlanStageStats> ret(new PlanStageStats(_commonStats, STAGE_OR)); + ret->specific.reset(new OrStats(_specificStats)); + for (size_t i = 0; i < _children.size(); ++i) { + ret->children.push_back(_children[i]->getStats()); } + return ret.release(); +} + +const CommonStats* OrStage::getCommonStats() const { + return &_commonStats; +} + +const SpecificStats* OrStage::getSpecificStats() const { + return &_specificStats; +} + } // namespace mongo |