diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2020-01-14 12:37:09 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-26 00:41:40 +0000 |
commit | 27363455aaba930778a5feff02b0b320d4b850af (patch) | |
tree | 7436cbb7be03dc9c98d68349c44977b4a71f066f /src/mongo/db/pipeline/pipeline.cpp | |
parent | 183e8c5c04d77ea840468ba8723970fa67258376 (diff) | |
download | mongo-27363455aaba930778a5feff02b0b320d4b850af.tar.gz |
SERVER-45538 Add shard version retry logic for $unionWith sub-pipeline
Diffstat (limited to 'src/mongo/db/pipeline/pipeline.cpp')
-rw-r--r-- | src/mongo/db/pipeline/pipeline.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/pipeline.cpp b/src/mongo/db/pipeline/pipeline.cpp index eb3a4d97914..ce3e9e89fa4 100644 --- a/src/mongo/db/pipeline/pipeline.cpp +++ b/src/mongo/db/pipeline/pipeline.cpp @@ -148,6 +148,24 @@ Pipeline::~Pipeline() { invariant(_disposed); } +std::unique_ptr<Pipeline, PipelineDeleter> Pipeline::clone() const { + const auto& serialized = serialize(); + std::vector<BSONObj> asBson; + asBson.reserve(serialized.size()); + for (auto&& stage : serialized) { + invariant(stage.getType() == BSONType::Object); + asBson.push_back(stage.getDocument().toBson()); + } + try { + return parse(asBson, getContext()); + } catch (DBException& ex) { + ex.addContext(str::stream() + << "Failed to copy pipeline. Could not parse serialized version: " + << Value(serialized).toString()); + throw; + } +} + std::unique_ptr<Pipeline, PipelineDeleter> Pipeline::parse( const std::vector<BSONObj>& rawPipeline, const intrusive_ptr<ExpressionContext>& expCtx, |