summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/expression.h
diff options
context:
space:
mode:
authorNeil Shweky <neilshweky@gmail.com>2021-10-29 20:49:04 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-15 15:45:37 +0000
commitca9bb0300c804617e936c2e2516b441a9474e355 (patch)
tree0dbe82b14166d238bb7375f113b073d5b7662c64 /src/mongo/db/pipeline/expression.h
parentfe9052cee98bcff412a06c3e8eaf9e54ea82a14c (diff)
downloadmongo-ca9bb0300c804617e936c2e2516b441a9474e355.tar.gz
SERVER-29425 implement $sortArray in classic engine
Diffstat (limited to 'src/mongo/db/pipeline/expression.h')
-rw-r--r--src/mongo/db/pipeline/expression.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/expression.h b/src/mongo/db/pipeline/expression.h
index 9bbca5ce58b..f7d751a79fd 100644
--- a/src/mongo/db/pipeline/expression.h
+++ b/src/mongo/db/pipeline/expression.h
@@ -54,6 +54,7 @@
#include "mongo/db/query/query_feature_flags_gen.h"
#include "mongo/db/query/sort_pattern.h"
#include "mongo/db/server_options.h"
+#include "mongo/db/update/pattern_cmp.h"
#include "mongo/util/intrusive_counter.h"
#include "mongo/util/str.h"
@@ -2889,6 +2890,41 @@ public:
}
};
+class ExpressionSortArray final : public Expression {
+public:
+ static constexpr auto kName = "$sortArray"_sd;
+ ExpressionSortArray(ExpressionContext* const expCtx,
+ boost::intrusive_ptr<Expression> input,
+ const PatternValueCmp& sortBy)
+ : Expression(expCtx, {std::move(input)}), _input(_children[0]), _sortBy(sortBy) {
+ expCtx->sbeCompatible = false;
+ }
+
+ Value evaluate(const Document& root, Variables* variables) const final;
+ boost::intrusive_ptr<Expression> optimize() final;
+ static boost::intrusive_ptr<Expression> parse(ExpressionContext* expCtx,
+ BSONElement expr,
+ const VariablesParseState& vps);
+ Value serialize(bool explain) const final;
+
+ void acceptVisitor(ExpressionMutableVisitor* visitor) final {
+ return visitor->visit(this);
+ }
+
+ void acceptVisitor(ExpressionConstVisitor* visitor) const final {
+ return visitor->visit(this);
+ }
+
+ const char* getOpName() const;
+
+protected:
+ void _doAddDependencies(DepsTracker* deps) const final;
+
+private:
+ boost::intrusive_ptr<Expression>& _input;
+
+ PatternValueCmp _sortBy;
+};
class ExpressionSlice final : public ExpressionRangedArity<ExpressionSlice, 2, 3> {
public: