summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/accumulator_for_window_functions.h
diff options
context:
space:
mode:
authorTed Tuckman <ted.tuckman@mongodb.com>2021-11-03 01:05:33 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-03 01:29:35 +0000
commit758a30de51c4fd33488249079db18c72928901a4 (patch)
tree96709885eac94680e784575db830f963a57f0612 /src/mongo/db/pipeline/accumulator_for_window_functions.h
parent2eaa640caa44332a0cf63b3e69b62a88f1d9c0cd (diff)
downloadmongo-758a30de51c4fd33488249079db18c72928901a4.tar.gz
SERVER-60501 Add $locf accumulator
Diffstat (limited to 'src/mongo/db/pipeline/accumulator_for_window_functions.h')
-rw-r--r--src/mongo/db/pipeline/accumulator_for_window_functions.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/accumulator_for_window_functions.h b/src/mongo/db/pipeline/accumulator_for_window_functions.h
index 77f42695935..2ac3edbdca4 100644
--- a/src/mongo/db/pipeline/accumulator_for_window_functions.h
+++ b/src/mongo/db/pipeline/accumulator_for_window_functions.h
@@ -170,4 +170,23 @@ private:
WindowFunctionIntegral _integralWF;
};
+class AccumulatorLocf : public AccumulatorForWindowFunctions {
+public:
+ static constexpr auto kName = "$locf"_sd;
+
+ const char* getOpName() const final {
+ return kName.rawData();
+ }
+
+ explicit AccumulatorLocf(ExpressionContext* expCtx);
+
+ void processInternal(const Value& input, bool merging) final;
+ Value getValue(bool toBeMerged) final;
+ void reset() final;
+ static boost::intrusive_ptr<AccumulatorState> create(ExpressionContext* expCtx);
+
+private:
+ Value _lastNonNull;
+};
+
} // namespace mongo