diff options
author | Ted Tuckman <ted.tuckman@mongodb.com> | 2019-10-14 20:58:20 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-14 20:58:20 +0000 |
commit | 2fb44f082935fcefdce1fcb94e0cef2aab6e945e (patch) | |
tree | d842d9241998e704ac05c15b4c7a1f39408cfbc1 /src/mongo/db/pipeline/accumulation_statement.h | |
parent | c119ef45e3f1c2cc7f36c7b81d0731e332461c2b (diff) | |
download | mongo-2fb44f082935fcefdce1fcb94e0cef2aab6e945e.tar.gz |
SERVER-43796 Support accumulators with an additional static argument
Diffstat (limited to 'src/mongo/db/pipeline/accumulation_statement.h')
-rw-r--r-- | src/mongo/db/pipeline/accumulation_statement.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mongo/db/pipeline/accumulation_statement.h b/src/mongo/db/pipeline/accumulation_statement.h index 07becc751e1..14b8ea953ab 100644 --- a/src/mongo/db/pipeline/accumulation_statement.h +++ b/src/mongo/db/pipeline/accumulation_statement.h @@ -58,6 +58,8 @@ namespace mongo { */ class AccumulationStatement { public: + using Parser = std::function<std::pair<boost::intrusive_ptr<Expression>, Accumulator::Factory>( + boost::intrusive_ptr<ExpressionContext>, BSONElement, VariablesParseState)>; AccumulationStatement(std::string fieldName, boost::intrusive_ptr<Expression> expression, Accumulator::Factory factory) @@ -84,13 +86,13 @@ public: * DO NOT call this method directly. Instead, use the REGISTER_ACCUMULATOR macro defined in this * file. */ - static void registerAccumulator(std::string name, Accumulator::Factory factory); + static void registerAccumulator(std::string name, Parser parser); /** - * Retrieves the Factory for the accumulator specified by the given name, and raises an error if + * Retrieves the Parser for the accumulator specified by the given name, and raises an error if * there is no such Accumulator registered. */ - static Accumulator::Factory getFactory(StringData name); + static Parser& getParser(StringData name); // The field name is used to store the results of the accumulation in a result document. std::string fieldName; @@ -99,8 +101,7 @@ public: boost::intrusive_ptr<Expression> expression; // Constructs an Accumulator to do actual accumulation. - boost::intrusive_ptr<Accumulator> makeAccumulator( - const boost::intrusive_ptr<ExpressionContext>& expCtx) const; + boost::intrusive_ptr<Accumulator> makeAccumulator() const; private: Accumulator::Factory _factory; |