diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2017-12-19 15:13:58 -0500 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2017-12-19 17:29:29 -0500 |
commit | a318fd1bc13e59a87def8de0061a08ec0dd134eb (patch) | |
tree | 55fc10b1fe53d07a802aa5a40a643d8b6d27c921 /src/mongo | |
parent | b5a2cc0fec6ac30b1a0196da5feb41d85a8b76c3 (diff) | |
download | mongo-a318fd1bc13e59a87def8de0061a08ec0dd134eb.tar.gz |
SERVER-32190 Shorten MongoDProcessInterface to MongoDInterface.
Similarly shorten other similar MongoProcessInterface implementation's
names, e.g. MongoSProcessInterface -> MongoSInterface and
MockMongoProcessInterface -> MockMongoInterface.
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/commands/run_aggregate.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_change_stream_test.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_check_resume_token_test.cpp | 30 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_current_op_test.cpp | 22 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_graph_lookup_test.cpp | 26 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp | 18 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_lookup_test.cpp | 32 | ||||
-rw-r--r-- | src/mongo/db/pipeline/pipeline_d.cpp | 64 | ||||
-rw-r--r-- | src/mongo/db/pipeline/pipeline_d.h | 4 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_aggregate.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/commands/pipeline_s.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/commands/pipeline_s.h | 6 |
12 files changed, 103 insertions, 116 deletions
diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp index 5e81b068dc9..bdd8887eb4f 100644 --- a/src/mongo/db/commands/run_aggregate.cpp +++ b/src/mongo/db/commands/run_aggregate.cpp @@ -460,7 +460,7 @@ Status runAggregate(OperationContext* opCtx, new ExpressionContext(opCtx, request, std::move(*collatorToUse), - std::make_shared<PipelineD::MongoDProcessInterface>(opCtx), + std::make_shared<PipelineD::MongoDInterface>(opCtx), uassertStatusOK(resolveInvolvedNamespaces(opCtx, request)))); expCtx->tempDir = storageGlobalParams.dbpath + "/_tmp"; diff --git a/src/mongo/db/pipeline/document_source_change_stream_test.cpp b/src/mongo/db/pipeline/document_source_change_stream_test.cpp index 44c28591d7b..157c4157a02 100644 --- a/src/mongo/db/pipeline/document_source_change_stream_test.cpp +++ b/src/mongo/db/pipeline/document_source_change_stream_test.cpp @@ -107,9 +107,9 @@ public: }; // This is needed only for the "insert" tests. -struct MockMongoProcessInterface final : public StubMongoProcessInterface { +struct MockMongoInterface final : public StubMongoProcessInterface { - MockMongoProcessInterface(std::vector<FieldPath> fields) : _fields(std::move(fields)) {} + MockMongoInterface(std::vector<FieldPath> fields) : _fields(std::move(fields)) {} std::vector<FieldPath> collectDocumentKeyFields(OperationContext*, const NamespaceString&, @@ -134,8 +134,7 @@ public: vector<intrusive_ptr<DocumentSource>> stages = makeStages(entry); auto transform = stages[2].get(); - getExpCtx()->mongoProcessInterface = - stdx::make_unique<MockMongoProcessInterface>(docKeyFields); + getExpCtx()->mongoProcessInterface = stdx::make_unique<MockMongoInterface>(docKeyFields); auto next = transform->getNext(); // Match stage should pass the doc down if expectedDoc is given. @@ -155,7 +154,7 @@ public: DSChangeStream::createFromBson(spec.firstElement(), getExpCtx()); vector<intrusive_ptr<DocumentSource>> stages(std::begin(result), std::end(result)); getExpCtx()->mongoProcessInterface = - stdx::make_unique<MockMongoProcessInterface>(std::vector<FieldPath>{}); + stdx::make_unique<MockMongoInterface>(std::vector<FieldPath>{}); // This match stage is a DocumentSourceOplogMatch, which we explicitly disallow from // executing as a safety mechanism, since it needs to use the collection-default collation, diff --git a/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp b/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp index b4dce391492..cf1267eeb03 100644 --- a/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp +++ b/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp @@ -213,9 +213,9 @@ TEST_F(CheckResumeTokenTest, ShouldSucceedWithNoDocuments) { /** * A mock MongoProcessInterface which allows mocking a foreign pipeline. */ -class MockMongoProcessInterface final : public StubMongoProcessInterface { +class MockMongoInterface final : public StubMongoProcessInterface { public: - MockMongoProcessInterface(deque<DocumentSource::GetNextResult> mockResults) + MockMongoInterface(deque<DocumentSource::GetNextResult> mockResults) : _mockResults(std::move(mockResults)) {} bool isSharded(OperationContext* opCtx, const NamespaceString& ns) final { @@ -259,7 +259,7 @@ TEST_F(ShardCheckResumabilityTest, auto shardCheckResumability = createShardCheckResumability(resumeTimestamp, "ID"); deque<DocumentSource::GetNextResult> mockOplog({Document{{"ts", oplogTimestamp}}}); - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); addDocument(resumeTimestamp, "ID"); // We should see the resume token. auto result = shardCheckResumability->getNext(); @@ -275,7 +275,7 @@ TEST_F(ShardCheckResumabilityTest, auto shardCheckResumability = createShardCheckResumability(resumeTimestamp, "ID"); deque<DocumentSource::GetNextResult> mockOplog({Document{{"ts", oplogTimestamp}}}); - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); addDocument(resumeTimestamp, "ID"); // We should see the resume token. auto result = shardCheckResumability->getNext(); @@ -289,7 +289,7 @@ TEST_F(ShardCheckResumabilityTest, ShouldSucceedIfResumeTokenIsPresentAndOplogIs auto shardCheckResumability = createShardCheckResumability(resumeTimestamp, "ID"); deque<DocumentSource::GetNextResult> mockOplog; - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); addDocument(resumeTimestamp, "ID"); // We should see the resume token. auto result = shardCheckResumability->getNext(); @@ -305,7 +305,7 @@ TEST_F(ShardCheckResumabilityTest, auto shardCheckResumability = createShardCheckResumability(resumeTimestamp, "0"); deque<DocumentSource::GetNextResult> mockOplog({Document{{"ts", oplogTimestamp}}}); - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); auto result = shardCheckResumability->getNext(); ASSERT_TRUE(result.isEOF()); } @@ -317,7 +317,7 @@ TEST_F(ShardCheckResumabilityTest, auto shardCheckResumability = createShardCheckResumability(resumeTimestamp, "0"); deque<DocumentSource::GetNextResult> mockOplog({Document{{"ts", oplogTimestamp}}}); - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); ASSERT_THROWS_CODE(shardCheckResumability->getNext(), AssertionException, 40576); } @@ -326,7 +326,7 @@ TEST_F(ShardCheckResumabilityTest, ShouldSucceedWithNoDocumentsInPipelineAndOplo auto shardCheckResumability = createShardCheckResumability(resumeTimestamp, "0"); deque<DocumentSource::GetNextResult> mockOplog; - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); auto result = shardCheckResumability->getNext(); ASSERT_TRUE(result.isEOF()); } @@ -340,7 +340,7 @@ TEST_F(ShardCheckResumabilityTest, auto shardCheckResumability = createShardCheckResumability(resumeTimestamp, "0"); addDocument(docTimestamp, "ID"); deque<DocumentSource::GetNextResult> mockOplog({Document{{"ts", oplogTimestamp}}}); - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); auto result = shardCheckResumability->getNext(); ASSERT_TRUE(result.isAdvanced()); auto& doc = result.getDocument(); @@ -356,7 +356,7 @@ TEST_F(ShardCheckResumabilityTest, auto shardCheckResumability = createShardCheckResumability(resumeTimestamp, "0"); addDocument(docTimestamp, "ID"); deque<DocumentSource::GetNextResult> mockOplog({Document{{"ts", oplogTimestamp}}}); - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); ASSERT_THROWS_CODE(shardCheckResumability->getNext(), AssertionException, 40576); } @@ -369,14 +369,14 @@ TEST_F(ShardCheckResumabilityTest, ShouldIgnoreOplogAfterFirstDoc) { auto shardCheckResumability = createShardCheckResumability(resumeTimestamp, "0"); addDocument(docTimestamp, "ID"); deque<DocumentSource::GetNextResult> mockOplog({Document{{"ts", oplogTimestamp}}}); - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); auto result1 = shardCheckResumability->getNext(); ASSERT_TRUE(result1.isAdvanced()); auto& doc1 = result1.getDocument(); ASSERT_EQ(docTimestamp, ResumeToken::parse(doc1["_id"].getDocument()).getData().clusterTime); mockOplog = {Document{{"ts", oplogFutureTimestamp}}}; - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); auto result2 = shardCheckResumability->getNext(); ASSERT_TRUE(result2.isEOF()); } @@ -391,7 +391,7 @@ TEST_F(ShardCheckResumabilityTest, ShouldSucceedWhenOplogEntriesExistBeforeAndAf addDocument(docTimestamp, "ID"); deque<DocumentSource::GetNextResult> mockOplog( {{Document{{"ts", oplogTimestamp}}}, {Document{{"ts", oplogFutureTimestamp}}}}); - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); auto result1 = shardCheckResumability->getNext(); ASSERT_TRUE(result1.isAdvanced()); auto& doc1 = result1.getDocument(); @@ -407,12 +407,12 @@ TEST_F(ShardCheckResumabilityTest, ShouldIgnoreOplogAfterFirstEOF) { auto shardCheckResumability = createShardCheckResumability(resumeTimestamp, "0"); deque<DocumentSource::GetNextResult> mockOplog({Document{{"ts", oplogTimestamp}}}); - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); auto result1 = shardCheckResumability->getNext(); ASSERT_TRUE(result1.isEOF()); mockOplog = {Document{{"ts", oplogFutureTimestamp}}}; - getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>(mockOplog); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockOplog); auto result2 = shardCheckResumability->getNext(); ASSERT_TRUE(result2.isEOF()); } diff --git a/src/mongo/db/pipeline/document_source_current_op_test.cpp b/src/mongo/db/pipeline/document_source_current_op_test.cpp index cbafc412e22..f2acc179d75 100644 --- a/src/mongo/db/pipeline/document_source_current_op_test.cpp +++ b/src/mongo/db/pipeline/document_source_current_op_test.cpp @@ -57,13 +57,12 @@ public: /** * A MongoProcessInterface used for testing which returns artificial currentOp entries. */ -class MockMongoProcessInterfaceImplementation final : public StubMongoProcessInterface { +class MockMongoInterface final : public StubMongoProcessInterface { public: - MockMongoProcessInterfaceImplementation(std::vector<BSONObj> ops, bool hasShardName = true) + MockMongoInterface(std::vector<BSONObj> ops, bool hasShardName = true) : _ops(std::move(ops)), _hasShardName(hasShardName) {} - MockMongoProcessInterfaceImplementation(bool hasShardName = true) - : _hasShardName(hasShardName) {} + MockMongoInterface(bool hasShardName = true) : _hasShardName(hasShardName) {} std::vector<BSONObj> getCurrentOps(OperationContext* opCtx, CurrentOpConnectionsMode connMode, @@ -184,8 +183,7 @@ TEST_F(DocumentSourceCurrentOpTest, ShouldSerializeOmittedOptionalArgumentsAsDef } TEST_F(DocumentSourceCurrentOpTest, ShouldReturnEOFImmediatelyIfNoCurrentOps) { - getExpCtx()->mongoProcessInterface = - std::make_shared<MockMongoProcessInterfaceImplementation>(); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(); const auto currentOp = DocumentSourceCurrentOp::create(getExpCtx()); @@ -197,8 +195,7 @@ TEST_F(DocumentSourceCurrentOpTest, getExpCtx()->fromMongos = true; std::vector<BSONObj> ops{fromjson("{ client: '192.168.1.10:50844', opid: 430 }")}; - getExpCtx()->mongoProcessInterface = - std::make_shared<MockMongoProcessInterfaceImplementation>(ops); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(ops); const auto currentOp = DocumentSourceCurrentOp::create(getExpCtx()); @@ -215,8 +212,7 @@ TEST_F(DocumentSourceCurrentOpTest, getExpCtx()->fromMongos = false; std::vector<BSONObj> ops{fromjson("{ client: '192.168.1.10:50844', opid: 430 }")}; - getExpCtx()->mongoProcessInterface = - std::make_shared<MockMongoProcessInterfaceImplementation>(ops); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(ops); const auto currentOp = DocumentSourceCurrentOp::create(getExpCtx()); @@ -229,8 +225,7 @@ TEST_F(DocumentSourceCurrentOpTest, TEST_F(DocumentSourceCurrentOpTest, ShouldFailIfNoShardNameAvailableForShardedRequest) { getExpCtx()->fromMongos = true; - getExpCtx()->mongoProcessInterface = - std::make_shared<MockMongoProcessInterfaceImplementation>(false); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(false); const auto currentOp = DocumentSourceCurrentOp::create(getExpCtx()); @@ -241,8 +236,7 @@ TEST_F(DocumentSourceCurrentOpTest, ShouldFailIfOpIDIsNonNumericWhenModifyingInS getExpCtx()->fromMongos = true; std::vector<BSONObj> ops{fromjson("{ client: '192.168.1.10:50844', opid: 'string' }")}; - getExpCtx()->mongoProcessInterface = - std::make_shared<MockMongoProcessInterfaceImplementation>(ops); + getExpCtx()->mongoProcessInterface = std::make_shared<MockMongoInterface>(ops); const auto currentOp = DocumentSourceCurrentOp::create(getExpCtx()); diff --git a/src/mongo/db/pipeline/document_source_graph_lookup_test.cpp b/src/mongo/db/pipeline/document_source_graph_lookup_test.cpp index 6dc9849baff..05a62606bb6 100644 --- a/src/mongo/db/pipeline/document_source_graph_lookup_test.cpp +++ b/src/mongo/db/pipeline/document_source_graph_lookup_test.cpp @@ -56,9 +56,9 @@ using DocumentSourceGraphLookUpTest = AggregationContextFixture; * A MongoProcessInterface use for testing that supports making pipelines with an initial * DocumentSourceMock source. */ -class MockMongoProcess final : public StubMongoProcessInterface { +class MockMongoInterface final : public StubMongoProcessInterface { public: - MockMongoProcess(std::deque<DocumentSource::GetNextResult> results) + MockMongoInterface(std::deque<DocumentSource::GetNextResult> results) : _results(std::move(results)) {} StatusWith<std::unique_ptr<Pipeline, PipelineDeleter>> makePipeline( @@ -101,7 +101,7 @@ TEST_F(DocumentSourceGraphLookUpTest, NamespaceString fromNs("test", "graph_lookup"); expCtx->setResolvedNamespace(fromNs, {fromNs, std::vector<BSONObj>{}}); - expCtx->mongoProcessInterface = std::make_shared<MockMongoProcess>(std::move(fromContents)); + expCtx->mongoProcessInterface = std::make_shared<MockMongoInterface>(std::move(fromContents)); auto graphLookupStage = DocumentSourceGraphLookUp::create(expCtx, fromNs, @@ -129,7 +129,7 @@ TEST_F(DocumentSourceGraphLookUpTest, NamespaceString fromNs("test", "graph_lookup"); expCtx->setResolvedNamespace(fromNs, {fromNs, std::vector<BSONObj>{}}); - expCtx->mongoProcessInterface = std::make_shared<MockMongoProcess>(std::move(fromContents)); + expCtx->mongoProcessInterface = std::make_shared<MockMongoInterface>(std::move(fromContents)); auto graphLookupStage = DocumentSourceGraphLookUp::create(expCtx, fromNs, @@ -157,7 +157,7 @@ TEST_F(DocumentSourceGraphLookUpTest, NamespaceString fromNs("test", "graph_lookup"); expCtx->setResolvedNamespace(fromNs, {fromNs, std::vector<BSONObj>{}}); - expCtx->mongoProcessInterface = std::make_shared<MockMongoProcess>(std::move(fromContents)); + expCtx->mongoProcessInterface = std::make_shared<MockMongoInterface>(std::move(fromContents)); auto unwindStage = DocumentSourceUnwind::create(expCtx, "results", false, boost::none); auto graphLookupStage = DocumentSourceGraphLookUp::create(expCtx, @@ -200,7 +200,7 @@ TEST_F(DocumentSourceGraphLookUpTest, NamespaceString fromNs("test", "graph_lookup"); expCtx->setResolvedNamespace(fromNs, {fromNs, std::vector<BSONObj>{}}); - expCtx->mongoProcessInterface = std::make_shared<MockMongoProcess>(std::move(fromContents)); + expCtx->mongoProcessInterface = std::make_shared<MockMongoInterface>(std::move(fromContents)); auto graphLookupStage = DocumentSourceGraphLookUp::create(expCtx, fromNs, @@ -264,7 +264,7 @@ TEST_F(DocumentSourceGraphLookUpTest, ShouldPropagatePauses) { NamespaceString fromNs("test", "foreign"); expCtx->setResolvedNamespace(fromNs, {fromNs, std::vector<BSONObj>{}}); - expCtx->mongoProcessInterface = std::make_shared<MockMongoProcess>(std::move(fromContents)); + expCtx->mongoProcessInterface = std::make_shared<MockMongoInterface>(std::move(fromContents)); auto graphLookupStage = DocumentSourceGraphLookUp::create(expCtx, fromNs, @@ -330,7 +330,7 @@ TEST_F(DocumentSourceGraphLookUpTest, ShouldPropagatePausesWhileUnwinding) { NamespaceString fromNs("test", "foreign"); expCtx->setResolvedNamespace(fromNs, {fromNs, std::vector<BSONObj>{}}); - expCtx->mongoProcessInterface = std::make_shared<MockMongoProcess>(std::move(fromContents)); + expCtx->mongoProcessInterface = std::make_shared<MockMongoInterface>(std::move(fromContents)); const bool preserveNullAndEmptyArrays = false; const boost::optional<std::string> includeArrayIndex = boost::none; @@ -394,7 +394,7 @@ TEST_F(DocumentSourceGraphLookUpTest, GraphLookupShouldReportAsFieldIsModified) NamespaceString fromNs("test", "foreign"); expCtx->setResolvedNamespace(fromNs, {fromNs, std::vector<BSONObj>{}}); expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcess>(std::deque<DocumentSource::GetNextResult>{}); + std::make_shared<MockMongoInterface>(std::deque<DocumentSource::GetNextResult>{}); auto graphLookupStage = DocumentSourceGraphLookUp::create(expCtx, fromNs, @@ -418,7 +418,7 @@ TEST_F(DocumentSourceGraphLookUpTest, GraphLookupShouldReportFieldsModifiedByAbs NamespaceString fromNs("test", "foreign"); expCtx->setResolvedNamespace(fromNs, {fromNs, std::vector<BSONObj>{}}); expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcess>(std::deque<DocumentSource::GetNextResult>{}); + std::make_shared<MockMongoInterface>(std::deque<DocumentSource::GetNextResult>{}); auto unwindStage = DocumentSourceUnwind::create(expCtx, "results", false, std::string("arrIndex")); auto graphLookupStage = @@ -449,7 +449,7 @@ TEST_F(DocumentSourceGraphLookUpTest, GraphLookupWithComparisonExpressionForStar expCtx->setResolvedNamespace(fromNs, {fromNs, std::vector<BSONObj>{}}); std::deque<DocumentSource::GetNextResult> fromContents{Document{{"_id", 0}, {"to", true}}, Document{{"_id", 1}, {"to", false}}}; - expCtx->mongoProcessInterface = std::make_shared<MockMongoProcess>(std::move(fromContents)); + expCtx->mongoProcessInterface = std::make_shared<MockMongoInterface>(std::move(fromContents)); auto graphLookupStage = DocumentSourceGraphLookUp::create( expCtx, @@ -512,7 +512,7 @@ TEST_F(DocumentSourceGraphLookUpTest, ShouldExpandArraysAtEndOfConnectFromField) NamespaceString fromNs("test", "graph_lookup"); expCtx->setResolvedNamespace(fromNs, {fromNs, std::vector<BSONObj>{}}); - expCtx->mongoProcessInterface = std::make_shared<MockMongoProcess>(std::move(fromContents)); + expCtx->mongoProcessInterface = std::make_shared<MockMongoInterface>(std::move(fromContents)); auto graphLookupStage = DocumentSourceGraphLookUp::create(expCtx, fromNs, @@ -584,7 +584,7 @@ TEST_F(DocumentSourceGraphLookUpTest, ShouldNotExpandArraysWithinArraysAtEndOfCo NamespaceString fromNs("test", "graph_lookup"); expCtx->setResolvedNamespace(fromNs, {fromNs, std::vector<BSONObj>{}}); - expCtx->mongoProcessInterface = std::make_shared<MockMongoProcess>(std::move(fromContents)); + expCtx->mongoProcessInterface = std::make_shared<MockMongoInterface>(std::move(fromContents)); auto graphLookupStage = DocumentSourceGraphLookUp::create(expCtx, fromNs, diff --git a/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp b/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp index ffcfb6fb904..175806d5f7e 100644 --- a/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp +++ b/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp @@ -78,9 +78,9 @@ public: /** * A mock MongoProcessInterface which allows mocking a foreign pipeline. */ -class MockMongoProcessInterface final : public StubMongoProcessInterface { +class MockMongoInterface final : public StubMongoProcessInterface { public: - MockMongoProcessInterface(deque<DocumentSource::GetNextResult> mockResults) + MockMongoInterface(deque<DocumentSource::GetNextResult> mockResults) : _mockResults(std::move(mockResults)) {} bool isSharded(OperationContext* opCtx, const NamespaceString& ns) final { @@ -160,7 +160,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfMissingDocumentKeyO // Mock out the foreign collection. getExpCtx()->mongoProcessInterface = - stdx::make_unique<MockMongoProcessInterface>(deque<DocumentSource::GetNextResult>{}); + stdx::make_unique<MockMongoInterface>(deque<DocumentSource::GetNextResult>{}); ASSERT_THROWS_CODE(lookupChangeStage->getNext(), AssertionException, 40578); } @@ -182,7 +182,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfMissingOperationTyp // Mock out the foreign collection. getExpCtx()->mongoProcessInterface = - stdx::make_unique<MockMongoProcessInterface>(deque<DocumentSource::GetNextResult>{}); + stdx::make_unique<MockMongoInterface>(deque<DocumentSource::GetNextResult>{}); ASSERT_THROWS_CODE(lookupChangeStage->getNext(), AssertionException, 40578); } @@ -204,7 +204,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfMissingNamespace) { // Mock out the foreign collection. getExpCtx()->mongoProcessInterface = - stdx::make_unique<MockMongoProcessInterface>(deque<DocumentSource::GetNextResult>{}); + stdx::make_unique<MockMongoInterface>(deque<DocumentSource::GetNextResult>{}); ASSERT_THROWS_CODE(lookupChangeStage->getNext(), AssertionException, 40578); } @@ -226,7 +226,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfNsFieldHasWrongType // Mock out the foreign collection. getExpCtx()->mongoProcessInterface = - stdx::make_unique<MockMongoProcessInterface>(deque<DocumentSource::GetNextResult>{}); + stdx::make_unique<MockMongoInterface>(deque<DocumentSource::GetNextResult>{}); ASSERT_THROWS_CODE(lookupChangeStage->getNext(), AssertionException, 40578); } @@ -248,7 +248,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfNsFieldDoesNotMatch // Mock out the foreign collection. getExpCtx()->mongoProcessInterface = - stdx::make_unique<MockMongoProcessInterface>(deque<DocumentSource::GetNextResult>{}); + stdx::make_unique<MockMongoInterface>(deque<DocumentSource::GetNextResult>{}); ASSERT_THROWS_CODE(lookupChangeStage->getNext(), AssertionException, 40579); } @@ -272,7 +272,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldErrorIfDocumentKeyIsNotUni deque<DocumentSource::GetNextResult> foreignCollection = {Document{{"_id", 0}}, Document{{"_id", 0}}}; getExpCtx()->mongoProcessInterface = - stdx::make_unique<MockMongoProcessInterface>(std::move(foreignCollection)); + stdx::make_unique<MockMongoInterface>(std::move(foreignCollection)); ASSERT_THROWS_CODE( lookupChangeStage->getNext(), AssertionException, ErrorCodes::TooManyMatchingDocuments); @@ -304,7 +304,7 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldPropagatePauses) { deque<DocumentSource::GetNextResult> mockForeignContents{Document{{"_id", 0}}, Document{{"_id", 1}}}; getExpCtx()->mongoProcessInterface = - stdx::make_unique<MockMongoProcessInterface>(std::move(mockForeignContents)); + stdx::make_unique<MockMongoInterface>(std::move(mockForeignContents)); auto next = lookupChangeStage->getNext(); ASSERT_TRUE(next.isAdvanced()); diff --git a/src/mongo/db/pipeline/document_source_lookup_test.cpp b/src/mongo/db/pipeline/document_source_lookup_test.cpp index ea96b7f9353..7b4001666cb 100644 --- a/src/mongo/db/pipeline/document_source_lookup_test.cpp +++ b/src/mongo/db/pipeline/document_source_lookup_test.cpp @@ -486,10 +486,10 @@ TEST(MakeMatchStageFromInput, ArrayValueWithRegexUsesOrQuery) { * pipeline will be removed, simulating the pipeline changes which occur when * PipelineD::prepareCursorSource absorbs stages into the PlanExecutor. */ -class MockMongoProcessInterface final : public StubMongoProcessInterface { +class MockMongoInterface final : public StubMongoProcessInterface { public: - MockMongoProcessInterface(deque<DocumentSource::GetNextResult> mockResults, - bool removeLeadingQueryStages = false) + MockMongoInterface(deque<DocumentSource::GetNextResult> mockResults, + bool removeLeadingQueryStages = false) : _mockResults(std::move(mockResults)), _removeLeadingQueryStages(removeLeadingQueryStages) {} @@ -565,7 +565,7 @@ TEST_F(DocumentSourceLookUpTest, ShouldPropagatePauses) { deque<DocumentSource::GetNextResult> mockForeignContents{Document{{"_id", 0}}, Document{{"_id", 1}}}; expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcessInterface>(std::move(mockForeignContents)); + std::make_shared<MockMongoInterface>(std::move(mockForeignContents)); auto next = lookup->getNext(); ASSERT_TRUE(next.isAdvanced()); @@ -620,7 +620,7 @@ TEST_F(DocumentSourceLookUpTest, ShouldPropagatePausesWhileUnwinding) { deque<DocumentSource::GetNextResult> mockForeignContents{Document{{"_id", 0}}, Document{{"_id", 1}}}; expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcessInterface>(std::move(mockForeignContents)); + std::make_shared<MockMongoInterface>(std::move(mockForeignContents)); auto next = lookup->getNext(); ASSERT_TRUE(next.isAdvanced()); @@ -711,7 +711,7 @@ TEST_F(DocumentSourceLookUpTest, ShouldCacheNonCorrelatedSubPipelinePrefix) { ASSERT(lookupStage); expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcessInterface>(std::deque<DocumentSource::GetNextResult>{}); + std::make_shared<MockMongoInterface>(std::deque<DocumentSource::GetNextResult>{}); auto subPipeline = lookupStage->getSubPipeline_forTest(DOC("_id" << 5)); ASSERT(subPipeline); @@ -745,7 +745,7 @@ TEST_F(DocumentSourceLookUpTest, ASSERT(lookupStage); expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcessInterface>(std::deque<DocumentSource::GetNextResult>{}); + std::make_shared<MockMongoInterface>(std::deque<DocumentSource::GetNextResult>{}); auto subPipeline = lookupStage->getSubPipeline_forTest(DOC("_id" << 5)); ASSERT(subPipeline); @@ -775,7 +775,7 @@ TEST_F(DocumentSourceLookUpTest, ExprEmbeddedInMatchExpressionShouldBeOptimized) ASSERT(lookupStage); expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcessInterface>(std::deque<DocumentSource::GetNextResult>{}); + std::make_shared<MockMongoInterface>(std::deque<DocumentSource::GetNextResult>{}); auto subPipeline = lookupStage->getSubPipeline_forTest(DOC("_id" << 5)); ASSERT(subPipeline); @@ -816,7 +816,7 @@ TEST_F(DocumentSourceLookUpTest, ASSERT(lookupStage); expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcessInterface>(std::deque<DocumentSource::GetNextResult>{}); + std::make_shared<MockMongoInterface>(std::deque<DocumentSource::GetNextResult>{}); auto subPipeline = lookupStage->getSubPipeline_forTest(DOC("_id" << 5)); ASSERT(subPipeline); @@ -851,7 +851,7 @@ TEST_F(DocumentSourceLookUpTest, ShouldInsertCacheBeforeCorrelatedNestedLookup) ASSERT(lookupStage); expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcessInterface>(std::deque<DocumentSource::GetNextResult>{}); + std::make_shared<MockMongoInterface>(std::deque<DocumentSource::GetNextResult>{}); auto subPipeline = lookupStage->getSubPipeline_forTest(DOC("_id" << 5)); ASSERT(subPipeline); @@ -887,7 +887,7 @@ TEST_F(DocumentSourceLookUpTest, ASSERT(lookupStage); expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcessInterface>(std::deque<DocumentSource::GetNextResult>{}); + std::make_shared<MockMongoInterface>(std::deque<DocumentSource::GetNextResult>{}); auto subPipeline = lookupStage->getSubPipeline_forTest(DOC("_id" << 5)); ASSERT(subPipeline); @@ -918,7 +918,7 @@ TEST_F(DocumentSourceLookUpTest, ShouldCacheEntirePipelineIfNonCorrelated) { ASSERT(lookupStage); expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcessInterface>(std::deque<DocumentSource::GetNextResult>{}); + std::make_shared<MockMongoInterface>(std::deque<DocumentSource::GetNextResult>{}); auto subPipeline = lookupStage->getSubPipeline_forTest(DOC("_id" << 5)); ASSERT(subPipeline); @@ -959,8 +959,7 @@ TEST_F(DocumentSourceLookUpTest, deque<DocumentSource::GetNextResult> mockForeignContents{ Document{{"x", 0}}, Document{{"x", 1}}, Document{{"x", 2}}}; - expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcessInterface>(mockForeignContents); + expCtx->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockForeignContents); // Confirm that the empty 'kBuilding' cache is placed just before the correlated $addFields. auto subPipeline = lookupStage->getSubPipeline_forTest(DOC("_id" << 0)); @@ -1036,8 +1035,7 @@ TEST_F(DocumentSourceLookUpTest, deque<DocumentSource::GetNextResult> mockForeignContents{Document{{"x", 0}}, Document{{"x", 1}}}; - expCtx->mongoProcessInterface = - std::make_shared<MockMongoProcessInterface>(mockForeignContents); + expCtx->mongoProcessInterface = std::make_shared<MockMongoInterface>(mockForeignContents); // Confirm that the empty 'kBuilding' cache is placed just before the correlated $addFields. auto subPipeline = lookupStage->getSubPipeline_forTest(DOC("_id" << 0)); @@ -1093,7 +1091,7 @@ TEST_F(DocumentSourceLookUpTest, ShouldNotCacheIfCorrelatedStageIsAbsorbedIntoPl const bool removeLeadingQueryStages = true; - expCtx->mongoProcessInterface = std::make_shared<MockMongoProcessInterface>( + expCtx->mongoProcessInterface = std::make_shared<MockMongoInterface>( std::deque<DocumentSource::GetNextResult>{}, removeLeadingQueryStages); auto subPipeline = lookupStage->getSubPipeline_forTest(DOC("_id" << 0)); diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp index 2638e7c9a82..7ce395f3716 100644 --- a/src/mongo/db/pipeline/pipeline_d.cpp +++ b/src/mongo/db/pipeline/pipeline_d.cpp @@ -574,19 +574,17 @@ void PipelineD::getPlanSummaryStats(const Pipeline* pPipeline, PlanSummaryStats* statsOut->hasSortStage = hasSortStage; } -PipelineD::MongoDProcessInterface::MongoDProcessInterface(OperationContext* opCtx) - : _client(opCtx) {} +PipelineD::MongoDInterface::MongoDInterface(OperationContext* opCtx) : _client(opCtx) {} -void PipelineD::MongoDProcessInterface::setOperationContext(OperationContext* opCtx) { +void PipelineD::MongoDInterface::setOperationContext(OperationContext* opCtx) { _client.setOpCtx(opCtx); } -DBClientBase* PipelineD::MongoDProcessInterface::directClient() { +DBClientBase* PipelineD::MongoDInterface::directClient() { return &_client; } -bool PipelineD::MongoDProcessInterface::isSharded(OperationContext* opCtx, - const NamespaceString& nss) { +bool PipelineD::MongoDInterface::isSharded(OperationContext* opCtx, const NamespaceString& nss) { AutoGetCollectionForReadCommand autoColl(opCtx, nss); // TODO SERVER-24960: Use CollectionShardingState::collectionIsSharded() to confirm sharding // state. @@ -594,10 +592,9 @@ bool PipelineD::MongoDProcessInterface::isSharded(OperationContext* opCtx, return bool(css->getMetadata()); } -BSONObj PipelineD::MongoDProcessInterface::insert( - const boost::intrusive_ptr<ExpressionContext>& expCtx, - const NamespaceString& ns, - const std::vector<BSONObj>& objs) { +BSONObj PipelineD::MongoDInterface::insert(const boost::intrusive_ptr<ExpressionContext>& expCtx, + const NamespaceString& ns, + const std::vector<BSONObj>& objs) { boost::optional<DisableDocumentValidation> maybeDisableValidation; if (expCtx->bypassDocumentValidation) maybeDisableValidation.emplace(expCtx->opCtx); @@ -606,8 +603,8 @@ BSONObj PipelineD::MongoDProcessInterface::insert( return _client.getLastErrorDetailed(); } -CollectionIndexUsageMap PipelineD::MongoDProcessInterface::getIndexStats( - OperationContext* opCtx, const NamespaceString& ns) { +CollectionIndexUsageMap PipelineD::MongoDInterface::getIndexStats(OperationContext* opCtx, + const NamespaceString& ns) { AutoGetCollectionForReadCommand autoColl(opCtx, ns); Collection* collection = autoColl.getCollection(); @@ -619,32 +616,32 @@ CollectionIndexUsageMap PipelineD::MongoDProcessInterface::getIndexStats( return collection->infoCache()->getIndexUsageStats(); } -void PipelineD::MongoDProcessInterface::appendLatencyStats(OperationContext* opCtx, - const NamespaceString& nss, - bool includeHistograms, - BSONObjBuilder* builder) const { +void PipelineD::MongoDInterface::appendLatencyStats(OperationContext* opCtx, + const NamespaceString& nss, + bool includeHistograms, + BSONObjBuilder* builder) const { Top::get(opCtx->getServiceContext()).appendLatencyStats(nss.ns(), includeHistograms, builder); } -Status PipelineD::MongoDProcessInterface::appendStorageStats(OperationContext* opCtx, - const NamespaceString& nss, - const BSONObj& param, - BSONObjBuilder* builder) const { +Status PipelineD::MongoDInterface::appendStorageStats(OperationContext* opCtx, + const NamespaceString& nss, + const BSONObj& param, + BSONObjBuilder* builder) const { return appendCollectionStorageStats(opCtx, nss, param, builder); } -Status PipelineD::MongoDProcessInterface::appendRecordCount(OperationContext* opCtx, - const NamespaceString& nss, - BSONObjBuilder* builder) const { +Status PipelineD::MongoDInterface::appendRecordCount(OperationContext* opCtx, + const NamespaceString& nss, + BSONObjBuilder* builder) const { return appendCollectionRecordCount(opCtx, nss, builder); } -BSONObj PipelineD::MongoDProcessInterface::getCollectionOptions(const NamespaceString& nss) { +BSONObj PipelineD::MongoDInterface::getCollectionOptions(const NamespaceString& nss) { const auto infos = _client.getCollectionInfos(nss.db().toString(), BSON("name" << nss.coll())); return infos.empty() ? BSONObj() : infos.front().getObjectField("options").getOwned(); } -Status PipelineD::MongoDProcessInterface::renameIfOptionsAndIndexesHaveNotChanged( +Status PipelineD::MongoDInterface::renameIfOptionsAndIndexesHaveNotChanged( OperationContext* opCtx, const BSONObj& renameCommandObj, const NamespaceString& targetNs, @@ -679,8 +676,7 @@ Status PipelineD::MongoDProcessInterface::renameIfOptionsAndIndexesHaveNotChange str::stream() << "renameCollection failed: " << info}; } -StatusWith<std::unique_ptr<Pipeline, PipelineDeleter>> -PipelineD::MongoDProcessInterface::makePipeline( +StatusWith<std::unique_ptr<Pipeline, PipelineDeleter>> PipelineD::MongoDInterface::makePipeline( const std::vector<BSONObj>& rawPipeline, const boost::intrusive_ptr<ExpressionContext>& expCtx, const MakePipelineOptions opts) { @@ -702,7 +698,7 @@ PipelineD::MongoDProcessInterface::makePipeline( return cursorStatus.isOK() ? std::move(pipeline) : cursorStatus; } -Status PipelineD::MongoDProcessInterface::attachCursorSourceToPipeline( +Status PipelineD::MongoDInterface::attachCursorSourceToPipeline( const boost::intrusive_ptr<ExpressionContext>& expCtx, Pipeline* pipeline) { invariant(pipeline->getSources().empty() || !dynamic_cast<DocumentSourceCursor*>(pipeline->getSources().front().get())); @@ -736,7 +732,7 @@ Status PipelineD::MongoDProcessInterface::attachCursorSourceToPipeline( return Status::OK(); } -std::vector<BSONObj> PipelineD::MongoDProcessInterface::getCurrentOps( +std::vector<BSONObj> PipelineD::MongoDInterface::getCurrentOps( OperationContext* opCtx, CurrentOpConnectionsMode connMode, CurrentOpUserMode userMode, @@ -813,7 +809,7 @@ std::vector<BSONObj> PipelineD::MongoDProcessInterface::getCurrentOps( return ops; } -std::string PipelineD::MongoDProcessInterface::getShardName(OperationContext* opCtx) const { +std::string PipelineD::MongoDInterface::getShardName(OperationContext* opCtx) const { if (ShardingState::get(opCtx)->enabled()) { return ShardingState::get(opCtx)->getShardName(); } @@ -821,7 +817,7 @@ std::string PipelineD::MongoDProcessInterface::getShardName(OperationContext* op return std::string(); } -std::vector<FieldPath> PipelineD::MongoDProcessInterface::collectDocumentKeyFields( +std::vector<FieldPath> PipelineD::MongoDInterface::collectDocumentKeyFields( OperationContext* opCtx, const NamespaceString& nss, UUID uuid) const { if (!ShardingState::get(opCtx)->enabled()) { return {"_id"}; // Nothing is sharded. @@ -854,12 +850,12 @@ std::vector<FieldPath> PipelineD::MongoDProcessInterface::collectDocumentKeyFiel return result; } -std::vector<GenericCursor> PipelineD::MongoDProcessInterface::getCursors( +std::vector<GenericCursor> PipelineD::MongoDInterface::getCursors( const intrusive_ptr<ExpressionContext>& expCtx) const { return CursorManager::getAllCursors(expCtx->opCtx); } -boost::optional<Document> PipelineD::MongoDProcessInterface::lookupSingleDocument( +boost::optional<Document> PipelineD::MongoDInterface::lookupSingleDocument( const boost::intrusive_ptr<ExpressionContext>& expCtx, const NamespaceString& nss, UUID collectionUUID, @@ -891,7 +887,7 @@ boost::optional<Document> PipelineD::MongoDProcessInterface::lookupSingleDocumen return lookedUpDocument; } -std::unique_ptr<CollatorInterface> PipelineD::MongoDProcessInterface::_getCollectionDefaultCollator( +std::unique_ptr<CollatorInterface> PipelineD::MongoDInterface::_getCollectionDefaultCollator( OperationContext* opCtx, const NamespaceString& nss, UUID collectionUUID) { if (_collatorCache.find(collectionUUID) == _collatorCache.end()) { AutoGetCollection autoColl(opCtx, nss, collectionUUID, MODE_IS); diff --git a/src/mongo/db/pipeline/pipeline_d.h b/src/mongo/db/pipeline/pipeline_d.h index 1551a9d035f..afbb6b8f73f 100644 --- a/src/mongo/db/pipeline/pipeline_d.h +++ b/src/mongo/db/pipeline/pipeline_d.h @@ -61,9 +61,9 @@ struct DepsTracker; */ class PipelineD { public: - class MongoDProcessInterface final : public MongoProcessInterface { + class MongoDInterface final : public MongoProcessInterface { public: - MongoDProcessInterface(OperationContext* opCtx); + MongoDInterface(OperationContext* opCtx); void setOperationContext(OperationContext* opCtx) final; DBClientBase* directClient() final; diff --git a/src/mongo/s/commands/cluster_aggregate.cpp b/src/mongo/s/commands/cluster_aggregate.cpp index 7e7577dbdb3..c90346763d0 100644 --- a/src/mongo/s/commands/cluster_aggregate.cpp +++ b/src/mongo/s/commands/cluster_aggregate.cpp @@ -731,7 +731,7 @@ Status ClusterAggregate::runAggregate(OperationContext* opCtx, new ExpressionContext(opCtx, request, std::move(collation), - std::make_shared<PipelineS::MongoSProcessInterface>(), + std::make_shared<PipelineS::MongoSInterface>(), std::move(resolvedNamespaces)); mergeCtx->inMongos = true; // explicitly *not* setting mergeCtx->tempDir diff --git a/src/mongo/s/commands/pipeline_s.cpp b/src/mongo/s/commands/pipeline_s.cpp index 8c198771e2b..26f8dad4ec2 100644 --- a/src/mongo/s/commands/pipeline_s.cpp +++ b/src/mongo/s/commands/pipeline_s.cpp @@ -89,7 +89,7 @@ StatusWith<CachedCollectionRoutingInfo> getCollectionRoutingInfo( } // namespace -boost::optional<Document> PipelineS::MongoSProcessInterface::lookupSingleDocument( +boost::optional<Document> PipelineS::MongoSInterface::lookupSingleDocument( const boost::intrusive_ptr<ExpressionContext>& expCtx, const NamespaceString& nss, UUID collectionUUID, @@ -184,7 +184,7 @@ boost::optional<Document> PipelineS::MongoSProcessInterface::lookupSingleDocumen return (!batch.empty() ? Document(batch.front()) : boost::optional<Document>{}); } -std::vector<GenericCursor> PipelineS::MongoSProcessInterface::getCursors( +std::vector<GenericCursor> PipelineS::MongoSInterface::getCursors( const intrusive_ptr<ExpressionContext>& expCtx) const { invariant(hasGlobalServiceContext()); auto cursorManager = Grid::get(expCtx->opCtx->getServiceContext())->getCursorManager(); diff --git a/src/mongo/s/commands/pipeline_s.h b/src/mongo/s/commands/pipeline_s.h index 173242e7653..cdf72158e31 100644 --- a/src/mongo/s/commands/pipeline_s.h +++ b/src/mongo/s/commands/pipeline_s.h @@ -43,11 +43,11 @@ public: * Class to provide access to mongos-specific implementations of methods required by some * document sources. */ - class MongoSProcessInterface final : public MongoProcessInterface { + class MongoSInterface final : public MongoProcessInterface { public: - MongoSProcessInterface() = default; + MongoSInterface() = default; - virtual ~MongoSProcessInterface() = default; + virtual ~MongoSInterface() = default; void setOperationContext(OperationContext* opCtx) final {} |