diff options
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/pipeline/document_source_densify.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_densify.h | 45 |
2 files changed, 47 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/document_source_densify.cpp b/src/mongo/db/pipeline/document_source_densify.cpp index 7f537a6a9b6..c7d8b122c31 100644 --- a/src/mongo/db/pipeline/document_source_densify.cpp +++ b/src/mongo/db/pipeline/document_source_densify.cpp @@ -141,4 +141,8 @@ bool DocumentSourceInternalDensify::DocGenerator::done() const { return _state == GeneratorState::kDone; } +DocumentSource::GetNextResult DocumentSourceInternalDensify::doGetNext() { + return pSource->getNext(); +} + } // namespace mongo diff --git a/src/mongo/db/pipeline/document_source_densify.h b/src/mongo/db/pipeline/document_source_densify.h index b25c482f9fe..ffc921d4714 100644 --- a/src/mongo/db/pipeline/document_source_densify.h +++ b/src/mongo/db/pipeline/document_source_densify.h @@ -31,6 +31,7 @@ #include "mongo/db/exec/document_value/document.h" #include "mongo/db/exec/document_value/value.h" +#include "mongo/db/pipeline/document_source.h" #include "mongo/db/pipeline/field_path.h" #include "mongo/db/query/datetime/date_time_support.h" #include "mongo/util/time_support.h" @@ -42,14 +43,17 @@ namespace document_source_densify { } // TODO SERVER-57332 This should inherit from DocumentSource. -class DocumentSourceInternalDensify { +class DocumentSourceInternalDensify final : public DocumentSource { public: + static constexpr StringData kStageName = "$_internalDensify"_sd; + using DensifyValueType = stdx::variant<double, Date_t>; struct StepSpec { double step; boost::optional<TimeUnit> unit; boost::optional<TimeZone> tz; }; + class DocGenerator { public: DocGenerator(DensifyValueType min, @@ -85,5 +89,42 @@ public: GeneratorState _state = GeneratorState::kGeneratingDocuments; }; + + static boost::intrusive_ptr<DocumentSourceInternalDensify> create(const boost::intrusive_ptr<ExpressionContext>& pExpCtx); + + static boost::intrusive_ptr<DocumentSource> createFromBson( + BSONElement elem, const boost::intrusive_ptr<ExpressionContext>& pExpCtx); + + StageConstraints constraints(Pipeline::SplitState pipeState) const final { + return {StreamType::kStreaming, + PositionRequirement::kNone, + HostTypeRequirement::kNone, + DiskUseRequirement::kNoDiskUse, + FacetRequirement::kAllowed, + TransactionRequirement::kAllowed, + LookupRequirement::kAllowed, + UnionRequirement::kAllowed}; + } + + const char* getSourceName() const final { + return kStageName.rawData(); + } + Pipeline::SourceContainer::iterator doOptimizeAt(Pipeline::SourceContainer::iterator itr, + Pipeline::SourceContainer* container) final; + Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; + + DepsTracker::State getDependencies(DepsTracker* deps) const final { + return DepsTracker::State::SEE_NEXT; // This doesn't affect needed fields + } + + boost::optional<DistributedPlanLogic> distributedPlanLogic() final { + // Running this stage on the shards is an optimization, but is not strictly necessary in + // order to produce correct pipeline output. + // {shardsStage, mergingStage, sortPattern} + return DistributedPlanLogic{nullptr, this, boost::none}; + } + + DocumentSourceInternalDensify(const boost::intrusive_ptr<ExpressionContext>& pExpCtx); + GetNextResult doGetNext() final; }; -} // namespace mongo +}; |