From 34ce1c33da2ea46ea7cc12980e8a4e436ad276eb Mon Sep 17 00:00:00 2001 From: Eric Cox Date: Mon, 9 Dec 2019 21:27:55 +0000 Subject: [PATCH] SERVER-44806 Move DocumentSource::getNext() implementation to the header --- src/mongo/db/pipeline/document_source.cpp | 16 ---------------- src/mongo/db/pipeline/document_source.h | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/mongo/db/pipeline/document_source.cpp b/src/mongo/db/pipeline/document_source.cpp index 5515d6d24ce..91e5c77f5a5 100644 --- a/src/mongo/db/pipeline/document_source.cpp +++ b/src/mongo/db/pipeline/document_source.cpp @@ -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> 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; diff --git a/src/mongo/db/pipeline/document_source.h b/src/mongo/db/pipeline/document_source.h index 1481f7b582c..dcab65033a9 100644 --- a/src/mongo/db/pipeline/document_source.h +++ b/src/mongo/db/pipeline/document_source.h @@ -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