summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/window_function/window_bounds.cpp
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/pipeline/window_function/window_bounds.cpp
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (diff)
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0' with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/pipeline/window_function/window_bounds.cpp')
-rw-r--r--src/mongo/db/pipeline/window_function/window_bounds.cpp34
1 files changed, 9 insertions, 25 deletions
diff --git a/src/mongo/db/pipeline/window_function/window_bounds.cpp b/src/mongo/db/pipeline/window_function/window_bounds.cpp
index 7ede49d0065..dd082135e02 100644
--- a/src/mongo/db/pipeline/window_function/window_bounds.cpp
+++ b/src/mongo/db/pipeline/window_function/window_bounds.cpp
@@ -63,19 +63,12 @@ WindowBounds::Bound<T> parseBound(ExpressionContext* expCtx,
}
template <class T>
-Value serializeBound(const WindowBounds::Bound<T>& bound,
- const SerializationOptions& opts,
- const Value& representativeValue) {
+Value serializeBound(const WindowBounds::Bound<T>& bound) {
return stdx::visit(
visit_helper::Overloaded{
- [&](const WindowBounds::Unbounded&) { return Value(WindowBounds::kValUnbounded); },
- [&](const WindowBounds::Current&) { return Value(WindowBounds::kValCurrent); },
- [&](const T& n) {
- // If not "unbounded" or "current", n must be a literal constant
- // The upper bound must be greater than the lower bound. We override the
- // representative value to meet this constraint.
- return opts.serializeLiteral(n, representativeValue);
- },
+ [](const WindowBounds::Unbounded&) { return Value(WindowBounds::kValUnbounded); },
+ [](const WindowBounds::Current&) { return Value(WindowBounds::kValCurrent); },
+ [](const T& n) { return Value(n); },
},
bound);
}
@@ -222,31 +215,22 @@ WindowBounds WindowBounds::parse(BSONObj args,
uassert(5339902,
"Range-based bounds require sortBy a single field",
sortBy && sortBy->size() == 1);
- const SortPattern::SortPatternPart& part = *sortBy->begin();
- uassert(8947400,
- "Range-based bounds require a non-expression sortBy",
- part.fieldPath && !part.expression);
- uassert(8947401, "Range-based bounds require an ascending sortBy", part.isAscending);
return bounds;
}
}
-void WindowBounds::serialize(MutableDocument& args, const SerializationOptions& opts) const {
+void WindowBounds::serialize(MutableDocument& args) const {
stdx::visit(
visit_helper::Overloaded{
[&](const DocumentBased& docBounds) {
args[kArgDocuments] = Value{std::vector<Value>{
- serializeBound(
- docBounds.lower, opts, /* representative value, if needed */ Value(0LL)),
- serializeBound(
- docBounds.upper, opts, /* representative value, if needed */ Value(1LL)),
+ serializeBound(docBounds.lower),
+ serializeBound(docBounds.upper),
}};
},
[&](const RangeBased& rangeBounds) {
args[kArgRange] = Value{std::vector<Value>{
- serializeBound(
- rangeBounds.lower, opts, /* representative value, if needed */ Value(0LL)),
- serializeBound(
- rangeBounds.upper, opts, /* representative value, if needed */ Value(1LL)),
+ serializeBound(rangeBounds.lower),
+ serializeBound(rangeBounds.upper),
}};
if (rangeBounds.unit) {
args[kArgUnit] = Value{serializeTimeUnit(*rangeBounds.unit)};