diff options
author | Ian Boros <puppyofkosh@gmail.com> | 2019-05-29 19:31:05 -0400 |
---|---|---|
committer | Ian Boros <puppyofkosh@gmail.com> | 2019-06-07 13:15:21 -0400 |
commit | ab322d38ef3d5c3836df516f2a40c54c5165cafd (patch) | |
tree | 1a1d77ad40275d3160b1701a2984745965f9da45 /src/mongo/db/pipeline/stub_mongo_process_interface_lookup_single_document.h | |
parent | d5a46532dd80c4255982308cb933cf78efb21a7f (diff) | |
download | mongo-ab322d38ef3d5c3836df516f2a40c54c5165cafd.tar.gz |
SERVER-41294 shard filtering for $sb
Diffstat (limited to 'src/mongo/db/pipeline/stub_mongo_process_interface_lookup_single_document.h')
-rw-r--r-- | src/mongo/db/pipeline/stub_mongo_process_interface_lookup_single_document.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/stub_mongo_process_interface_lookup_single_document.h b/src/mongo/db/pipeline/stub_mongo_process_interface_lookup_single_document.h index 4b3bcbaafdc..36d9dd81cbc 100644 --- a/src/mongo/db/pipeline/stub_mongo_process_interface_lookup_single_document.h +++ b/src/mongo/db/pipeline/stub_mongo_process_interface_lookup_single_document.h @@ -33,6 +33,7 @@ #include <deque> #include <vector> +#include "mongo/db/exec/shard_filterer.h" #include "mongo/db/pipeline/document.h" #include "mongo/db/pipeline/document_source.h" #include "mongo/db/pipeline/pipeline.h" @@ -40,6 +41,21 @@ namespace mongo { +class StubShardFilterer : public ShardFilterer { +public: + DocumentBelongsResult documentBelongsToMe(const MatchableDocument& doc) const override { + MONGO_UNREACHABLE; + } + + bool isCollectionSharded() const override { + MONGO_UNREACHABLE; + } + + const KeyPattern& getKeyPattern() const override { + MONGO_UNREACHABLE; + } +}; + /** * A mock MongoProcessInterface which allows mocking a foreign pipeline. */ @@ -67,6 +83,16 @@ public: boost::optional<BSONObj> readConcern, bool allowSpeculativeMajorityRead); + std::unique_ptr<ShardFilterer> getShardFilterer( + const boost::intrusive_ptr<ExpressionContext>& expCtx) const override { + // Try to emulate the behavior mongos and mongod would each follow. + if (expCtx->inMongos) { + return nullptr; + } else { + return stdx::make_unique<StubShardFilterer>(); + } + } + private: std::deque<DocumentSource::GetNextResult> _mockResults; }; |