summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/process_interface
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/process_interface')
-rw-r--r--src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp25
-rw-r--r--src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h4
-rw-r--r--src/mongo/db/pipeline/process_interface/mongo_process_interface.h22
-rw-r--r--src/mongo/db/pipeline/process_interface/mongos_process_interface.cpp19
-rw-r--r--src/mongo/db/pipeline/process_interface/mongos_process_interface.h5
-rw-r--r--src/mongo/db/pipeline/process_interface/stub_lookup_single_document_process_interface.cpp20
-rw-r--r--src/mongo/db/pipeline/process_interface/stub_lookup_single_document_process_interface.h5
-rw-r--r--src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h9
8 files changed, 6 insertions, 103 deletions
diff --git a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp
index fd2dac05fc0..b95439e7240 100644
--- a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp
@@ -277,24 +277,6 @@ BSONObj CommonMongodProcessInterface::getCollectionOptions(OperationContext* opC
return collectionOptions;
}
-std::unique_ptr<Pipeline, PipelineDeleter> CommonMongodProcessInterface::makePipeline(
- const std::vector<BSONObj>& rawPipeline,
- const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const MakePipelineOptions opts) {
- auto pipeline = uassertStatusOK(Pipeline::parse(rawPipeline, expCtx));
-
- if (opts.optimize) {
- pipeline->optimizePipeline();
- }
-
- if (opts.attachCursorSource) {
- pipeline =
- attachCursorSourceToPipeline(expCtx, pipeline.release(), opts.allowTargetingShards);
- }
-
- return pipeline;
-}
-
std::unique_ptr<Pipeline, PipelineDeleter>
CommonMongodProcessInterface::attachCursorSourceToPipelineForLocalRead(
const boost::intrusive_ptr<ExpressionContext>& expCtx, Pipeline* ownedPipeline) {
@@ -355,11 +337,10 @@ boost::optional<Document> CommonMongodProcessInterface::lookupSingleDocument(
_getCollectionDefaultCollator(expCtx->opCtx, nss.db(), collectionUUID));
// When looking up on a mongoD, we only ever want to read from the local collection. By
// default, makePipeline will attach a cursor source which may read from remote if the
- // collection is sharded, so we manually attach a local-only cursor source here.
+ // collection is sharded, so we configure it to not allow that here.
MakePipelineOptions opts;
- opts.attachCursorSource = false;
- pipeline = makePipeline({BSON("$match" << documentKey)}, foreignExpCtx, opts);
- pipeline = attachCursorSourceToPipelineForLocalRead(foreignExpCtx, pipeline.release());
+ opts.allowTargetingShards = false;
+ pipeline = Pipeline::makePipeline({BSON("$match" << documentKey)}, foreignExpCtx, opts);
} catch (const ExceptionFor<ErrorCodes::NamespaceNotFound>&) {
return boost::none;
}
diff --git a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h
index f8058e18d89..898d5380d13 100644
--- a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h
@@ -81,10 +81,6 @@ public:
const NamespaceString& nss,
BSONObjBuilder* builder) const final override;
BSONObj getCollectionOptions(OperationContext* opCtx, const NamespaceString& nss) final;
- std::unique_ptr<Pipeline, PipelineDeleter> makePipeline(
- const std::vector<BSONObj>& rawPipeline,
- const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const MakePipelineOptions opts = MakePipelineOptions{}) final;
std::unique_ptr<Pipeline, PipelineDeleter> attachCursorSourceToPipelineForLocalRead(
const boost::intrusive_ptr<ExpressionContext>& expCtx, Pipeline* pipeline) final;
std::string getShardName(OperationContext* opCtx) const final;
diff --git a/src/mongo/db/pipeline/process_interface/mongo_process_interface.h b/src/mongo/db/pipeline/process_interface/mongo_process_interface.h
index c4d5267f452..7179a05cb21 100644
--- a/src/mongo/db/pipeline/process_interface/mongo_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/mongo_process_interface.h
@@ -106,14 +106,6 @@ public:
*/
static std::shared_ptr<MongoProcessInterface> create(OperationContext* opCtx);
- struct MakePipelineOptions {
- MakePipelineOptions(){};
-
- bool optimize = true;
- bool attachCursorSource = true;
- bool allowTargetingShards = true;
- };
-
/**
* This structure holds the result of a batched update operation, such as the number of
* documents that matched the query predicate, and the number of documents modified by the
@@ -250,20 +242,6 @@ public:
virtual void dropCollection(OperationContext* opCtx, const NamespaceString& collection) = 0;
/**
- * Parses a Pipeline from a vector of BSONObjs representing DocumentSources. The state of the
- * returned pipeline will depend upon the supplied MakePipelineOptions:
- * - The boolean opts.optimize determines whether the pipeline will be optimized.
- * - If opts.attachCursorSource is false, the pipeline will be returned without attempting to
- * add an initial cursor source.
- *
- * This function throws if parsing the pipeline failed.
- */
- virtual std::unique_ptr<Pipeline, PipelineDeleter> makePipeline(
- const std::vector<BSONObj>& rawPipeline,
- const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const MakePipelineOptions opts = MakePipelineOptions{}) = 0;
-
- /**
* Accepts a pipeline and returns a new one which will draw input from the underlying
* collection. Performs no further optimization of the pipeline. NamespaceNotFound will be
* thrown if ExpressionContext has a UUID and that UUID doesn't exist anymore. That should be
diff --git a/src/mongo/db/pipeline/process_interface/mongos_process_interface.cpp b/src/mongo/db/pipeline/process_interface/mongos_process_interface.cpp
index 18b6e2125ca..6c28dfd47f6 100644
--- a/src/mongo/db/pipeline/process_interface/mongos_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/mongos_process_interface.cpp
@@ -100,25 +100,6 @@ bool supportsUniqueKey(const boost::intrusive_ptr<ExpressionContext>& expCtx,
} // namespace
-std::unique_ptr<Pipeline, PipelineDeleter> MongosProcessInterface::makePipeline(
- const std::vector<BSONObj>& rawPipeline,
- const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const MakePipelineOptions pipelineOptions) {
- // Explain is not supported for auxiliary lookups.
- invariant(!expCtx->explain);
-
- auto pipeline = uassertStatusOK(Pipeline::parse(rawPipeline, expCtx));
- if (pipelineOptions.optimize) {
- pipeline->optimizePipeline();
- }
- if (pipelineOptions.attachCursorSource) {
- // 'attachCursorSourceToPipeline' handles any complexity related to sharding.
- pipeline = attachCursorSourceToPipeline(expCtx, pipeline.release(), false);
- }
-
- return pipeline;
-}
-
std::unique_ptr<Pipeline, PipelineDeleter> MongosProcessInterface::attachCursorSourceToPipeline(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
Pipeline* ownedPipeline,
diff --git a/src/mongo/db/pipeline/process_interface/mongos_process_interface.h b/src/mongo/db/pipeline/process_interface/mongos_process_interface.h
index 36abd00c6da..2e505f47ddd 100644
--- a/src/mongo/db/pipeline/process_interface/mongos_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/mongos_process_interface.h
@@ -173,11 +173,6 @@ public:
MONGO_UNREACHABLE;
}
- std::unique_ptr<Pipeline, PipelineDeleter> makePipeline(
- const std::vector<BSONObj>& rawPipeline,
- const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const MakePipelineOptions pipelineOptions) final;
-
/**
* The following methods only make sense for data-bearing nodes and should never be called on
* a mongos.
diff --git a/src/mongo/db/pipeline/process_interface/stub_lookup_single_document_process_interface.cpp b/src/mongo/db/pipeline/process_interface/stub_lookup_single_document_process_interface.cpp
index cba2a97ffcc..782ad6e56ef 100644
--- a/src/mongo/db/pipeline/process_interface/stub_lookup_single_document_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/stub_lookup_single_document_process_interface.cpp
@@ -33,27 +33,11 @@
#include "mongo/db/pipeline/document_source.h"
#include "mongo/db/pipeline/document_source_mock.h"
+#include "mongo/db/pipeline/pipeline.h"
#include "mongo/util/assert_util.h"
namespace mongo {
-std::unique_ptr<Pipeline, PipelineDeleter> StubLookupSingleDocumentProcessInterface::makePipeline(
- const std::vector<BSONObj>& rawPipeline,
- const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const MakePipelineOptions opts) {
- auto pipeline = uassertStatusOK(Pipeline::parse(rawPipeline, expCtx));
-
- if (opts.optimize) {
- pipeline->optimizePipeline();
- }
-
- if (opts.attachCursorSource) {
- pipeline =
- attachCursorSourceToPipeline(expCtx, pipeline.release(), opts.allowTargetingShards);
- }
-
- return pipeline;
-}
std::unique_ptr<Pipeline, PipelineDeleter>
StubLookupSingleDocumentProcessInterface::attachCursorSourceToPipelineForLocalRead(
@@ -85,7 +69,7 @@ boost::optional<Document> StubLookupSingleDocumentProcessInterface::lookupSingle
auto foreignExpCtx = expCtx->copyWith(nss, collectionUUID, boost::none);
std::unique_ptr<Pipeline, PipelineDeleter> pipeline;
try {
- pipeline = makePipeline({BSON("$match" << documentKey)}, foreignExpCtx);
+ pipeline = Pipeline::makePipeline({BSON("$match" << documentKey)}, foreignExpCtx);
} catch (ExceptionFor<ErrorCodes::NamespaceNotFound>&) {
return boost::none;
}
diff --git a/src/mongo/db/pipeline/process_interface/stub_lookup_single_document_process_interface.h b/src/mongo/db/pipeline/process_interface/stub_lookup_single_document_process_interface.h
index 421fb759ae2..68f8317ec0a 100644
--- a/src/mongo/db/pipeline/process_interface/stub_lookup_single_document_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/stub_lookup_single_document_process_interface.h
@@ -67,11 +67,6 @@ public:
StubLookupSingleDocumentProcessInterface(std::deque<DocumentSource::GetNextResult> mockResults)
: _mockResults(std::move(mockResults)) {}
- std::unique_ptr<Pipeline, PipelineDeleter> makePipeline(
- const std::vector<BSONObj>& rawPipeline,
- const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const MakePipelineOptions opts = MakePipelineOptions{}) final;
-
std::unique_ptr<Pipeline, PipelineDeleter> attachCursorSourceToPipeline(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
Pipeline* ownedPipeline,
diff --git a/src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h b/src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h
index 69d7b5eec49..d197918719b 100644
--- a/src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/stub_mongo_process_interface.h
@@ -140,17 +140,10 @@ public:
MONGO_UNREACHABLE;
}
- std::unique_ptr<Pipeline, PipelineDeleter> makePipeline(
- const std::vector<BSONObj>& rawPipeline,
- const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const MakePipelineOptions opts) override {
- MONGO_UNREACHABLE;
- }
-
std::unique_ptr<Pipeline, PipelineDeleter> attachCursorSourceToPipeline(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
Pipeline* pipeline,
- bool allowTargetingShards = true) override {
+ bool allowTargetingShards) override {
MONGO_UNREACHABLE;
}