summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/grouping/request/GroupingOperation.java5
-rw-r--r--container-search/src/main/java/com/yahoo/search/grouping/vespa/RequestBuilder.java41
2 files changed, 23 insertions, 23 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/request/GroupingOperation.java b/container-search/src/main/java/com/yahoo/search/grouping/request/GroupingOperation.java
index a4934586b3f..db9585e0637 100644
--- a/container-search/src/main/java/com/yahoo/search/grouping/request/GroupingOperation.java
+++ b/container-search/src/main/java/com/yahoo/search/grouping/request/GroupingOperation.java
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.request;
+import com.yahoo.api.annotations.Beta;
import com.yahoo.collections.LazyMap;
import com.yahoo.collections.LazySet;
import com.yahoo.search.grouping.request.parser.GroupingParser;
@@ -25,6 +26,8 @@ import java.util.Set;
*/
public abstract class GroupingOperation extends GroupingNode {
+ @Beta public static final int UNLIMITED_MAX = Integer.MAX_VALUE;
+
private final List<GroupingExpression> orderBy = new ArrayList<>();
private final List<GroupingExpression> outputs = new ArrayList<>();
private final List<GroupingOperation> children = new ArrayList<>();
@@ -269,6 +272,8 @@ public abstract class GroupingOperation extends GroupingNode {
/** Indicates if the 'max' value has been set. */
public boolean hasMax() { return max >= 0; }
+ @Beta public boolean hasUnlimitedMax() { return max == Integer.MAX_VALUE; }
+
/**
* Assigns an accuracy value for this. This is a number between 0 and 1 describing the accuracy of the result, which
* again determines the speed of the grouping request. A low value will make sure the grouping operation runs fast,
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/vespa/RequestBuilder.java b/container-search/src/main/java/com/yahoo/search/grouping/vespa/RequestBuilder.java
index 5ee6f7bc604..78452b36cd5 100644
--- a/container-search/src/main/java/com/yahoo/search/grouping/vespa/RequestBuilder.java
+++ b/container-search/src/main/java/com/yahoo/search/grouping/vespa/RequestBuilder.java
@@ -179,16 +179,10 @@ class RequestBuilder {
grpLevel.setPrecision(frame.state.precision + offset);
frame.state.precision = null;
}
- int max = -1;
if (frame.state.max != null) {
- max = frame.state.max;
+ transform.putMax(tag, frame.state.max, "group list");
+ grpLevel.setMaxGroups(LOOKAHEAD + frame.state.max + offset);
frame.state.max = null;
- } else if (defaultMaxGroups >= 0) {
- max = defaultMaxGroups;
- }
- if (max >= 0) {
- transform.putMax(tag, max, "group list");
- grpLevel.setMaxGroups(LOOKAHEAD + max + offset);
}
frame.grouping.getLevels().add(grpLevel);
}
@@ -245,12 +239,19 @@ class RequestBuilder {
return (oldMax < 0) ? newMax : Math.min(oldMax, newMax);
}
private void resolveMax(BuildFrame frame) {
- if (frame.astNode.hasMax()) {
- int max = frame.astNode.getMax();
- if (isTopNAllowed(frame)) {
- frame.grouping.setTopN(computeNewTopN(frame.grouping.getTopN(), max));
- } else {
- frame.state.max = max;
+ if (isTopNAllowed(frame)) {
+ if (frame.astNode.hasMax() && !frame.astNode.hasUnlimitedMax()) {
+ frame.grouping.setTopN(computeNewTopN(frame.grouping.getTopN(), frame.astNode.getMax()));
+ }
+ } else {
+ if (frame.astNode.hasUnlimitedMax()) {
+ frame.state.max = null;
+ } else if (frame.astNode.hasMax()) {
+ frame.state.max = frame.astNode.getMax();
+ } else if (frame.state.groupBy != null && defaultMaxGroups != -1) {
+ frame.state.max = defaultMaxGroups;
+ } else if (frame.state.groupBy == null && defaultMaxHits != -1) {
+ frame.state.max = defaultMaxHits;
}
}
}
@@ -297,17 +298,11 @@ class RequestBuilder {
throw new UnsupportedOperationException("Can not label expression '" + exp + "'.");
}
HitsAggregationResult hits = (HitsAggregationResult)result;
- int max = -1;
if (frame.state.max != null) {
- max = frame.state.max;
- frame.state.max = null;
- } else if (defaultMaxHits >= 0) {
- max = defaultMaxHits;
- }
- if (max >= 0) {
- transform.putMax(tag, max, "hit list");
+ transform.putMax(tag, frame.state.max, "hit list");
int offset = transform.getOffset(tag);
- hits.setMaxHits(LOOKAHEAD + max + offset);
+ hits.setMaxHits(LOOKAHEAD + frame.state.max + offset);
+ frame.state.max = null;
}
transform.putLabel(group.getTag(), tag, frame.state.label, "hit list");
} else {