From c832bc753c29f91597b75fa02c0d9019c3c20b0f Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Wed, 8 Jul 2015 12:40:15 -0400 Subject: SERVER-17364 Unify handling of child stages into PlanStage base class This is prep for adding more methods that need to propagate to children. --- src/mongo/db/exec/text_or.cpp | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) (limited to 'src/mongo/db/exec/text_or.cpp') diff --git a/src/mongo/db/exec/text_or.cpp b/src/mongo/db/exec/text_or.cpp index be600e3639d..d1e57871593 100644 --- a/src/mongo/db/exec/text_or.cpp +++ b/src/mongo/db/exec/text_or.cpp @@ -59,10 +59,10 @@ TextOrStage::TextOrStage(OperationContext* txn, WorkingSet* ws, const MatchExpression* filter, IndexDescriptor* index) - : _ftsSpec(ftsSpec), + : PlanStage(kStageType), + _ftsSpec(ftsSpec), _ws(ws), _scoreIterator(_scores.end()), - _commonStats(kStageType), _filter(filter), _txn(txn), _idRetrying(WorkingSet::INVALID_ID), @@ -78,41 +78,22 @@ bool TextOrStage::isEOF() { return _internalState == State::kDone; } -void TextOrStage::saveState() { +void TextOrStage::doSaveState() { _txn = NULL; - ++_commonStats.yields; - - for (auto& child : _children) { - child->saveState(); - } - if (_recordCursor) { _recordCursor->saveUnpositioned(); } } -void TextOrStage::restoreState(OperationContext* opCtx) { +void TextOrStage::doRestoreState(OperationContext* opCtx) { invariant(_txn == NULL); _txn = opCtx; - ++_commonStats.unyields; - - for (auto& child : _children) { - child->restoreState(opCtx); - } - if (_recordCursor) { invariant(_recordCursor->restore(opCtx)); } } -void TextOrStage::invalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) { - ++_commonStats.invalidates; - - // Propagate invalidate to children. - for (auto& child : _children) { - child->invalidate(txn, dl, type); - } - +void TextOrStage::doInvalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) { // Remove the RecordID from the ScoreMap. ScoreMap::iterator scoreIt = _scores.find(dl); if (scoreIt != _scores.end()) { @@ -123,14 +104,6 @@ void TextOrStage::invalidate(OperationContext* txn, const RecordId& dl, Invalida } } -vector TextOrStage::getChildren() const { - std::vector vec; - for (auto& child : _children) { - vec.push_back(child.get()); - } - return vec; -} - std::unique_ptr TextOrStage::getStats() { _commonStats.isEOF = isEOF(); @@ -150,10 +123,6 @@ std::unique_ptr TextOrStage::getStats() { return ret; } -const CommonStats* TextOrStage::getCommonStats() const { - return &_commonStats; -} - const SpecificStats* TextOrStage::getSpecificStats() const { return &_specificStats; } -- cgit v1.2.1