diff options
author | Will Buerger <will.buerger@mongodb.com> | 2023-03-14 20:49:09 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-03-16 19:20:45 +0000 |
commit | a9a20593fd1c3106548650bfc909d26dab2e38a4 (patch) | |
tree | 9121911fdcfc6ebd2fec8d31df02f554d970c3bc /src/mongo/db/pipeline | |
parent | 9662f3c9edfd52ce4c9b0cad619bed57562a3daa (diff) | |
download | mongo-a9a20593fd1c3106548650bfc909d26dab2e38a4.tar.gz |
SERVER-74843 Remove overloaded document source serializers and change signature to use SerializationOptions
Diffstat (limited to 'src/mongo/db/pipeline')
130 files changed, 404 insertions, 537 deletions
diff --git a/src/mongo/db/pipeline/accumulator.h b/src/mongo/db/pipeline/accumulator.h index 05732983f9a..52e28579ac5 100644 --- a/src/mongo/db/pipeline/accumulator.h +++ b/src/mongo/db/pipeline/accumulator.h @@ -137,7 +137,6 @@ public: */ virtual Document serialize(boost::intrusive_ptr<Expression> initializer, boost::intrusive_ptr<Expression> argument, - bool explain, SerializationOptions options = {}) const { ExpressionConstant const* ec = dynamic_cast<ExpressionConstant const*>(initializer.get()); invariant(ec); diff --git a/src/mongo/db/pipeline/accumulator_js_reduce.cpp b/src/mongo/db/pipeline/accumulator_js_reduce.cpp index 78454b6b267..375bd7484c8 100644 --- a/src/mongo/db/pipeline/accumulator_js_reduce.cpp +++ b/src/mongo/db/pipeline/accumulator_js_reduce.cpp @@ -196,7 +196,6 @@ void AccumulatorInternalJsReduce::reset() { // Returns this accumulator serialized as a Value along with the reduce function. Document AccumulatorInternalJsReduce::serialize(boost::intrusive_ptr<Expression> initializer, boost::intrusive_ptr<Expression> argument, - bool explain, SerializationOptions options) const { if (options.replacementForLiteralArgs) { return DOC(kName << DOC("data" << argument->serialize(options) << "eval" @@ -240,7 +239,6 @@ std::string parseFunction(StringData fieldName, Document AccumulatorJs::serialize(boost::intrusive_ptr<Expression> initializer, boost::intrusive_ptr<Expression> argument, - bool explain, SerializationOptions options) const { MutableDocument args; diff --git a/src/mongo/db/pipeline/accumulator_js_reduce.h b/src/mongo/db/pipeline/accumulator_js_reduce.h index 7690cb1660e..8970223c24b 100644 --- a/src/mongo/db/pipeline/accumulator_js_reduce.h +++ b/src/mongo/db/pipeline/accumulator_js_reduce.h @@ -66,7 +66,6 @@ public: virtual Document serialize(boost::intrusive_ptr<Expression> initializer, boost::intrusive_ptr<Expression> argument, - bool explain, SerializationOptions options = {}) const override; private: @@ -104,7 +103,6 @@ public: Document serialize(boost::intrusive_ptr<Expression> initializer, boost::intrusive_ptr<Expression> argument, - bool explain, SerializationOptions options = {}) const final; void startNewGroup(Value const& input) final; diff --git a/src/mongo/db/pipeline/accumulator_multi.cpp b/src/mongo/db/pipeline/accumulator_multi.cpp index 67dafbd90e4..def608f383c 100644 --- a/src/mongo/db/pipeline/accumulator_multi.cpp +++ b/src/mongo/db/pipeline/accumulator_multi.cpp @@ -106,7 +106,6 @@ const char* AccumulatorMinMaxN::getOpName() const { Document AccumulatorMinMaxN::serialize(boost::intrusive_ptr<Expression> initializer, boost::intrusive_ptr<Expression> argument, - bool explain, SerializationOptions options) const { MutableDocument args; AccumulatorN::serializeHelper(initializer, argument, options, args); @@ -314,7 +313,6 @@ const char* AccumulatorFirstLastN::getOpName() const { Document AccumulatorFirstLastN::serialize(boost::intrusive_ptr<Expression> initializer, boost::intrusive_ptr<Expression> argument, - bool explain, SerializationOptions options) const { MutableDocument args; AccumulatorN::serializeHelper(initializer, argument, options, args); @@ -462,7 +460,6 @@ template <TopBottomSense sense, bool single> Document AccumulatorTopBottomN<sense, single>::serialize( boost::intrusive_ptr<Expression> initializer, boost::intrusive_ptr<Expression> argument, - bool explain, SerializationOptions options) const { MutableDocument args; diff --git a/src/mongo/db/pipeline/accumulator_multi.h b/src/mongo/db/pipeline/accumulator_multi.h index 34c91902d71..ac1d70aae0c 100644 --- a/src/mongo/db/pipeline/accumulator_multi.h +++ b/src/mongo/db/pipeline/accumulator_multi.h @@ -136,7 +136,6 @@ public: Document serialize(boost::intrusive_ptr<Expression> initializer, boost::intrusive_ptr<Expression> argument, - bool explain, SerializationOptions options = {}) const final; void reset() final; @@ -208,7 +207,6 @@ public: Document serialize(boost::intrusive_ptr<Expression> initializer, boost::intrusive_ptr<Expression> argument, - bool explain, SerializationOptions options = {}) const final; void reset() final; @@ -324,7 +322,6 @@ public: Document serialize(boost::intrusive_ptr<Expression> initializer, boost::intrusive_ptr<Expression> argument, - bool explain, SerializationOptions options = {}) const final; void reset() final; diff --git a/src/mongo/db/pipeline/accumulator_test.cpp b/src/mongo/db/pipeline/accumulator_test.cpp index 8cf881bffa3..81c521d80fe 100644 --- a/src/mongo/db/pipeline/accumulator_test.cpp +++ b/src/mongo/db/pipeline/accumulator_test.cpp @@ -1768,7 +1768,7 @@ Document parseAndSerializeAccum( auto expr = func(expCtx.get(), elem, vps); auto accum = expr.factory(); - return accum->serialize(expr.initializer, expr.argument, false, options); + return accum->serialize(expr.initializer, expr.argument, options); } TEST(Accumulators, SerializeWithRedaction) { diff --git a/src/mongo/db/pipeline/document_source.cpp b/src/mongo/db/pipeline/document_source.cpp index 73fce6aceca..28dc3b4ab5c 100644 --- a/src/mongo/db/pipeline/document_source.cpp +++ b/src/mongo/db/pipeline/document_source.cpp @@ -274,14 +274,6 @@ Pipeline::SourceContainer::iterator DocumentSource::optimizeAt( return doOptimizeAt(itr, container); } -void DocumentSource::serializeToArray(vector<Value>& array, - boost::optional<ExplainOptions::Verbosity> explain) const { - Value entry = serialize(explain); - if (!entry.missing()) { - array.push_back(entry); - } -} - void DocumentSource::serializeToArray(vector<Value>& array, SerializationOptions opts) const { Value entry = serialize(opts); if (!entry.missing()) { diff --git a/src/mongo/db/pipeline/document_source.h b/src/mongo/db/pipeline/document_source.h index c77e32da622..c2e415e2e6d 100644 --- a/src/mongo/db/pipeline/document_source.h +++ b/src/mongo/db/pipeline/document_source.h @@ -441,23 +441,9 @@ public: * * A subclass may choose to overwrite this, rather than serialize, if it should output multiple * stages (eg, $sort sometimes also outputs a $limit). - * - * The 'explain' parameter indicates the explain verbosity mode, or is equal boost::none if no - * explain is requested. - * - * TODO: Remove this once all concrete types have implemented serialize(SerializationOptions). - */ - virtual void serializeToArray( - std::vector<Value>& array, - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const; - - /** - * In the default case, serializes the DocumentSource and adds it to the std::vector<Value>. - * - * A subclass may choose to overwrite this, rather than serialize, if it should output multiple - * stages (eg, $sort sometimes also outputs a $limit). */ - virtual void serializeToArray(std::vector<Value>& array, SerializationOptions opts) const; + virtual void serializeToArray(std::vector<Value>& array, + SerializationOptions opts = SerializationOptions()) const; /** * Shortcut method to get a BSONObj for debugging. Often useful in log messages, but is not @@ -812,23 +798,8 @@ private: * This is used by the default implementation of serializeToArray() to add this object * to a pipeline being serialized. Returning a missing() Value results in no entry * being added to the array for this stage (DocumentSource). - * - * The 'explain' parameter indicates the explain verbosity mode, or is equal boost::none if no - * explain is requested. - * - * TODO: Remove this once all concrete types have implemented serialize(SerializationOptions). - */ - virtual Value serialize( - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const = 0; - - /** - * Create a Value that represents the document source. - * - * This is used by the default implementation of serializeToArray() to add this object - * to a pipeline being serialized. Returning a missing() Value results in no entry - * being added to the array for this stage (DocumentSource). */ - virtual Value serialize(SerializationOptions opts) const = 0; + virtual Value serialize(SerializationOptions opts = SerializationOptions()) const = 0; }; /** diff --git a/src/mongo/db/pipeline/document_source_bucket_auto.cpp b/src/mongo/db/pipeline/document_source_bucket_auto.cpp index aa2bc2fed77..660c17af86b 100644 --- a/src/mongo/db/pipeline/document_source_bucket_auto.cpp +++ b/src/mongo/db/pipeline/document_source_bucket_auto.cpp @@ -380,11 +380,15 @@ void DocumentSourceBucketAuto::doDispose() { _sortedInput.reset(); } -Value DocumentSourceBucketAuto::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceBucketAuto::serialize(SerializationOptions opts) const { + auto explain = opts.verbosity; + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484364); + } + MutableDocument insides; - insides["groupBy"] = _groupByExpression->serialize(static_cast<bool>(explain)); + insides["groupBy"] = _groupByExpression->serialize(explain); insides["buckets"] = Value(_nBuckets); if (_granularityRounder) { @@ -394,10 +398,8 @@ Value DocumentSourceBucketAuto::serialize( MutableDocument outputSpec(_accumulatedFields.size()); for (auto&& accumulatedField : _accumulatedFields) { intrusive_ptr<AccumulatorState> accum = accumulatedField.makeAccumulator(); - outputSpec[accumulatedField.fieldName] = - Value(accum->serialize(accumulatedField.expr.initializer, - accumulatedField.expr.argument, - static_cast<bool>(explain))); + outputSpec[accumulatedField.fieldName] = Value(accum->serialize( + accumulatedField.expr.initializer, accumulatedField.expr.argument, explain)); } insides["output"] = outputSpec.freezeToValue(); diff --git a/src/mongo/db/pipeline/document_source_bucket_auto.h b/src/mongo/db/pipeline/document_source_bucket_auto.h index 044adb8d89a..9d576eb9a16 100644 --- a/src/mongo/db/pipeline/document_source_bucket_auto.h +++ b/src/mongo/db/pipeline/document_source_bucket_auto.h @@ -45,11 +45,8 @@ namespace mongo { class DocumentSourceBucketAuto final : public DocumentSource { public: static constexpr StringData kStageName = "$bucketAuto"_sd; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } DepsTracker::State getDependencies(DepsTracker* deps) const final; void addVariableRefs(std::set<Variables::Id>* refs) const final; diff --git a/src/mongo/db/pipeline/document_source_change_stream_add_post_image.cpp b/src/mongo/db/pipeline/document_source_change_stream_add_post_image.cpp index f7dcf3da213..bdf1add6b71 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_add_post_image.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_add_post_image.cpp @@ -208,9 +208,11 @@ boost::optional<Document> DocumentSourceChangeStreamAddPostImage::lookupLatestPo pExpCtx, nss, *resumeTokenData.uuid, documentKey, std::move(readConcern)); } -Value DocumentSourceChangeStreamAddPostImage::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { - return explain +Value DocumentSourceChangeStreamAddPostImage::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484363); + } + return opts.verbosity ? Value(Document{ {DocumentSourceChangeStream::kStageName, Document{{"stage"_sd, kStageName}, diff --git a/src/mongo/db/pipeline/document_source_change_stream_add_post_image.h b/src/mongo/db/pipeline/document_source_change_stream_add_post_image.h index 49b9792d6a5..15bd2d365c3 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_add_post_image.h +++ b/src/mongo/db/pipeline/document_source_change_stream_add_post_image.h @@ -116,11 +116,7 @@ public: void addVariableRefs(std::set<Variables::Id>* refs) const final {} - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; const char* getSourceName() const final { return kStageName.rawData(); diff --git a/src/mongo/db/pipeline/document_source_change_stream_add_pre_image.cpp b/src/mongo/db/pipeline/document_source_change_stream_add_pre_image.cpp index c547f606f25..4dbf2fd1f8c 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_add_pre_image.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_add_pre_image.cpp @@ -139,9 +139,12 @@ boost::optional<Document> DocumentSourceChangeStreamAddPreImage::lookupPreImage( return preImageField.getDocument().getOwned(); } -Value DocumentSourceChangeStreamAddPreImage::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { - return explain +Value DocumentSourceChangeStreamAddPreImage::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484362); + } + + return opts.verbosity ? Value(Document{ {DocumentSourceChangeStream::kStageName, Document{{"stage"_sd, "internalAddPreImage"_sd}, diff --git a/src/mongo/db/pipeline/document_source_change_stream_add_pre_image.h b/src/mongo/db/pipeline/document_source_change_stream_add_pre_image.h index 81c66d11c55..bad3ccd51b0 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_add_pre_image.h +++ b/src/mongo/db/pipeline/document_source_change_stream_add_pre_image.h @@ -109,11 +109,7 @@ public: void addVariableRefs(std::set<Variables::Id>* refs) const final {} - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; const char* getSourceName() const final { return kStageName.rawData(); diff --git a/src/mongo/db/pipeline/document_source_change_stream_check_invalidate.cpp b/src/mongo/db/pipeline/document_source_change_stream_check_invalidate.cpp index 0842398e770..25eecd66cf2 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_check_invalidate.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_check_invalidate.cpp @@ -180,9 +180,12 @@ DocumentSource::GetNextResult DocumentSourceChangeStreamCheckInvalidate::doGetNe return nextInput; } -Value DocumentSourceChangeStreamCheckInvalidate::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { - if (explain) { +Value DocumentSourceChangeStreamCheckInvalidate::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484361); + } + + if (opts.verbosity) { return Value(Document{{DocumentSourceChangeStream::kStageName, Document{{"stage"_sd, "internalCheckInvalidate"_sd}}}}); } diff --git a/src/mongo/db/pipeline/document_source_change_stream_check_invalidate.h b/src/mongo/db/pipeline/document_source_change_stream_check_invalidate.h index 942a47c516b..a8fa30cdac5 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_check_invalidate.h +++ b/src/mongo/db/pipeline/document_source_change_stream_check_invalidate.h @@ -64,11 +64,7 @@ public: return boost::none; } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; void addVariableRefs(std::set<Variables::Id>* refs) const final {} diff --git a/src/mongo/db/pipeline/document_source_change_stream_check_resumability.cpp b/src/mongo/db/pipeline/document_source_change_stream_check_resumability.cpp index f5b01a0cc4e..688cf771cc6 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_check_resumability.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_check_resumability.cpp @@ -210,9 +210,12 @@ DocumentSource::GetNextResult DocumentSourceChangeStreamCheckResumability::doGet MONGO_UNREACHABLE; } -Value DocumentSourceChangeStreamCheckResumability::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { - return explain +Value DocumentSourceChangeStreamCheckResumability::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484360); + } + + return opts.verbosity ? Value(DOC(DocumentSourceChangeStream::kStageName << DOC("stage" << "internalCheckResumability"_sd diff --git a/src/mongo/db/pipeline/document_source_change_stream_check_resumability.h b/src/mongo/db/pipeline/document_source_change_stream_check_resumability.h index c35f7a4e772..3693ab378f7 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_check_resumability.h +++ b/src/mongo/db/pipeline/document_source_change_stream_check_resumability.h @@ -90,11 +90,7 @@ public: return boost::none; } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const override; - - Value serialize(SerializationOptions opts) const override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const override; void addVariableRefs(std::set<Variables::Id>* refs) const final {} diff --git a/src/mongo/db/pipeline/document_source_change_stream_check_topology_change.cpp b/src/mongo/db/pipeline/document_source_change_stream_check_topology_change.cpp index 73212fedac4..9b6d0038241 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_check_topology_change.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_check_topology_change.cpp @@ -87,9 +87,12 @@ DocumentSource::GetNextResult DocumentSourceChangeStreamCheckTopologyChange::doG return nextInput; } -Value DocumentSourceChangeStreamCheckTopologyChange::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { - if (explain) { +Value DocumentSourceChangeStreamCheckTopologyChange::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484359); + } + + if (opts.verbosity) { return Value(DOC(DocumentSourceChangeStream::kStageName << DOC("stage" << "internalCheckTopologyChange"_sd))); diff --git a/src/mongo/db/pipeline/document_source_change_stream_check_topology_change.h b/src/mongo/db/pipeline/document_source_change_stream_check_topology_change.h index d8a207cf917..c4ada63a032 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_check_topology_change.h +++ b/src/mongo/db/pipeline/document_source_change_stream_check_topology_change.h @@ -67,11 +67,7 @@ public: return boost::none; } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; void addVariableRefs(std::set<Variables::Id>* refs) const final {} diff --git a/src/mongo/db/pipeline/document_source_change_stream_ensure_resume_token_present.cpp b/src/mongo/db/pipeline/document_source_change_stream_ensure_resume_token_present.cpp index 3db86ebfd3e..a485bee93a7 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_ensure_resume_token_present.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_ensure_resume_token_present.cpp @@ -152,9 +152,13 @@ DocumentSource::GetNextResult DocumentSourceChangeStreamEnsureResumeTokenPresent } Value DocumentSourceChangeStreamEnsureResumeTokenPresent::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { + SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484358); + } + // We only serialize this stage in the context of explain. - if (explain) { + if (opts.verbosity) { return Value(DOC(DocumentSourceChangeStream::kStageName << DOC("stage" << "internalEnsureResumeTokenPresent"_sd diff --git a/src/mongo/db/pipeline/document_source_change_stream_ensure_resume_token_present.h b/src/mongo/db/pipeline/document_source_change_stream_ensure_resume_token_present.h index 71aa6be58ac..dfdbff78379 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_ensure_resume_token_present.h +++ b/src/mongo/db/pipeline/document_source_change_stream_ensure_resume_token_present.h @@ -54,11 +54,7 @@ public: const boost::intrusive_ptr<ExpressionContext>& expCtx, const DocumentSourceChangeStreamSpec& spec); - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; private: /** diff --git a/src/mongo/db/pipeline/document_source_change_stream_handle_topology_change.cpp b/src/mongo/db/pipeline/document_source_change_stream_handle_topology_change.cpp index cfd2a66e854..6c346f17cea 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_handle_topology_change.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_handle_topology_change.cpp @@ -254,9 +254,12 @@ BSONObj DocumentSourceChangeStreamHandleTopologyChange::replaceResumeTokenInComm return newCmd.freeze().toBson(); } -Value DocumentSourceChangeStreamHandleTopologyChange::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { - if (explain) { +Value DocumentSourceChangeStreamHandleTopologyChange::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484357); + } + + if (opts.verbosity) { return Value(DOC(DocumentSourceChangeStream::kStageName << DOC("stage" << "internalHandleTopologyChange"_sd))); diff --git a/src/mongo/db/pipeline/document_source_change_stream_handle_topology_change.h b/src/mongo/db/pipeline/document_source_change_stream_handle_topology_change.h index 8c795ffdc1e..afa6e16a704 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_handle_topology_change.h +++ b/src/mongo/db/pipeline/document_source_change_stream_handle_topology_change.h @@ -61,11 +61,7 @@ public: return kStageName.rawData(); } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; StageConstraints constraints(Pipeline::SplitState) const final; diff --git a/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp b/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp index 79457243c69..d074c49144a 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp @@ -203,9 +203,12 @@ Pipeline::SourceContainer::iterator DocumentSourceChangeStreamOplogMatch::doOpti return nextChangeStreamStageItr; } -Value DocumentSourceChangeStreamOplogMatch::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { - if (explain) { +Value DocumentSourceChangeStreamOplogMatch::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484356); + } + + if (opts.verbosity) { return Value( Document{{DocumentSourceChangeStream::kStageName, Document{{"stage"_sd, "internalOplogMatch"_sd}, {"filter"_sd, _predicate}}}}); diff --git a/src/mongo/db/pipeline/document_source_change_stream_oplog_match.h b/src/mongo/db/pipeline/document_source_change_stream_oplog_match.h index 1d980dfa952..a5a65d4cb25 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_oplog_match.h +++ b/src/mongo/db/pipeline/document_source_change_stream_oplog_match.h @@ -74,11 +74,7 @@ public: StageConstraints constraints(Pipeline::SplitState pipeState) const final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - }; + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; protected: Pipeline::SourceContainer::iterator doOptimizeAt(Pipeline::SourceContainer::iterator itr, diff --git a/src/mongo/db/pipeline/document_source_change_stream_split_large_event.cpp b/src/mongo/db/pipeline/document_source_change_stream_split_large_event.cpp index 2fc7f7623a6..d248c3d3898 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_split_large_event.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_split_large_event.cpp @@ -77,8 +77,11 @@ DocumentSourceChangeStreamSplitLargeEvent::DocumentSourceChangeStreamSplitLargeE !_resumeAfterSplit || resumeAfterSplit->fragmentNum); } -Value DocumentSourceChangeStreamSplitLargeEvent::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceChangeStreamSplitLargeEvent::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484355); + } + return Value(Document{{DocumentSourceChangeStreamSplitLargeEvent::kStageName, Document{}}}); } diff --git a/src/mongo/db/pipeline/document_source_change_stream_split_large_event.h b/src/mongo/db/pipeline/document_source_change_stream_split_large_event.h index 95fab4a4268..92fccf55c24 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_split_large_event.h +++ b/src/mongo/db/pipeline/document_source_change_stream_split_large_event.h @@ -52,11 +52,7 @@ public: // This stage does not reference any user or system variables. void addVariableRefs(std::set<Variables::Id>* refs) const final {} - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; StageConstraints constraints(Pipeline::SplitState pipeState) const final; diff --git a/src/mongo/db/pipeline/document_source_change_stream_transform.cpp b/src/mongo/db/pipeline/document_source_change_stream_transform.cpp index 42c86da6b30..30f434d6dd4 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_transform.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_transform.cpp @@ -105,9 +105,12 @@ StageConstraints DocumentSourceChangeStreamTransform::constraints( return constraints; } -Value DocumentSourceChangeStreamTransform::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { - if (explain) { +Value DocumentSourceChangeStreamTransform::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484354); + } + + if (opts.verbosity) { return Value(Document{{DocumentSourceChangeStream::kStageName, Document{{"stage"_sd, "internalTransform"_sd}, {"options"_sd, _changeStreamSpec.toBSON()}}}}); diff --git a/src/mongo/db/pipeline/document_source_change_stream_transform.h b/src/mongo/db/pipeline/document_source_change_stream_transform.h index 5d2c91b6f85..ee433d6cd50 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_transform.h +++ b/src/mongo/db/pipeline/document_source_change_stream_transform.h @@ -56,11 +56,7 @@ public: DocumentSource::GetModPathsReturn getModifiedPaths() const final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; StageConstraints constraints(Pipeline::SplitState pipeState) const final; diff --git a/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp b/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp index b99a1263953..e8feda051cf 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp @@ -128,11 +128,14 @@ StageConstraints DocumentSourceChangeStreamUnwindTransaction::constraints( ChangeStreamRequirement::kChangeStreamStage); } -Value DocumentSourceChangeStreamUnwindTransaction::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceChangeStreamUnwindTransaction::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484353); + } + tassert(5467604, "expression has not been initialized", _expression); - if (explain) { + if (opts.verbosity) { return Value( DOC(DocumentSourceChangeStream::kStageName << DOC("stage" << "internalUnwindTransaction"_sd diff --git a/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.h b/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.h index 986385b0e17..18fd795c1f4 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.h +++ b/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.h @@ -57,11 +57,7 @@ public: DocumentSource::GetModPathsReturn getModifiedPaths() const final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; StageConstraints constraints(Pipeline::SplitState pipeState) const final; diff --git a/src/mongo/db/pipeline/document_source_coll_stats.cpp b/src/mongo/db/pipeline/document_source_coll_stats.cpp index 4609c4259a3..b771cf08433 100644 --- a/src/mongo/db/pipeline/document_source_coll_stats.cpp +++ b/src/mongo/db/pipeline/document_source_coll_stats.cpp @@ -128,7 +128,10 @@ DocumentSource::GetNextResult DocumentSourceCollStats::doGetNext() { return {Document(makeStatsForNs(pExpCtx, pExpCtx->ns, _collStatsSpec))}; } -Value DocumentSourceCollStats::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceCollStats::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484352); + } return Value(Document{{getSourceName(), _collStatsSpec.toBSON()}}); } diff --git a/src/mongo/db/pipeline/document_source_coll_stats.h b/src/mongo/db/pipeline/document_source_coll_stats.h index b359f88f66b..6c29644fb87 100644 --- a/src/mongo/db/pipeline/document_source_coll_stats.h +++ b/src/mongo/db/pipeline/document_source_coll_stats.h @@ -114,11 +114,7 @@ public: return boost::none; } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; void addVariableRefs(std::set<Variables::Id>* refs) const final {} diff --git a/src/mongo/db/pipeline/document_source_current_op.cpp b/src/mongo/db/pipeline/document_source_current_op.cpp index 0366764c0f5..2216858b97a 100644 --- a/src/mongo/db/pipeline/document_source_current_op.cpp +++ b/src/mongo/db/pipeline/document_source_current_op.cpp @@ -289,7 +289,11 @@ intrusive_ptr<DocumentSourceCurrentOp> DocumentSourceCurrentOp::create( backtrace); } -Value DocumentSourceCurrentOp::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceCurrentOp::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484351); + } + return Value(Document{ {getSourceName(), Document{{kIdleConnectionsFieldName, diff --git a/src/mongo/db/pipeline/document_source_current_op.h b/src/mongo/db/pipeline/document_source_current_op.h index b8d92bd26c7..9c752edde6d 100644 --- a/src/mongo/db/pipeline/document_source_current_op.h +++ b/src/mongo/db/pipeline/document_source_current_op.h @@ -134,11 +134,7 @@ public: static boost::intrusive_ptr<DocumentSource> createFromBson( BSONElement spec, const boost::intrusive_ptr<ExpressionContext>& pExpCtx); - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; void addVariableRefs(std::set<Variables::Id>* refs) const final {} diff --git a/src/mongo/db/pipeline/document_source_cursor.cpp b/src/mongo/db/pipeline/document_source_cursor.cpp index 6c59043a7ed..520e999c10a 100644 --- a/src/mongo/db/pipeline/document_source_cursor.cpp +++ b/src/mongo/db/pipeline/document_source_cursor.cpp @@ -208,7 +208,11 @@ void DocumentSourceCursor::recordPlanSummaryStats() { _exec->getPlanExplainer().getSummaryStats(&_stats.planSummaryStats); } -Value DocumentSourceCursor::serialize(boost::optional<ExplainOptions::Verbosity> verbosity) const { +Value DocumentSourceCursor::serialize(SerializationOptions opts) const { + auto verbosity = opts.verbosity; + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484350); + } // We never parse a DocumentSourceCursor, so we only serialize for explain. if (!verbosity) return Value(); diff --git a/src/mongo/db/pipeline/document_source_cursor.h b/src/mongo/db/pipeline/document_source_cursor.h index 4274b883a8d..ab1af3feb31 100644 --- a/src/mongo/db/pipeline/document_source_cursor.h +++ b/src/mongo/db/pipeline/document_source_cursor.h @@ -72,11 +72,7 @@ public: const char* getSourceName() const override; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; StageConstraints constraints(Pipeline::SplitState pipeState) const final { StageConstraints constraints(StreamType::kStreaming, diff --git a/src/mongo/db/pipeline/document_source_densify.cpp b/src/mongo/db/pipeline/document_source_densify.cpp index 60908e598c5..5c0356f0fcc 100644 --- a/src/mongo/db/pipeline/document_source_densify.cpp +++ b/src/mongo/db/pipeline/document_source_densify.cpp @@ -633,8 +633,11 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceInternalDensify::createFromBs return results.front(); } -Value DocumentSourceInternalDensify::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceInternalDensify::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484349); + } + MutableDocument spec; spec[kFieldFieldName] = Value(_field.fullPath()); std::vector<Value> serializedPartitionByFields(_partitions.size()); diff --git a/src/mongo/db/pipeline/document_source_densify.h b/src/mongo/db/pipeline/document_source_densify.h index a11343ab8ce..77499a8907f 100644 --- a/src/mongo/db/pipeline/document_source_densify.h +++ b/src/mongo/db/pipeline/document_source_densify.h @@ -383,11 +383,7 @@ public: return kStageName.rawData(); } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; DepsTracker::State getDependencies(DepsTracker* deps) const final { deps->fields.insert(_field.fullPath()); diff --git a/src/mongo/db/pipeline/document_source_exchange.cpp b/src/mongo/db/pipeline/document_source_exchange.cpp index ae6eff551a0..dd23d00b94f 100644 --- a/src/mongo/db/pipeline/document_source_exchange.cpp +++ b/src/mongo/db/pipeline/document_source_exchange.cpp @@ -93,7 +93,10 @@ const char* DocumentSourceExchange::getSourceName() const { return kStageName.rawData(); } -Value DocumentSourceExchange::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceExchange::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484348); + } return Value(DOC(getSourceName() << _exchange->getSpec().toBSON())); } diff --git a/src/mongo/db/pipeline/document_source_exchange.h b/src/mongo/db/pipeline/document_source_exchange.h index 89268cc7504..190c6152c63 100644 --- a/src/mongo/db/pipeline/document_source_exchange.h +++ b/src/mongo/db/pipeline/document_source_exchange.h @@ -221,11 +221,7 @@ public: const char* getSourceName() const final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; /** * DocumentSourceExchange does not have a direct source (it is reading through the shared diff --git a/src/mongo/db/pipeline/document_source_facet.cpp b/src/mongo/db/pipeline/document_source_facet.cpp index 9f0c1fdad06..f16b4c9be03 100644 --- a/src/mongo/db/pipeline/document_source_facet.cpp +++ b/src/mongo/db/pipeline/document_source_facet.cpp @@ -185,11 +185,16 @@ DocumentSource::GetNextResult DocumentSourceFacet::doGetNext() { return resultDoc.freeze(); } -Value DocumentSourceFacet::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceFacet::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484347); + } + MutableDocument serialized; for (auto&& facet : _facets) { - serialized[facet.name] = Value(explain ? facet.pipeline->writeExplainOps(*explain) - : facet.pipeline->serialize()); + serialized[facet.name] = + Value(opts.verbosity ? facet.pipeline->writeExplainOps(*opts.verbosity) + : facet.pipeline->serialize()); } return Value(Document{{"$facet", serialized.freezeToValue()}}); } diff --git a/src/mongo/db/pipeline/document_source_facet.h b/src/mongo/db/pipeline/document_source_facet.h index c9c96fd5c56..344b3448ac9 100644 --- a/src/mongo/db/pipeline/document_source_facet.h +++ b/src/mongo/db/pipeline/document_source_facet.h @@ -161,11 +161,7 @@ private: size_t bufferSizeBytes, size_t maxOutputDocBytes); - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; boost::intrusive_ptr<TeeBuffer> _teeBuffer; std::vector<FacetPipeline> _facets; diff --git a/src/mongo/db/pipeline/document_source_find_and_modify_image_lookup.cpp b/src/mongo/db/pipeline/document_source_find_and_modify_image_lookup.cpp index 80747efcb99..48fd455beb4 100644 --- a/src/mongo/db/pipeline/document_source_find_and_modify_image_lookup.cpp +++ b/src/mongo/db/pipeline/document_source_find_and_modify_image_lookup.cpp @@ -178,8 +178,10 @@ StageConstraints DocumentSourceFindAndModifyImageLookup::constraints( ChangeStreamRequirement::kDenylist); } -Value DocumentSourceFindAndModifyImageLookup::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceFindAndModifyImageLookup::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484346); + } return Value( Document{{kStageName, Value(Document{{kIncludeCommitTransactionTimestampFieldName, diff --git a/src/mongo/db/pipeline/document_source_find_and_modify_image_lookup.h b/src/mongo/db/pipeline/document_source_find_and_modify_image_lookup.h index 3fe0c2f95bc..25837196b45 100644 --- a/src/mongo/db/pipeline/document_source_find_and_modify_image_lookup.h +++ b/src/mongo/db/pipeline/document_source_find_and_modify_image_lookup.h @@ -62,11 +62,7 @@ public: DocumentSource::GetModPathsReturn getModifiedPaths() const final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; StageConstraints constraints(Pipeline::SplitState pipeState) const final; diff --git a/src/mongo/db/pipeline/document_source_geo_near.cpp b/src/mongo/db/pipeline/document_source_geo_near.cpp index ce9c7906dc5..c9bd67da5dd 100644 --- a/src/mongo/db/pipeline/document_source_geo_near.cpp +++ b/src/mongo/db/pipeline/document_source_geo_near.cpp @@ -60,7 +60,11 @@ REGISTER_DOCUMENT_SOURCE(geoNear, DocumentSourceGeoNear::createFromBson, AllowedWithApiStrict::kAlways); -Value DocumentSourceGeoNear::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceGeoNear::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484345); + } + MutableDocument result; if (keyFieldPath) { @@ -72,7 +76,7 @@ Value DocumentSourceGeoNear::serialize(boost::optional<ExplainOptions::Verbosity constGeometry) { return constGeometry->getValue(); } else { - return _nearGeometry->serialize(static_cast<bool>(explain)); + return _nearGeometry->serialize(opts); } }(); result.setField("near", nearValue); diff --git a/src/mongo/db/pipeline/document_source_geo_near.h b/src/mongo/db/pipeline/document_source_geo_near.h index 17d677e1eca..44ba7ccd635 100644 --- a/src/mongo/db/pipeline/document_source_geo_near.h +++ b/src/mongo/db/pipeline/document_source_geo_near.h @@ -79,11 +79,7 @@ public: MONGO_UNREACHABLE; } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; boost::intrusive_ptr<DocumentSource> optimize() final; diff --git a/src/mongo/db/pipeline/document_source_graph_lookup.cpp b/src/mongo/db/pipeline/document_source_graph_lookup.cpp index 58c80225c05..f8a7244b03a 100644 --- a/src/mongo/db/pipeline/document_source_graph_lookup.cpp +++ b/src/mongo/db/pipeline/document_source_graph_lookup.cpp @@ -579,8 +579,13 @@ void DocumentSourceGraphLookUp::checkMemoryUsage() { _cache.evictDownTo(_maxMemoryUsageBytes - _frontierUsageBytes - _visitedUsageBytes); } -void DocumentSourceGraphLookUp::serializeToArray( - std::vector<Value>& array, boost::optional<ExplainOptions::Verbosity> explain) const { +void DocumentSourceGraphLookUp::serializeToArray(std::vector<Value>& array, + SerializationOptions opts) const { + auto explain = opts.verbosity; + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484344); + } + // Do not include tenantId in serialized 'from' namespace. auto fromValue = (pExpCtx->ns.db() == _from.db()) ? Value(_from.coll()) diff --git a/src/mongo/db/pipeline/document_source_graph_lookup.h b/src/mongo/db/pipeline/document_source_graph_lookup.h index e24da420f1a..64165cad008 100644 --- a/src/mongo/db/pipeline/document_source_graph_lookup.h +++ b/src/mongo/db/pipeline/document_source_graph_lookup.h @@ -98,14 +98,8 @@ public: _additionalFilter = additionalFilter ? additionalFilter->getOwned() : additionalFilter; }; - void serializeToArray( - std::vector<Value>& array, - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - void serializeToArray(std::vector<Value>& array, - SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - }; + SerializationOptions opts = SerializationOptions()) const final override; /** * Returns the 'as' path, and possibly the fields modified by an absorbed $unwind. @@ -179,13 +173,9 @@ private: boost::optional<long long> maxDepth, boost::optional<boost::intrusive_ptr<DocumentSourceUnwind>> unwindSrc); - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final { + Value serialize(SerializationOptions opts = SerializationOptions()) const final override { // Should not be called; use serializeToArray instead. - MONGO_UNREACHABLE; - } - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; + MONGO_UNREACHABLE_TASSERT(7484306); } /** diff --git a/src/mongo/db/pipeline/document_source_group_base.cpp b/src/mongo/db/pipeline/document_source_group_base.cpp index 791b0ce7151..69c77c4fe54 100644 --- a/src/mongo/db/pipeline/document_source_group_base.cpp +++ b/src/mongo/db/pipeline/document_source_group_base.cpp @@ -87,19 +87,23 @@ DocumentSourceGroupBase::~DocumentSourceGroupBase() { _stats.spills, _stats.spilledDataStorageSize, _stats.spilledRecords); } -Value DocumentSourceGroupBase::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceGroupBase::serialize(SerializationOptions opts) const { + auto explain = opts.verbosity; + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484343); + } MutableDocument insides; // Add the _id. if (_idFieldNames.empty()) { invariant(_idExpressions.size() == 1); - insides["_id"] = _idExpressions[0]->serialize(static_cast<bool>(explain)); + insides["_id"] = _idExpressions[0]->serialize(explain); } else { // Decomposed document case. invariant(_idExpressions.size() == _idFieldNames.size()); MutableDocument md; for (size_t i = 0; i < _idExpressions.size(); i++) { - md[_idFieldNames[i]] = _idExpressions[i]->serialize(static_cast<bool>(explain)); + md[_idFieldNames[i]] = _idExpressions[i]->serialize(explain); } insides["_id"] = md.freezeToValue(); } @@ -107,10 +111,8 @@ Value DocumentSourceGroupBase::serialize(boost::optional<ExplainOptions::Verbosi // Add the remaining fields. for (auto&& accumulatedField : _accumulatedFields) { intrusive_ptr<AccumulatorState> accum = accumulatedField.makeAccumulator(); - insides[accumulatedField.fieldName] = - Value(accum->serialize(accumulatedField.expr.initializer, - accumulatedField.expr.argument, - static_cast<bool>(explain))); + insides[accumulatedField.fieldName] = Value(accum->serialize( + accumulatedField.expr.initializer, accumulatedField.expr.argument, explain)); } if (_doingMerge) { diff --git a/src/mongo/db/pipeline/document_source_group_base.h b/src/mongo/db/pipeline/document_source_group_base.h index 9f70f58d5c7..a7142978ff1 100644 --- a/src/mongo/db/pipeline/document_source_group_base.h +++ b/src/mongo/db/pipeline/document_source_group_base.h @@ -54,10 +54,7 @@ public: using Accumulators = std::vector<boost::intrusive_ptr<AccumulatorState>>; using GroupsMap = ValueUnorderedMap<Accumulators>; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; boost::intrusive_ptr<DocumentSource> optimize() final; DepsTracker::State getDependencies(DepsTracker* deps) const final; void addVariableRefs(std::set<Variables::Id>* refs) const final; diff --git a/src/mongo/db/pipeline/document_source_index_stats.cpp b/src/mongo/db/pipeline/document_source_index_stats.cpp index 139fdde3bca..fdf4003a26b 100644 --- a/src/mongo/db/pipeline/document_source_index_stats.cpp +++ b/src/mongo/db/pipeline/document_source_index_stats.cpp @@ -78,8 +78,10 @@ intrusive_ptr<DocumentSource> DocumentSourceIndexStats::createFromBson( return new DocumentSourceIndexStats(pExpCtx); } -Value DocumentSourceIndexStats::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceIndexStats::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484342); + } return Value(DOC(getSourceName() << Document())); } } // namespace mongo diff --git a/src/mongo/db/pipeline/document_source_index_stats.h b/src/mongo/db/pipeline/document_source_index_stats.h index c0f15bde79b..1c7f7525317 100644 --- a/src/mongo/db/pipeline/document_source_index_stats.h +++ b/src/mongo/db/pipeline/document_source_index_stats.h @@ -75,11 +75,7 @@ public: // virtuals from DocumentSource const char* getSourceName() const final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; StageConstraints constraints(Pipeline::SplitState pipeState) const final { StageConstraints constraints(StreamType::kStreaming, diff --git a/src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp b/src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp index bbc07b66bc4..27f74f41025 100644 --- a/src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp +++ b/src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp @@ -126,8 +126,12 @@ Pipeline::SourceContainer::iterator DocumentSourceInternalAllCollectionStats::do } } -void DocumentSourceInternalAllCollectionStats::serializeToArray( - std::vector<Value>& array, boost::optional<ExplainOptions::Verbosity> explain) const { +void DocumentSourceInternalAllCollectionStats::serializeToArray(std::vector<Value>& array, + SerializationOptions opts) const { + auto explain = opts.verbosity; + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484341); + } if (explain) { BSONObjBuilder bob; _internalAllCollectionStatsSpec.serialize(&bob); @@ -165,8 +169,10 @@ const char* DocumentSourceInternalAllCollectionStats::getSourceName() const { return kStageNameInternal.rawData(); } -Value DocumentSourceInternalAllCollectionStats::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceInternalAllCollectionStats::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484340); + } return Value(Document{{getSourceName(), _internalAllCollectionStatsSpec.toBSON()}}); } } // namespace mongo diff --git a/src/mongo/db/pipeline/document_source_internal_all_collection_stats.h b/src/mongo/db/pipeline/document_source_internal_all_collection_stats.h index d0b805a04d7..15d378b376c 100644 --- a/src/mongo/db/pipeline/document_source_internal_all_collection_stats.h +++ b/src/mongo/db/pipeline/document_source_internal_all_collection_stats.h @@ -83,11 +83,7 @@ public: void addVariableRefs(std::set<Variables::Id>* refs) const final{}; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; StageConstraints constraints(Pipeline::SplitState pipeState) const final { StageConstraints constraints(StreamType::kStreaming, @@ -114,14 +110,8 @@ public: Pipeline::SourceContainer::iterator doOptimizeAt(Pipeline::SourceContainer::iterator itr, Pipeline::SourceContainer* container) final; - void serializeToArray( - std::vector<Value>& array, - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - void serializeToArray(std::vector<Value>& array, - SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - }; + SerializationOptions opts = SerializationOptions()) const final override; private: GetNextResult doGetNext() final; diff --git a/src/mongo/db/pipeline/document_source_internal_apply_oplog_update.cpp b/src/mongo/db/pipeline/document_source_internal_apply_oplog_update.cpp index 69a0b5ce4f9..8b75750bd1d 100644 --- a/src/mongo/db/pipeline/document_source_internal_apply_oplog_update.cpp +++ b/src/mongo/db/pipeline/document_source_internal_apply_oplog_update.cpp @@ -97,8 +97,10 @@ DocumentSource::GetNextResult DocumentSourceInternalApplyOplogUpdate::doGetNext( return Document(doc.getObject()); } -Value DocumentSourceInternalApplyOplogUpdate::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceInternalApplyOplogUpdate::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484339); + } return Value(Document{{kStageName, Document{{kOplogUpdateFieldName, _oplogUpdate}}}}); } diff --git a/src/mongo/db/pipeline/document_source_internal_apply_oplog_update.h b/src/mongo/db/pipeline/document_source_internal_apply_oplog_update.h index b8625c15191..b4b2d370e58 100644 --- a/src/mongo/db/pipeline/document_source_internal_apply_oplog_update.h +++ b/src/mongo/db/pipeline/document_source_internal_apply_oplog_update.h @@ -82,12 +82,7 @@ public: void addVariableRefs(std::set<Variables::Id>* refs) const final {} private: - Value serialize( - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const override; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; GetNextResult doGetNext() override; diff --git a/src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.cpp b/src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.cpp index 87845a67826..6bee8d29fd4 100644 --- a/src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.cpp +++ b/src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.cpp @@ -141,8 +141,11 @@ DocumentSource::GetNextResult DocumentSourceInternalGeoNearDistance::doGetNext() return next; } -Value DocumentSourceInternalGeoNearDistance::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceInternalGeoNearDistance::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484338); + } + MutableDocument out; out.setField(DocumentSourceInternalGeoNearDistance::kNearFieldName, Value(_coords)); out.setField(DocumentSourceInternalGeoNearDistance::kKeyFieldName, Value(_key)); diff --git a/src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.h b/src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.h index f4637e05889..4514d54c249 100644 --- a/src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.h +++ b/src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.h @@ -86,12 +86,7 @@ public: void addVariableRefs(std::set<Variables::Id>* refs) const final {} private: - Value serialize( - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const override; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; GetNextResult doGetNext() override; diff --git a/src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.cpp b/src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.cpp index be9784f5346..4a53382a23d 100644 --- a/src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.cpp +++ b/src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.cpp @@ -145,8 +145,11 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceInternalConvertBucketIndexSta expCtx, std::move(timeseriesOptions)); } -Value DocumentSourceInternalConvertBucketIndexStats::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceInternalConvertBucketIndexStats::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484337); + } + MutableDocument out; out.addField(timeseries::kTimeFieldName, Value{_timeseriesOptions.timeField}); if (_timeseriesOptions.metaField) { diff --git a/src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.h b/src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.h index d87cc06fe92..a8e60cd0ec9 100644 --- a/src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.h +++ b/src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.h @@ -77,11 +77,7 @@ public: ChangeStreamRequirement::kDenylist}; } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; boost::optional<DistributedPlanLogic> distributedPlanLogic() final { return boost::none; diff --git a/src/mongo/db/pipeline/document_source_internal_inhibit_optimization.cpp b/src/mongo/db/pipeline/document_source_internal_inhibit_optimization.cpp index af9d4c297b1..5c1cdb186dc 100644 --- a/src/mongo/db/pipeline/document_source_internal_inhibit_optimization.cpp +++ b/src/mongo/db/pipeline/document_source_internal_inhibit_optimization.cpp @@ -60,8 +60,10 @@ DocumentSource::GetNextResult DocumentSourceInternalInhibitOptimization::doGetNe return pSource->getNext(); } -Value DocumentSourceInternalInhibitOptimization::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceInternalInhibitOptimization::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484336); + } return Value(Document{{getSourceName(), Value{Document{}}}}); } diff --git a/src/mongo/db/pipeline/document_source_internal_inhibit_optimization.h b/src/mongo/db/pipeline/document_source_internal_inhibit_optimization.h index d398100afd1..4454f929a82 100644 --- a/src/mongo/db/pipeline/document_source_internal_inhibit_optimization.h +++ b/src/mongo/db/pipeline/document_source_internal_inhibit_optimization.h @@ -73,11 +73,7 @@ public: private: GetNextResult doGetNext() final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; }; } // namespace mongo diff --git a/src/mongo/db/pipeline/document_source_internal_shard_filter.cpp b/src/mongo/db/pipeline/document_source_internal_shard_filter.cpp index a2aa30596d5..0ae1dbbc9be 100644 --- a/src/mongo/db/pipeline/document_source_internal_shard_filter.cpp +++ b/src/mongo/db/pipeline/document_source_internal_shard_filter.cpp @@ -97,8 +97,10 @@ Pipeline::SourceContainer::iterator DocumentSourceInternalShardFilter::doOptimiz return ret; } -Value DocumentSourceInternalShardFilter::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceInternalShardFilter::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484335); + } return Value(DOC(getSourceName() << Document())); } diff --git a/src/mongo/db/pipeline/document_source_internal_shard_filter.h b/src/mongo/db/pipeline/document_source_internal_shard_filter.h index 8ae8c157bf9..d05a486cbd0 100644 --- a/src/mongo/db/pipeline/document_source_internal_shard_filter.h +++ b/src/mongo/db/pipeline/document_source_internal_shard_filter.h @@ -64,12 +64,8 @@ public: ChangeStreamRequirement::kDenylist); } - Value serialize( - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const override; - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; boost::optional<DistributedPlanLogic> distributedPlanLogic() override { return boost::none; diff --git a/src/mongo/db/pipeline/document_source_internal_shardserver_info.cpp b/src/mongo/db/pipeline/document_source_internal_shardserver_info.cpp index 4b4d9cd3e4e..8621ce25f43 100644 --- a/src/mongo/db/pipeline/document_source_internal_shardserver_info.cpp +++ b/src/mongo/db/pipeline/document_source_internal_shardserver_info.cpp @@ -60,9 +60,10 @@ DocumentSource::GetNextResult DocumentSourceInternalShardServerInfo::doGetNext() return DocumentSource::GetNextResult::makeEOF(); } -Value DocumentSourceInternalShardServerInfo::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { - +Value DocumentSourceInternalShardServerInfo::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484334); + } return Value(Document{{getSourceName(), Value{Document{{}}}}}); } diff --git a/src/mongo/db/pipeline/document_source_internal_shardserver_info.h b/src/mongo/db/pipeline/document_source_internal_shardserver_info.h index 4bf42b5dd14..1e2d480a7fe 100644 --- a/src/mongo/db/pipeline/document_source_internal_shardserver_info.h +++ b/src/mongo/db/pipeline/document_source_internal_shardserver_info.h @@ -103,11 +103,7 @@ private: GetNextResult doGetNext() final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; bool _didEmit = false; }; diff --git a/src/mongo/db/pipeline/document_source_internal_split_pipeline.cpp b/src/mongo/db/pipeline/document_source_internal_split_pipeline.cpp index 8f5f9927ada..ef2f5f9ce1a 100644 --- a/src/mongo/db/pipeline/document_source_internal_split_pipeline.cpp +++ b/src/mongo/db/pipeline/document_source_internal_split_pipeline.cpp @@ -86,8 +86,11 @@ DocumentSource::GetNextResult DocumentSourceInternalSplitPipeline::doGetNext() { return pSource->getNext(); } -Value DocumentSourceInternalSplitPipeline::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceInternalSplitPipeline::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484333); + } + std::string mergeTypeString; switch (_mergeType) { diff --git a/src/mongo/db/pipeline/document_source_internal_split_pipeline.h b/src/mongo/db/pipeline/document_source_internal_split_pipeline.h index b0531f2a389..53bf8885a8b 100644 --- a/src/mongo/db/pipeline/document_source_internal_split_pipeline.h +++ b/src/mongo/db/pipeline/document_source_internal_split_pipeline.h @@ -83,12 +83,7 @@ private: : DocumentSource(kStageName, expCtx), _mergeType(mergeType) {} GetNextResult doGetNext() final; - - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; HostTypeRequirement _mergeType = HostTypeRequirement::kNone; }; diff --git a/src/mongo/db/pipeline/document_source_internal_unpack_bucket.cpp b/src/mongo/db/pipeline/document_source_internal_unpack_bucket.cpp index 66f98aa7e9d..ce18295eec5 100644 --- a/src/mongo/db/pipeline/document_source_internal_unpack_bucket.cpp +++ b/src/mongo/db/pipeline/document_source_internal_unpack_bucket.cpp @@ -481,8 +481,13 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceInternalUnpackBucket::createF assumeClean); } -void DocumentSourceInternalUnpackBucket::serializeToArray( - std::vector<Value>& array, boost::optional<ExplainOptions::Verbosity> explain) const { +void DocumentSourceInternalUnpackBucket::serializeToArray(std::vector<Value>& array, + SerializationOptions opts) const { + auto explain = opts.verbosity; + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484332); + } + MutableDocument out; auto behavior = _bucketUnpacker.behavior() == BucketSpec::Behavior::kInclude ? kInclude : kExclude; diff --git a/src/mongo/db/pipeline/document_source_internal_unpack_bucket.h b/src/mongo/db/pipeline/document_source_internal_unpack_bucket.h index 3e000d2a247..03627b3f735 100644 --- a/src/mongo/db/pipeline/document_source_internal_unpack_bucket.h +++ b/src/mongo/db/pipeline/document_source_internal_unpack_bucket.h @@ -75,24 +75,14 @@ public: return kStageNameInternal.rawData(); } - void serializeToArray( - std::vector<Value>& array, - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - void serializeToArray(std::vector<Value>& array, - SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - }; + SerializationOptions opts = SerializationOptions()) const final override; /** * Use 'serializeToArray' above. */ - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final { - MONGO_UNREACHABLE; - } - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; + Value serialize(SerializationOptions opts = SerializationOptions()) const final override { + MONGO_UNREACHABLE_TASSERT(7484305); } bool includeMetaField() const { diff --git a/src/mongo/db/pipeline/document_source_limit.cpp b/src/mongo/db/pipeline/document_source_limit.cpp index f50e795897d..c83c33f5f8f 100644 --- a/src/mongo/db/pipeline/document_source_limit.cpp +++ b/src/mongo/db/pipeline/document_source_limit.cpp @@ -88,7 +88,10 @@ DocumentSource::GetNextResult DocumentSourceLimit::doGetNext() { return nextInput; } -Value DocumentSourceLimit::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceLimit::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484331); + } return Value(Document{{getSourceName(), _limit}}); } diff --git a/src/mongo/db/pipeline/document_source_limit.h b/src/mongo/db/pipeline/document_source_limit.h index 67c4e634efc..a080b832ee3 100644 --- a/src/mongo/db/pipeline/document_source_limit.h +++ b/src/mongo/db/pipeline/document_source_limit.h @@ -69,11 +69,7 @@ public: */ Pipeline::SourceContainer::iterator doOptimizeAt(Pipeline::SourceContainer::iterator itr, Pipeline::SourceContainer* container) final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; DepsTracker::State getDependencies(DepsTracker* deps) const final { return DepsTracker::State::SEE_NEXT; // This doesn't affect needed fields diff --git a/src/mongo/db/pipeline/document_source_list_cached_and_active_users.h b/src/mongo/db/pipeline/document_source_list_cached_and_active_users.h index 8dc487b7f35..a9a31707a77 100644 --- a/src/mongo/db/pipeline/document_source_list_cached_and_active_users.h +++ b/src/mongo/db/pipeline/document_source_list_cached_and_active_users.h @@ -87,14 +87,13 @@ public: return kStageName.rawData(); } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final { + Value serialize(SerializationOptions opts = SerializationOptions()) const final override { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484330); + } return Value(Document{{getSourceName(), Document{}}}); } - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } - StageConstraints constraints(Pipeline::SplitState pipeState) const final { StageConstraints constraints(StreamType::kStreaming, PositionRequirement::kFirst, diff --git a/src/mongo/db/pipeline/document_source_list_catalog.cpp b/src/mongo/db/pipeline/document_source_list_catalog.cpp index 8c536e39c01..9e8ce37e515 100644 --- a/src/mongo/db/pipeline/document_source_list_catalog.cpp +++ b/src/mongo/db/pipeline/document_source_list_catalog.cpp @@ -118,8 +118,10 @@ intrusive_ptr<DocumentSource> DocumentSourceListCatalog::createFromBson( return new DocumentSourceListCatalog(pExpCtx); } -Value DocumentSourceListCatalog::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceListCatalog::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484329); + } return Value(DOC(getSourceName() << Document())); } } // namespace mongo diff --git a/src/mongo/db/pipeline/document_source_list_catalog.h b/src/mongo/db/pipeline/document_source_list_catalog.h index 8eaee46975a..f42bce56a04 100644 --- a/src/mongo/db/pipeline/document_source_list_catalog.h +++ b/src/mongo/db/pipeline/document_source_list_catalog.h @@ -75,11 +75,7 @@ public: // virtuals from DocumentSource const char* getSourceName() const final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; StageConstraints constraints(Pipeline::SplitState pipeState) const final { StageConstraints constraints(StreamType::kStreaming, diff --git a/src/mongo/db/pipeline/document_source_list_local_sessions.h b/src/mongo/db/pipeline/document_source_list_local_sessions.h index 7416fe25512..d3c8c47d127 100644 --- a/src/mongo/db/pipeline/document_source_list_local_sessions.h +++ b/src/mongo/db/pipeline/document_source_list_local_sessions.h @@ -101,14 +101,13 @@ public: return DocumentSourceListLocalSessions::kStageName.rawData(); } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final { + Value serialize(SerializationOptions opts = SerializationOptions()) const final override { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484328); + } return Value(Document{{getSourceName(), _spec.toBSON()}}); } - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } - StageConstraints constraints(Pipeline::SplitState pipeState) const final { StageConstraints constraints(StreamType::kStreaming, PositionRequirement::kFirst, diff --git a/src/mongo/db/pipeline/document_source_list_sessions.cpp b/src/mongo/db/pipeline/document_source_list_sessions.cpp index 40d279f3c15..e1f2ea650a3 100644 --- a/src/mongo/db/pipeline/document_source_list_sessions.cpp +++ b/src/mongo/db/pipeline/document_source_list_sessions.cpp @@ -74,8 +74,10 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceListSessions::createFromBson( return new DocumentSourceListSessions(query, pExpCtx, spec.getAllUsers(), spec.getUsers()); } -Value DocumentSourceListSessions::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceListSessions::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484327); + } ListSessionsSpec spec; spec.setAllUsers(_allUsers); spec.setUsers(_users); diff --git a/src/mongo/db/pipeline/document_source_list_sessions.h b/src/mongo/db/pipeline/document_source_list_sessions.h index b48c2954d1c..cc19525e9f2 100644 --- a/src/mongo/db/pipeline/document_source_list_sessions.h +++ b/src/mongo/db/pipeline/document_source_list_sessions.h @@ -98,11 +98,7 @@ public: return DocumentSourceListSessions::kStageName.rawData(); } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - }; + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; StageConstraints constraints(Pipeline::SplitState pipeState) const final { return {StreamType::kStreaming, diff --git a/src/mongo/db/pipeline/document_source_lookup.cpp b/src/mongo/db/pipeline/document_source_lookup.cpp index a363c13ab66..5a9bfc481d7 100644 --- a/src/mongo/db/pipeline/document_source_lookup.cpp +++ b/src/mongo/db/pipeline/document_source_lookup.cpp @@ -1011,8 +1011,12 @@ void DocumentSourceLookUp::appendSpecificExecStats(MutableDocument& doc) const { doc["indexesUsed"] = Value{std::move(indexesUsedVec)}; } -void DocumentSourceLookUp::serializeToArray( - std::vector<Value>& array, boost::optional<ExplainOptions::Verbosity> explain) const { +void DocumentSourceLookUp::serializeToArray(std::vector<Value>& array, + SerializationOptions opts) const { + auto explain = opts.verbosity; + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484326); + } // Support alternative $lookup from config.cache.chunks* namespaces. // @@ -1038,8 +1042,7 @@ void DocumentSourceLookUp::serializeToArray( if (!hasLocalFieldForeignFieldJoin() || pipeline.size() > 0) { MutableDocument exprList; for (const auto& letVar : _letVariables) { - exprList.addField(letVar.name, - letVar.expression->serialize(static_cast<bool>(explain))); + exprList.addField(letVar.name, letVar.expression->serialize(explain)); } output[getSourceName()]["let"] = Value(exprList.freeze()); diff --git a/src/mongo/db/pipeline/document_source_lookup.h b/src/mongo/db/pipeline/document_source_lookup.h index 15bb07263c2..ca8c79798bd 100644 --- a/src/mongo/db/pipeline/document_source_lookup.h +++ b/src/mongo/db/pipeline/document_source_lookup.h @@ -123,14 +123,8 @@ public: const boost::intrusive_ptr<ExpressionContext>&); const char* getSourceName() const final; - void serializeToArray( - std::vector<Value>& array, - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - void serializeToArray(std::vector<Value>& array, - SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - }; + SerializationOptions opts = SerializationOptions()) const final override; /** * Returns the 'as' path, and possibly fields modified by an absorbed $unwind. @@ -310,12 +304,8 @@ private: /** * Should not be called; use serializeToArray instead. */ - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final { - MONGO_UNREACHABLE; - } - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; + Value serialize(SerializationOptions opts = SerializationOptions()) const final override { + MONGO_UNREACHABLE_TASSERT(7484304); } GetNextResult unwindResult(); diff --git a/src/mongo/db/pipeline/document_source_match.cpp b/src/mongo/db/pipeline/document_source_match.cpp index 3deaf5ab453..d8bde7db83d 100644 --- a/src/mongo/db/pipeline/document_source_match.cpp +++ b/src/mongo/db/pipeline/document_source_match.cpp @@ -68,7 +68,12 @@ const char* DocumentSourceMatch::getSourceName() const { return kStageName.rawData(); } -Value DocumentSourceMatch::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceMatch::serialize(SerializationOptions opts) const { + auto explain = opts.verbosity; + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484325); + } + if (explain) { return Value(DOC(getSourceName() << Document(_expression->serialize()))); } diff --git a/src/mongo/db/pipeline/document_source_match.h b/src/mongo/db/pipeline/document_source_match.h index bd26cc05235..15682350f36 100644 --- a/src/mongo/db/pipeline/document_source_match.h +++ b/src/mongo/db/pipeline/document_source_match.h @@ -126,12 +126,7 @@ public: ChangeStreamRequirement::kAllowlist}; } - Value serialize( - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const override; - - Value serialize(SerializationOptions opts) const override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const override; /** * Attempts to combine with any subsequent $match stages, joining the query objects with a diff --git a/src/mongo/db/pipeline/document_source_merge.cpp b/src/mongo/db/pipeline/document_source_merge.cpp index c407cf96ba8..48052af235f 100644 --- a/src/mongo/db/pipeline/document_source_merge.cpp +++ b/src/mongo/db/pipeline/document_source_merge.cpp @@ -531,7 +531,12 @@ boost::optional<DocumentSource::DistributedPlanLogic> DocumentSourceMerge::distr return DocumentSourceWriter::distributedPlanLogic(); } -Value DocumentSourceMerge::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceMerge::serialize(SerializationOptions opts) const { + auto explain = opts.verbosity; + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484324); + } + DocumentSourceMergeSpec spec; spec.setTargetNss(_outputNs); spec.setLet([&]() -> boost::optional<BSONObj> { @@ -541,7 +546,7 @@ Value DocumentSourceMerge::serialize(boost::optional<ExplainOptions::Verbosity> BSONObjBuilder bob; for (auto&& [name, expr] : *_letVariables) { - bob << name << expr->serialize(static_cast<bool>(explain)); + bob << name << expr->serialize(explain); } return bob.obj(); }()); diff --git a/src/mongo/db/pipeline/document_source_merge.h b/src/mongo/db/pipeline/document_source_merge.h index 15b4b8c90cb..b0eed7a6df9 100644 --- a/src/mongo/db/pipeline/document_source_merge.h +++ b/src/mongo/db/pipeline/document_source_merge.h @@ -128,11 +128,7 @@ public: boost::optional<DistributedPlanLogic> distributedPlanLogic() final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; /** * Creates a new $merge stage from the given arguments. diff --git a/src/mongo/db/pipeline/document_source_mock.h b/src/mongo/db/pipeline/document_source_mock.h index 5d0fb3e303b..7ce320049f4 100644 --- a/src/mongo/db/pipeline/document_source_mock.h +++ b/src/mongo/db/pipeline/document_source_mock.h @@ -75,16 +75,14 @@ public: DocumentSourceMock(std::deque<GetNextResult>, const boost::intrusive_ptr<ExpressionContext>&); - Value serialize( - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const override { + Value serialize(SerializationOptions opts = SerializationOptions()) const final override { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484323); + } // Unlike the queue, it's okay to serialize this stage for testing purposes. return Value(Document{{getSourceName(), Document()}}); } - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } - const char* getSourceName() const override; size_t size() const; diff --git a/src/mongo/db/pipeline/document_source_operation_metrics.cpp b/src/mongo/db/pipeline/document_source_operation_metrics.cpp index 03fc1bd680e..915add9f8b7 100644 --- a/src/mongo/db/pipeline/document_source_operation_metrics.cpp +++ b/src/mongo/db/pipeline/document_source_operation_metrics.cpp @@ -113,8 +113,10 @@ intrusive_ptr<DocumentSource> DocumentSourceOperationMetrics::createFromBson( return new DocumentSourceOperationMetrics(pExpCtx, clearMetrics); } -Value DocumentSourceOperationMetrics::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceOperationMetrics::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484322); + } return Value(DOC(getSourceName() << Document())); } } // namespace mongo diff --git a/src/mongo/db/pipeline/document_source_operation_metrics.h b/src/mongo/db/pipeline/document_source_operation_metrics.h index a4ac1511074..2a1e9ecfec2 100644 --- a/src/mongo/db/pipeline/document_source_operation_metrics.h +++ b/src/mongo/db/pipeline/document_source_operation_metrics.h @@ -89,11 +89,7 @@ public: return boost::none; } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; void addVariableRefs(std::set<Variables::Id>* refs) const final {} diff --git a/src/mongo/db/pipeline/document_source_out.cpp b/src/mongo/db/pipeline/document_source_out.cpp index 84d95418444..1864a8b1629 100644 --- a/src/mongo/db/pipeline/document_source_out.cpp +++ b/src/mongo/db/pipeline/document_source_out.cpp @@ -291,7 +291,11 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceOut::createFromBson( return create(std::move(targetNss), expCtx, std::move(outSpec.getTimeseries())); } -Value DocumentSourceOut::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceOut::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484321); + } + // Do not include the tenantId in the serialized 'outputNs'. return Value(Document{{getSourceName(), Document{{"db", _outputNs.dbName().db()}, diff --git a/src/mongo/db/pipeline/document_source_out.h b/src/mongo/db/pipeline/document_source_out.h index 99ae32a377b..f8257d7acce 100644 --- a/src/mongo/db/pipeline/document_source_out.h +++ b/src/mongo/db/pipeline/document_source_out.h @@ -92,12 +92,7 @@ public: UnionRequirement::kNotAllowed}; } - Value serialize( - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final override; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; /** * Creates a new $out stage from the given arguments. diff --git a/src/mongo/db/pipeline/document_source_plan_cache_stats.cpp b/src/mongo/db/pipeline/document_source_plan_cache_stats.cpp index 51f7bf3d650..e942cab149c 100644 --- a/src/mongo/db/pipeline/document_source_plan_cache_stats.cpp +++ b/src/mongo/db/pipeline/document_source_plan_cache_stats.cpp @@ -57,9 +57,13 @@ DocumentSourcePlanCacheStats::DocumentSourcePlanCacheStats( const boost::intrusive_ptr<ExpressionContext>& expCtx) : DocumentSource(kStageName, expCtx) {} -void DocumentSourcePlanCacheStats::serializeToArray( - std::vector<Value>& array, boost::optional<ExplainOptions::Verbosity> explain) const { - if (explain) { +void DocumentSourcePlanCacheStats::serializeToArray(std::vector<Value>& array, + SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484320); + } + + if (opts.verbosity) { array.push_back(Value{ Document{{kStageName, Document{{"match"_sd, diff --git a/src/mongo/db/pipeline/document_source_plan_cache_stats.h b/src/mongo/db/pipeline/document_source_plan_cache_stats.h index 81bce911e77..9f6d432640d 100644 --- a/src/mongo/db/pipeline/document_source_plan_cache_stats.h +++ b/src/mongo/db/pipeline/document_source_plan_cache_stats.h @@ -115,14 +115,8 @@ public: Pipeline::SourceContainer::iterator doOptimizeAt(Pipeline::SourceContainer::iterator itr, Pipeline::SourceContainer* container) override; - void serializeToArray( - std::vector<Value>& array, - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const override; - void serializeToArray(std::vector<Value>& array, - SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - }; + SerializationOptions opts = SerializationOptions()) const final override; void addVariableRefs(std::set<Variables::Id>* refs) const final {} @@ -131,13 +125,8 @@ private: GetNextResult doGetNext() final; - Value serialize( - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const override { - MONGO_UNREACHABLE; // Should call serializeToArray instead. - } - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; + Value serialize(SerializationOptions opts = SerializationOptions()) const final override { + MONGO_UNREACHABLE_TASSERT(7484303); // Should call serializeToArray instead. } // If running through mongos in a sharded cluster, stores the shard name so that it can be diff --git a/src/mongo/db/pipeline/document_source_queue.cpp b/src/mongo/db/pipeline/document_source_queue.cpp index b5c4e1f80f5..3d3019188c1 100644 --- a/src/mongo/db/pipeline/document_source_queue.cpp +++ b/src/mongo/db/pipeline/document_source_queue.cpp @@ -80,7 +80,11 @@ DocumentSource::GetNextResult DocumentSourceQueue::doGetNext() { return next; } -Value DocumentSourceQueue::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceQueue::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484319); + } + ValueArrayStream vals; for (const auto& elem : _queue) { vals << elem.getDocument().getOwned(); diff --git a/src/mongo/db/pipeline/document_source_queue.h b/src/mongo/db/pipeline/document_source_queue.h index 42b4227b612..7ca536a6e17 100644 --- a/src/mongo/db/pipeline/document_source_queue.h +++ b/src/mongo/db/pipeline/document_source_queue.h @@ -55,11 +55,7 @@ public: const char* getSourceName() const override; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const override; - - Value serialize(SerializationOptions opts) const override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const override; StageConstraints constraints(Pipeline::SplitState pipeState) const override { StageConstraints constraints{StreamType::kStreaming, diff --git a/src/mongo/db/pipeline/document_source_queue_test.cpp b/src/mongo/db/pipeline/document_source_queue_test.cpp index b7014bd3166..f33a1e385f4 100644 --- a/src/mongo/db/pipeline/document_source_queue_test.cpp +++ b/src/mongo/db/pipeline/document_source_queue_test.cpp @@ -73,7 +73,7 @@ TEST_F(QueueStageTest, QueueStageSerialize) { ASSERT_TRUE(queueStage); - auto res = queueStage->serialize(boost::none); + auto res = queueStage->serialize(); ASSERT_VALUE_EQ(res, Value{DOC("$queue" << DOC_ARRAY(DOC("a1" << 1) << DOC("a2" << 2)))}); } diff --git a/src/mongo/db/pipeline/document_source_redact.cpp b/src/mongo/db/pipeline/document_source_redact.cpp index 80dc406c620..da0aecee671 100644 --- a/src/mongo/db/pipeline/document_source_redact.cpp +++ b/src/mongo/db/pipeline/document_source_redact.cpp @@ -169,8 +169,11 @@ intrusive_ptr<DocumentSource> DocumentSourceRedact::optimize() { return this; } -Value DocumentSourceRedact::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { - return Value(DOC(getSourceName() << _expression.get()->serialize(static_cast<bool>(explain)))); +Value DocumentSourceRedact::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484318); + } + return Value(DOC(getSourceName() << _expression.get()->serialize(opts))); } intrusive_ptr<DocumentSource> DocumentSourceRedact::createFromBson( diff --git a/src/mongo/db/pipeline/document_source_redact.h b/src/mongo/db/pipeline/document_source_redact.h index c6d5224931e..69d4b12f0a3 100644 --- a/src/mongo/db/pipeline/document_source_redact.h +++ b/src/mongo/db/pipeline/document_source_redact.h @@ -67,11 +67,7 @@ public: static boost::intrusive_ptr<DocumentSource> createFromBson( BSONElement elem, const boost::intrusive_ptr<ExpressionContext>& expCtx); - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; boost::intrusive_ptr<Expression> getExpression() { return _expression; diff --git a/src/mongo/db/pipeline/document_source_replace_root.h b/src/mongo/db/pipeline/document_source_replace_root.h index 16c76713d87..5f81375d657 100644 --- a/src/mongo/db/pipeline/document_source_replace_root.h +++ b/src/mongo/db/pipeline/document_source_replace_root.h @@ -63,7 +63,7 @@ public: Document serializeTransformation(boost::optional<ExplainOptions::Verbosity> explain, SerializationOptions options = {}) const final { - return Document{{"newRoot", _newRoot->serialize(static_cast<bool>(explain))}}; + return Document{{"newRoot", _newRoot->serialize(explain)}}; } DepsTracker::State addDependencies(DepsTracker* deps) const final { diff --git a/src/mongo/db/pipeline/document_source_sample.cpp b/src/mongo/db/pipeline/document_source_sample.cpp index 24e86b38cba..c2df7d43286 100644 --- a/src/mongo/db/pipeline/document_source_sample.cpp +++ b/src/mongo/db/pipeline/document_source_sample.cpp @@ -83,7 +83,10 @@ DocumentSource::GetNextResult DocumentSourceSample::doGetNext() { return _sortStage->getNext(); } -Value DocumentSourceSample::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceSample::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484317); + } return Value(DOC(kStageName << DOC("size" << _size))); } diff --git a/src/mongo/db/pipeline/document_source_sample.h b/src/mongo/db/pipeline/document_source_sample.h index a4af7d94b31..160525fd0e4 100644 --- a/src/mongo/db/pipeline/document_source_sample.h +++ b/src/mongo/db/pipeline/document_source_sample.h @@ -41,11 +41,7 @@ public: const char* getSourceName() const final { return kStageName.rawData(); } - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; StageConstraints constraints(Pipeline::SplitState pipeState) const final { return {StreamType::kBlocking, diff --git a/src/mongo/db/pipeline/document_source_sample_from_random_cursor.cpp b/src/mongo/db/pipeline/document_source_sample_from_random_cursor.cpp index 885cbed6132..34ee86d4c80 100644 --- a/src/mongo/db/pipeline/document_source_sample_from_random_cursor.cpp +++ b/src/mongo/db/pipeline/document_source_sample_from_random_cursor.cpp @@ -145,8 +145,10 @@ DocumentSource::GetNextResult DocumentSourceSampleFromRandomCursor::getNextNonDu "sporadic failure, please try again."); } -Value DocumentSourceSampleFromRandomCursor::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceSampleFromRandomCursor::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484316); + } return Value(DOC(getSourceName() << DOC("size" << _size))); } diff --git a/src/mongo/db/pipeline/document_source_sample_from_random_cursor.h b/src/mongo/db/pipeline/document_source_sample_from_random_cursor.h index 5f5d4da226a..e58fd5cea84 100644 --- a/src/mongo/db/pipeline/document_source_sample_from_random_cursor.h +++ b/src/mongo/db/pipeline/document_source_sample_from_random_cursor.h @@ -42,10 +42,7 @@ class DocumentSourceSampleFromRandomCursor final : public DocumentSource { public: static constexpr StringData kStageName = "$sampleFromRandomCursor"_sd; const char* getSourceName() const final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; DepsTracker::State getDependencies(DepsTracker* deps) const final; StageConstraints constraints(Pipeline::SplitState pipeState) const final { diff --git a/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp b/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp index fa0c9f759e2..5fd98a6d381 100644 --- a/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp +++ b/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp @@ -155,9 +155,11 @@ Pipeline::SourceContainer::iterator DocumentSourceSequentialDocumentCache::doOpt return container->end(); } -Value DocumentSourceSequentialDocumentCache::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { - if (explain) { +Value DocumentSourceSequentialDocumentCache::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484315); + } + if (opts.verbosity) { return Value(Document{ {kStageName, Document{{"maxSizeBytes"_sd, Value(static_cast<long long>(_cache->maxSizeBytes()))}, diff --git a/src/mongo/db/pipeline/document_source_sequential_document_cache.h b/src/mongo/db/pipeline/document_source_sequential_document_cache.h index 139f60c3ff5..61eb0bd273b 100644 --- a/src/mongo/db/pipeline/document_source_sequential_document_cache.h +++ b/src/mongo/db/pipeline/document_source_sequential_document_cache.h @@ -108,11 +108,7 @@ private: DocumentSourceSequentialDocumentCache(const boost::intrusive_ptr<ExpressionContext>& expCtx, SequentialDocumentCache* cache); - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; SequentialDocumentCache* _cache; diff --git a/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp b/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp index e5ab4b9c597..010e4685a8a 100644 --- a/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp +++ b/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp @@ -53,13 +53,16 @@ REGISTER_INTERNAL_DOCUMENT_SOURCE(setVariableFromSubPipeline, DocumentSourceSetVariableFromSubPipeline::createFromBson, true); -Value DocumentSourceSetVariableFromSubPipeline::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceSetVariableFromSubPipeline::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484314); + } + const auto var = "$$" + Variables::getBuiltinVariableName(_variableID); SetVariableFromSubPipelineSpec spec; tassert(625298, "SubPipeline cannot be null during serialization", _subPipeline); spec.setSetVariable(var); - spec.setPipeline(_subPipeline->serializeToBson(explain)); + spec.setPipeline(_subPipeline->serializeToBson(opts.verbosity)); return Value(DOC(getSourceName() << spec.toBSON())); } diff --git a/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.h b/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.h index 3c978ed532e..2a9d570aa39 100644 --- a/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.h +++ b/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.h @@ -112,10 +112,7 @@ protected: private: GetNextResult doGetNext() final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; std::unique_ptr<Pipeline, PipelineDeleter> _subPipeline; Variables::Id _variableID; // $setVariableFromSubPipeline sets the value of $$SEARCH_META only on the first call to diff --git a/src/mongo/db/pipeline/document_source_set_window_fields.cpp b/src/mongo/db/pipeline/document_source_set_window_fields.cpp index e044a07d69f..e4da78f582f 100644 --- a/src/mongo/db/pipeline/document_source_set_window_fields.cpp +++ b/src/mongo/db/pipeline/document_source_set_window_fields.cpp @@ -283,8 +283,12 @@ intrusive_ptr<DocumentSource> DocumentSourceInternalSetWindowFields::optimize() return this; } -Value DocumentSourceInternalSetWindowFields::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceInternalSetWindowFields::serialize(SerializationOptions opts) const { + auto explain = opts.verbosity; + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484313); + } + MutableDocument spec; spec[SetWindowFieldsSpec::kPartitionByFieldName] = _partitionBy ? (*_partitionBy)->serialize(false) : Value(); diff --git a/src/mongo/db/pipeline/document_source_set_window_fields.h b/src/mongo/db/pipeline/document_source_set_window_fields.h index ec04e27af42..ea58ada0ff3 100644 --- a/src/mongo/db/pipeline/document_source_set_window_fields.h +++ b/src/mongo/db/pipeline/document_source_set_window_fields.h @@ -184,11 +184,7 @@ public: boost::intrusive_ptr<DocumentSource> optimize() final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; DocumentSource::GetNextResult doGetNext(); diff --git a/src/mongo/db/pipeline/document_source_single_document_transformation.cpp b/src/mongo/db/pipeline/document_source_single_document_transformation.cpp index a8079a78994..109e0883b52 100644 --- a/src/mongo/db/pipeline/document_source_single_document_transformation.cpp +++ b/src/mongo/db/pipeline/document_source_single_document_transformation.cpp @@ -87,11 +87,15 @@ void DocumentSourceSingleDocumentTransformation::doDispose() { } } -Value DocumentSourceSingleDocumentTransformation::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { - return Value(Document{{getSourceName(), - _parsedTransform ? _parsedTransform->serializeTransformation(explain) - : _cachedStageOptions}}); +Value DocumentSourceSingleDocumentTransformation::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484312); + } + + return Value( + Document{{getSourceName(), + _parsedTransform ? _parsedTransform->serializeTransformation(opts.verbosity) + : _cachedStageOptions}}); } Pipeline::SourceContainer::iterator DocumentSourceSingleDocumentTransformation::doOptimizeAt( diff --git a/src/mongo/db/pipeline/document_source_single_document_transformation.h b/src/mongo/db/pipeline/document_source_single_document_transformation.h index e1dfb4401b0..c411e838726 100644 --- a/src/mongo/db/pipeline/document_source_single_document_transformation.h +++ b/src/mongo/db/pipeline/document_source_single_document_transformation.h @@ -62,10 +62,7 @@ public: const char* getSourceName() const final; boost::intrusive_ptr<DocumentSource> optimize() final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; DepsTracker::State getDependencies(DepsTracker* deps) const final; void addVariableRefs(std::set<Variables::Id>* refs) const final; GetModPathsReturn getModifiedPaths() const final; diff --git a/src/mongo/db/pipeline/document_source_skip.cpp b/src/mongo/db/pipeline/document_source_skip.cpp index df7537fd1dd..6eda5a592f5 100644 --- a/src/mongo/db/pipeline/document_source_skip.cpp +++ b/src/mongo/db/pipeline/document_source_skip.cpp @@ -72,7 +72,11 @@ DocumentSource::GetNextResult DocumentSourceSkip::doGetNext() { return pSource->getNext(); } -Value DocumentSourceSkip::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceSkip::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484311); + } + return Value(DOC(getSourceName() << _nToSkip)); } diff --git a/src/mongo/db/pipeline/document_source_skip.h b/src/mongo/db/pipeline/document_source_skip.h index d849fbef0fa..78060f7a363 100644 --- a/src/mongo/db/pipeline/document_source_skip.h +++ b/src/mongo/db/pipeline/document_source_skip.h @@ -73,11 +73,7 @@ public: Pipeline::SourceContainer::iterator doOptimizeAt(Pipeline::SourceContainer::iterator itr, Pipeline::SourceContainer* container) final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; boost::intrusive_ptr<DocumentSource> optimize() final; diff --git a/src/mongo/db/pipeline/document_source_sort.cpp b/src/mongo/db/pipeline/document_source_sort.cpp index c81b98fe0fa..bc6d90b7386 100644 --- a/src/mongo/db/pipeline/document_source_sort.cpp +++ b/src/mongo/db/pipeline/document_source_sort.cpp @@ -281,8 +281,13 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceSort::clone( _sortExecutor->getMaxMemoryBytes()); } -void DocumentSourceSort::serializeToArray( - std::vector<Value>& array, boost::optional<ExplainOptions::Verbosity> explain) const { +void DocumentSourceSort::serializeToArray(std::vector<Value>& array, + SerializationOptions opts) const { + auto explain = opts.verbosity; + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484310); + } + if (_timeSorter) { tassert(6369900, "$_internalBoundedSort should not absorb a $limit", diff --git a/src/mongo/db/pipeline/document_source_sort.h b/src/mongo/db/pipeline/document_source_sort.h index 104b0bdd621..32e72998d09 100644 --- a/src/mongo/db/pipeline/document_source_sort.h +++ b/src/mongo/db/pipeline/document_source_sort.h @@ -70,14 +70,8 @@ public: return kStageName.rawData(); } - void serializeToArray( - std::vector<Value>& array, - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - void serializeToArray(std::vector<Value>& array, - SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - }; + SerializationOptions opts = SerializationOptions()) const final override; boost::intrusive_ptr<DocumentSource> clone( const boost::intrusive_ptr<ExpressionContext>& newExpCtx) const final; @@ -212,12 +206,8 @@ private: uint64_t limit, uint64_t maxMemoryUsageBytes); - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final { - MONGO_UNREACHABLE; // Should call serializeToArray instead. - } - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; + MONGO_UNREACHABLE_TASSERT(7484302); // Should call serializeToArray instead. } /** diff --git a/src/mongo/db/pipeline/document_source_tee_consumer.cpp b/src/mongo/db/pipeline/document_source_tee_consumer.cpp index 739cec3498c..14135af4659 100644 --- a/src/mongo/db/pipeline/document_source_tee_consumer.cpp +++ b/src/mongo/db/pipeline/document_source_tee_consumer.cpp @@ -71,9 +71,12 @@ void DocumentSourceTeeConsumer::doDispose() { _bufferSource->dispose(_facetId); } -Value DocumentSourceTeeConsumer::serialize( - boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceTeeConsumer::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484309); + } + // We only serialize this stage in the context of explain. - return explain ? Value(DOC(_stageName << Document())) : Value(); + return opts.verbosity ? Value(DOC(_stageName << Document())) : Value(); } } // namespace mongo diff --git a/src/mongo/db/pipeline/document_source_tee_consumer.h b/src/mongo/db/pipeline/document_source_tee_consumer.h index 275cd680ab4..eaac8906326 100644 --- a/src/mongo/db/pipeline/document_source_tee_consumer.h +++ b/src/mongo/db/pipeline/document_source_tee_consumer.h @@ -81,11 +81,7 @@ public: const char* getSourceName() const override; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; protected: GetNextResult doGetNext() final; diff --git a/src/mongo/db/pipeline/document_source_telemetry.cpp b/src/mongo/db/pipeline/document_source_telemetry.cpp index 7e4eabfc100..cd08e8f3ba8 100644 --- a/src/mongo/db/pipeline/document_source_telemetry.cpp +++ b/src/mongo/db/pipeline/document_source_telemetry.cpp @@ -95,7 +95,11 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceTelemetry::createFromBson( parseTelemetryEmbeddedObject(spec.embeddedObject())); } -Value DocumentSourceTelemetry::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceTelemetry::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484308); + } + return Value{Document{{kStageName, Document{}}}}; } diff --git a/src/mongo/db/pipeline/document_source_telemetry.h b/src/mongo/db/pipeline/document_source_telemetry.h index 0e89484dfd4..befd91851de 100644 --- a/src/mongo/db/pipeline/document_source_telemetry.h +++ b/src/mongo/db/pipeline/document_source_telemetry.h @@ -106,12 +106,7 @@ public: return kStageName.rawData(); } - Value serialize( - boost::optional<ExplainOptions::Verbosity> explain = boost::none) const override; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; void addVariableRefs(std::set<Variables::Id>* refs) const final {} diff --git a/src/mongo/db/pipeline/document_source_test_optimizations.h b/src/mongo/db/pipeline/document_source_test_optimizations.h index a2c28664c36..7e0c6d4770e 100644 --- a/src/mongo/db/pipeline/document_source_test_optimizations.h +++ b/src/mongo/db/pipeline/document_source_test_optimizations.h @@ -73,11 +73,9 @@ public: void addVariableRefs(std::set<Variables::Id>* refs) const final {} private: - virtual Value serialize(boost::optional<ExplainOptions::Verbosity>) const override { - MONGO_UNREACHABLE; - } - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; + virtual Value serialize( + SerializationOptions opts = SerializationOptions()) const final override { + MONGO_UNREACHABLE_TASSERT(7484301); } }; diff --git a/src/mongo/db/pipeline/document_source_union_with.cpp b/src/mongo/db/pipeline/document_source_union_with.cpp index f6f9707f92e..f8d61a9e061 100644 --- a/src/mongo/db/pipeline/document_source_union_with.cpp +++ b/src/mongo/db/pipeline/document_source_union_with.cpp @@ -322,7 +322,12 @@ void DocumentSourceUnionWith::doDispose() { } } -Value DocumentSourceUnionWith::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceUnionWith::serialize(SerializationOptions opts) const { + auto explain = opts.verbosity; + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484307); + } + auto collectionless = _pipeline->getContext()->ns.isCollectionlessAggregateNS(); if (explain) { // There are several different possible states depending on the explain verbosity as well as diff --git a/src/mongo/db/pipeline/document_source_union_with.h b/src/mongo/db/pipeline/document_source_union_with.h index 6be0d606ddb..3b1dbb194e5 100644 --- a/src/mongo/db/pipeline/document_source_union_with.h +++ b/src/mongo/db/pipeline/document_source_union_with.h @@ -190,11 +190,7 @@ private: kFinished }; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; void addViewDefinition(NamespaceString nss, std::vector<BSONObj> viewPipeline); diff --git a/src/mongo/db/pipeline/document_source_unwind.cpp b/src/mongo/db/pipeline/document_source_unwind.cpp index 6f4599ffa59..950062204fc 100644 --- a/src/mongo/db/pipeline/document_source_unwind.cpp +++ b/src/mongo/db/pipeline/document_source_unwind.cpp @@ -293,7 +293,11 @@ Pipeline::SourceContainer::iterator DocumentSourceUnwind::doOptimizeAt( return std::next(itr); } -Value DocumentSourceUnwind::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { +Value DocumentSourceUnwind::serialize(SerializationOptions opts) const { + if (opts.redactFieldNames || opts.replacementForLiteralArgs) { + MONGO_UNIMPLEMENTED_TASSERT(7484306); + } + return Value(DOC(getSourceName() << DOC( "path" << _unwindPath.fullPathWithPrefix() << "preserveNullAndEmptyArrays" << (_preserveNullAndEmptyArrays ? Value(true) : Value()) diff --git a/src/mongo/db/pipeline/document_source_unwind.h b/src/mongo/db/pipeline/document_source_unwind.h index d525eb951f2..f2b97085d33 100644 --- a/src/mongo/db/pipeline/document_source_unwind.h +++ b/src/mongo/db/pipeline/document_source_unwind.h @@ -43,11 +43,7 @@ public: // virtuals from DocumentSource const char* getSourceName() const final; - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final; - - Value serialize(SerializationOptions opts) const final override { - MONGO_UNIMPLEMENTED; - } + Value serialize(SerializationOptions opts = SerializationOptions()) const final override; /** * Returns the unwound path, and the 'includeArrayIndex' path, if specified. diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp index 008a93c5ac5..6cdc08bca0c 100644 --- a/src/mongo/db/pipeline/expression.cpp +++ b/src/mongo/db/pipeline/expression.cpp @@ -976,7 +976,7 @@ Value ExpressionCoerceToBool::evaluate(const Document& root, Variables* variable Value ExpressionCoerceToBool::serialize(SerializationOptions options) const { // When not explaining, serialize to an $and expression. When parsed, the $and expression // will be optimized back into a ExpressionCoerceToBool. - const char* name = options.explain ? "$coerceToBool" : "$and"; + const char* name = options.verbosity ? "$coerceToBool" : "$and"; return Value(DOC(name << DOC_ARRAY(_children[_kExpression]->serialize(options)))); } diff --git a/src/mongo/db/pipeline/expression.h b/src/mongo/db/pipeline/expression.h index 179d01bcb86..803102f3760 100644 --- a/src/mongo/db/pipeline/expression.h +++ b/src/mongo/db/pipeline/expression.h @@ -208,7 +208,7 @@ public: * If 'explain' is false, the returned Value must result in the same Expression when parsed by * parseOperand(). */ - virtual Value serialize(SerializationOptions options) const = 0; + virtual Value serialize(SerializationOptions options = SerializationOptions()) const = 0; /** * Evaluate the expression with respect to the Document given by 'root' and the Variables given diff --git a/src/mongo/db/pipeline/group_from_first_document_transformation.cpp b/src/mongo/db/pipeline/group_from_first_document_transformation.cpp index 68ef20cb2e1..ebf7ca8fd94 100644 --- a/src/mongo/db/pipeline/group_from_first_document_transformation.cpp +++ b/src/mongo/db/pipeline/group_from_first_document_transformation.cpp @@ -52,7 +52,7 @@ Document GroupFromFirstDocumentTransformation::serializeTransformation( MutableDocument newRoot(_accumulatorExprs.size()); for (auto&& expr : _accumulatorExprs) { - newRoot.addField(expr.first, expr.second->serialize(static_cast<bool>(explain))); + newRoot.addField(expr.first, expr.second->serialize(explain)); } return {{"newRoot", newRoot.freezeToValue()}}; diff --git a/src/mongo/db/pipeline/window_function/window_function_expression.cpp b/src/mongo/db/pipeline/window_function/window_function_expression.cpp index b7fefdb2fc2..125bb1fd009 100644 --- a/src/mongo/db/pipeline/window_function/window_function_expression.cpp +++ b/src/mongo/db/pipeline/window_function/window_function_expression.cpp @@ -277,7 +277,7 @@ template <typename WindowFunctionN, typename AccumulatorNType> Value ExpressionN<WindowFunctionN, AccumulatorNType>::serialize( boost::optional<ExplainOptions::Verbosity> explain) const { auto acc = buildAccumulatorOnly(); - MutableDocument result(acc->serialize(nExpr, _input, static_cast<bool>(explain))); + MutableDocument result(acc->serialize(nExpr, _input, explain)); MutableDocument windowField; _bounds.serialize(windowField); diff --git a/src/mongo/db/pipeline/window_function/window_function_expression.h b/src/mongo/db/pipeline/window_function/window_function_expression.h index 8554963fd42..f6dc5272a6f 100644 --- a/src/mongo/db/pipeline/window_function/window_function_expression.h +++ b/src/mongo/db/pipeline/window_function/window_function_expression.h @@ -203,7 +203,7 @@ public: virtual Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const { MutableDocument args; - args[_accumulatorName] = _input->serialize(static_cast<bool>(explain)); + args[_accumulatorName] = _input->serialize(explain); MutableDocument windowField; _bounds.serialize(windowField); args[kWindowArg] = windowField.freezeToValue(); @@ -339,7 +339,7 @@ public: Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const final { MutableDocument args; - args.addField(_accumulatorName, Value(_input->serialize(static_cast<bool>(explain)))); + args.addField(_accumulatorName, Value(_input->serialize(explain))); return args.freezeToValue(); } }; @@ -512,7 +512,7 @@ public: } else { subObj[kAlphaArg] = Value(_alpha.get()); } - subObj[kInputArg] = _input->serialize(static_cast<bool>(explain)); + subObj[kInputArg] = _input->serialize(explain); MutableDocument outerObj; outerObj[kAccName] = subObj.freezeToValue(); return outerObj.freezeToValue(); @@ -541,7 +541,7 @@ public: Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const final { MutableDocument result; - result[_accumulatorName][kArgInput] = _input->serialize(static_cast<bool>(explain)); + result[_accumulatorName][kArgInput] = _input->serialize(explain); if (_unit) { result[_accumulatorName][kArgUnit] = Value(serializeTimeUnit(*_unit)); } @@ -823,7 +823,7 @@ public: Value serialize(boost::optional<ExplainOptions::Verbosity> explain) const final { MutableDocument args; - args.addField(_accumulatorName, Value(_input->serialize(static_cast<bool>(explain)))); + args.addField(_accumulatorName, Value(_input->serialize(explain))); return args.freezeToValue(); } }; diff --git a/src/mongo/db/pipeline/window_function/window_function_shift.cpp b/src/mongo/db/pipeline/window_function/window_function_shift.cpp index c74424e74e7..52409a0afa6 100644 --- a/src/mongo/db/pipeline/window_function/window_function_shift.cpp +++ b/src/mongo/db/pipeline/window_function/window_function_shift.cpp @@ -122,7 +122,7 @@ boost::intrusive_ptr<Expression> ExpressionShift::parse(BSONObj obj, Value ExpressionShift::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { MutableDocument args; args.addField(kByArg, Value(_offset)); - args.addField(kOutputArg, _input->serialize(static_cast<bool>(explain))); + args.addField(kOutputArg, _input->serialize(explain)); args.addField(kDefaultArg, _defaultVal.get_value_or(mongo::Value(BSONNULL))); MutableDocument windowFun; |