PlanStage::StageState TextStage::work(WorkingSetID* out) { ++_commonStats.works; if (isEOF()) { return PlanStage::IS_EOF; } switch (_internalState) { case INIT_SCANS: return initScans(out); case READING_TERMS: return readFromSubScanners(out); case RETURNING_RESULTS: return returnResults(out); case DONE: return PlanStage::IS_EOF; } // Not reached. return PlanStage::IS_EOF; }
PlanStage::StageState TextStage::work(WorkingSetID* out) { ++_commonStats.works; // Adds the amount of time taken by work() to executionTimeMillis. ScopedTimer timer(&_commonStats.executionTimeMillis); if (isEOF()) { return PlanStage::IS_EOF; } invariant(_internalState != DONE); PlanStage::StageState stageState = PlanStage::IS_EOF; switch (_internalState) { case INIT_SCANS: stageState = initScans(out); break; case READING_TERMS: stageState = readFromSubScanners(out); break; case FILTER_NEGATIVES: stageState = filterNegatives(out); break; case RETURNING_RESULTS: stageState = returnResults(out); break; case DONE: // Handled above. break; } // Increment common stats counters that are specific to the return value of work(). switch (stageState) { case PlanStage::ADVANCED: ++_commonStats.advanced; break; case PlanStage::NEED_TIME: ++_commonStats.needTime; break; default: break; } return stageState; }