summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/grouping/request/MinFunction.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-08-14 11:15:12 +0200
committerJon Bratseth <bratseth@oath.com>2018-08-14 11:15:12 +0200
commit7b134d8ef30cc3bd6e0867ba3f47452d78d4fce0 (patch)
tree96ef67d3c9998c0f51c289d1e8cfb298b26f0e2f /container-search/src/main/java/com/yahoo/search/grouping/request/MinFunction.java
parent216feb84a135cbcd3e20cdb3240a63fdb53439e3 (diff)
Fix Select and grouping bugs
- Deep copy the grouping structure on query copy. It is mutable but we have neglected doing this right until now. - Fix a bug in the previous commit where the last constructed Query.Model was shared between all instances. - Fix a bug in the previous commit where the query string instead of the query tree was reset when a new select expression is set. - Don't use deprecated method. - Clean up Javadoc and formatting.
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/grouping/request/MinFunction.java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/grouping/request/MinFunction.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/request/MinFunction.java b/container-search/src/main/java/com/yahoo/search/grouping/request/MinFunction.java
index 478684dd73e..40fbda5a98a 100644
--- a/container-search/src/main/java/com/yahoo/search/grouping/request/MinFunction.java
+++ b/container-search/src/main/java/com/yahoo/search/grouping/request/MinFunction.java
@@ -1,7 +1,9 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.request;
+import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
/**
* This class represents a min-function in a {@link GroupingExpression}. It evaluates to a number that equals the
@@ -19,11 +21,18 @@ public class MinFunction extends FunctionNode {
* @param argN The optional arguments, must evaluate to a number.
*/
public MinFunction(GroupingExpression arg1, GroupingExpression arg2, GroupingExpression... argN) {
- this(asList(arg1, arg2, argN));
+ this(null, null, asList(arg1, arg2, argN));
}
- private MinFunction(List<GroupingExpression> args) {
- super("min", args);
+ private MinFunction(String label, Integer level, List<GroupingExpression> args) {
+ super("min", label, level, args);
+ }
+
+ @Override
+ public MinFunction copy() {
+ return new MinFunction(getLabel(),
+ getLevelOrNull(),
+ args().stream().map(arg -> arg.copy()).collect(Collectors.toList()));
}
/**
@@ -37,7 +46,7 @@ public class MinFunction extends FunctionNode {
if (args.size() < 2) {
throw new IllegalArgumentException("Expected 2 or more arguments, got " + args.size() + ".");
}
- return new MinFunction(args);
+ return new MinFunction(null, null, args);
}
}