diff options
Diffstat (limited to 'src/mongo/db/pipeline/document_source.h')
| -rw-r--r-- | src/mongo/db/pipeline/document_source.h | 60 |
1 files changed, 26 insertions, 34 deletions
diff --git a/src/mongo/db/pipeline/document_source.h b/src/mongo/db/pipeline/document_source.h index 4e4a5bfdadd..ee3977aed18 100644 --- a/src/mongo/db/pipeline/document_source.h +++ b/src/mongo/db/pipeline/document_source.h @@ -319,8 +319,8 @@ public: * original's 'ExpressionContext'. */ virtual boost::intrusive_ptr<DocumentSource> clone( - const boost::intrusive_ptr<ExpressionContext>& expCtx) const { - tassert(7406001, "expCtx passed to clone must not be null", expCtx); + const boost::intrusive_ptr<ExpressionContext>& newExpCtx = nullptr) const { + auto expCtx = newExpCtx ? newExpCtx : pExpCtx; std::vector<Value> serializedDoc; serializeToArray(serializedDoc); tassert(5757900, @@ -381,16 +381,6 @@ public: Pipeline::SplitState = Pipeline::SplitState::kUnsplit) const = 0; /** - * If a stage's StageConstraints::PositionRequirement is kCustom, then it should also override - * this method, which will be called by the validation process. - */ - virtual void validatePipelinePosition(bool alreadyOptimized, - Pipeline::SourceContainer::const_iterator pos, - const Pipeline::SourceContainer& container) const { - MONGO_UNIMPLEMENTED_TASSERT(7183905); - }; - - /** * Informs the stage that it is no longer needed and can release its resources. After dispose() * is called the stage must still be able to handle calls to getNext(), but can return kEOF. * @@ -437,9 +427,13 @@ 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. */ - virtual void serializeToArray(std::vector<Value>& array, - const SerializationOptions& opts = SerializationOptions{}) const; + virtual void serializeToArray( + std::vector<Value>& array, + boost::optional<ExplainOptions::Verbosity> explain = boost::none) const; /** * Shortcut method to get a BSONObj for debugging. Often useful in log messages, but is not @@ -458,14 +452,6 @@ public: virtual void reattachToOperationContext(OperationContext* opCtx) {} - /** - * Validate that all operation contexts associated with this document source, including any - * subpipelines, match the argument. - */ - virtual bool validateOperationContext(const OperationContext* opCtx) const { - return getContext()->opCtx == opCtx; - } - virtual bool usedDisk() { return false; }; @@ -537,15 +523,15 @@ private: Pipeline::SourceContainer* container); /** - * Attempts to push any kind of 'DocumentSourceSingleDocumentTransformation' stage or a $redact - * stage directly ahead of the stage present at the 'itr' position if matches the constraints. - * Returns true if optimization was performed, false otherwise. + * Attempts to push any kind of 'DocumentSourceSingleDocumentTransformation' stage directly + * ahead of the stage present at the 'itr' position if matches the constraints. Returns true if + * optimization was performed, false otherwise. * * Note that this optimization is oblivious to the transform function. The only stages that are * eligible to swap are those that can safely swap with any transform. */ - bool pushSingleDocumentTransformOrRedactBefore(Pipeline::SourceContainer::iterator itr, - Pipeline::SourceContainer* container); + bool pushSingleDocumentTransformBefore(Pipeline::SourceContainer::iterator itr, + Pipeline::SourceContainer* container); /** * Wraps various optimization methods and returns the call immediately if any one of them @@ -558,7 +544,7 @@ private: } return pushMatchBefore(itr, container) || pushSampleBefore(itr, container) || - pushSingleDocumentTransformOrRedactBefore(itr, container); + pushSingleDocumentTransformBefore(itr, container); } public: @@ -615,7 +601,9 @@ public: kAllExcept, }; - GetModPathsReturn(Type type, OrderedPathSet&& paths, StringMap<std::string>&& renames) + GetModPathsReturn(Type type, + std::set<std::string>&& paths, + StringMap<std::string>&& renames) : type(type), paths(std::move(paths)), renames(std::move(renames)) {} std::set<std::string> getNewNames() { @@ -661,11 +649,11 @@ public: return true; } // Cannot hit. - MONGO_UNREACHABLE_TASSERT(6434902); + MONGO_UNREACHABLE_TASSERT(6434901); } Type type; - OrderedPathSet paths; + std::set<std::string> paths; // Stages may fill out 'renames' to contain information about path renames. Each entry in // 'renames' maps from the new name of the path (valid in documents flowing *out* of this @@ -688,7 +676,7 @@ public: * See GetModPathsReturn above for the possible return values and what they mean. */ virtual GetModPathsReturn getModifiedPaths() const { - return {GetModPathsReturn::Type::kNotSupported, OrderedPathSet{}, {}}; + return {GetModPathsReturn::Type::kNotSupported, std::set<std::string>{}, {}}; } /** @@ -726,7 +714,7 @@ public: * parallel since it will preserve the shard key. */ virtual bool canRunInParallelBeforeWriteStage( - const OrderedPathSet& nameOfShardKeyFieldsUponEntryToStage) const { + const std::set<std::string>& nameOfShardKeyFieldsUponEntryToStage) const { return false; } @@ -790,8 +778,12 @@ 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. */ - virtual Value serialize(const SerializationOptions& opts = SerializationOptions{}) const = 0; + virtual Value serialize( + boost::optional<ExplainOptions::Verbosity> explain = boost::none) const = 0; }; /** |
