SERVER-44806 Move DocumentSource::getNext() implementation to the header

This commit is contained in:
Eric Cox
2019-12-09 21:27:55 +00:00
committed by evergreen
parent 64a9f0dcc0
commit 34ce1c33da
2 changed files with 17 additions and 17 deletions

View File

@@ -32,7 +32,6 @@
#include "mongo/db/pipeline/document_source.h"
#include "mongo/db/exec/document_value/value.h"
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/matcher/expression_algo.h"
#include "mongo/db/pipeline/document_source_group.h"
#include "mongo/db/pipeline/document_source_internal_shard_filter.h"
@@ -87,21 +86,6 @@ list<intrusive_ptr<DocumentSource>> DocumentSource::parse(
return it->second(stageSpec, expCtx);
}
DocumentSource::GetNextResult DocumentSource::getNext() {
pExpCtx->checkForInterrupt();
invariant(pExpCtx->opCtx->getServiceContext());
invariant(pExpCtx->opCtx->getServiceContext()->getFastClockSource());
ScopedTimer timer(pExpCtx->opCtx->getServiceContext()->getFastClockSource(),
&_commonStats.executionTimeMillis);
++_commonStats.works;
GetNextResult next = doGetNext();
if (next.isAdvanced()) {
++_commonStats.advanced;
}
return next;
}
const char* DocumentSource::getSourceName() const {
static const char unknown[] = "[UNKNOWN]";
return unknown;

View File

@@ -46,6 +46,7 @@
#include "mongo/db/exec/document_value/document.h"
#include "mongo/db/exec/document_value/value.h"
#include "mongo/db/exec/plan_stats.h"
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/generic_cursor.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
@@ -247,7 +248,22 @@ public:
* return it) before asking for another result. Failing to do so can result in extra work, since
* the Document/Value library must copy data on write when that data has a refcount above one.
*/
GetNextResult getNext();
GetNextResult getNext() {
pExpCtx->checkForInterrupt();
auto serviceCtx = pExpCtx->opCtx->getServiceContext();
invariant(serviceCtx);
auto fcs = serviceCtx->getFastClockSource();
invariant(fcs);
ScopedTimer timer(fcs, &_commonStats.executionTimeMillis);
++_commonStats.works;
GetNextResult next = doGetNext();
if (next.isAdvanced()) {
++_commonStats.advanced;
}
return next;
}
/**
* Returns a struct containing information about any special constraints imposed on using this