summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-04-12 09:28:48 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2022-04-12 09:43:32 +0200
commit4fd3898ba112c32bd740e94d75448c3c91f4e0d9 (patch)
treeae72c74f619360ef5efc1e2a8d9414971b765f69 /container-search
parentd3b9917ecc210db49b998d40b4c649b3ff6d5afe (diff)
Optimize for the leaf groups that has no children since there are most of them.
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/grouping/vespa/ResultBuilder.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/grouping/vespa/ResultBuilder.java b/container-search/src/main/java/com/yahoo/search/grouping/vespa/ResultBuilder.java
index d7592d4f97a..950e9da48ad 100644
--- a/container-search/src/main/java/com/yahoo/search/grouping/vespa/ResultBuilder.java
+++ b/container-search/src/main/java/com/yahoo/search/grouping/vespa/ResultBuilder.java
@@ -143,9 +143,9 @@ class ResultBuilder {
}
private class GroupBuilder {
-
+ private static final int CHILDLIST_SIZE_INCREMENTS = 4;
boolean [] results = new boolean[8];
- GroupListBuilder [] childLists = new GroupListBuilder[8];
+ GroupListBuilder [] childLists;
int childCount = 0;
final ResultId resultId;
final com.yahoo.searchlib.aggregation.Group group;
@@ -173,9 +173,11 @@ class ResultBuilder {
}
}
}
- for (GroupListBuilder child : childLists) {
- if (child != null) {
- group.add(child.build());
+ if (childLists != null) {
+ for (GroupListBuilder child : childLists) {
+ if (child != null) {
+ group.add(child.build());
+ }
}
}
return group;
@@ -183,8 +185,11 @@ class ResultBuilder {
GroupListBuilder getOrCreateChildList(int tag, boolean ranked) {
int index = tag + 1; // Add 1 to avoid the dreaded -1 default value.
- if (index >= childLists.length) {
- childLists = Arrays.copyOf(childLists, tag + 8);
+ if (childLists == null || index >= childLists.length) {
+ int reservedSize = (((index + 1) + (CHILDLIST_SIZE_INCREMENTS -1))/CHILDLIST_SIZE_INCREMENTS) * CHILDLIST_SIZE_INCREMENTS;
+ childLists = (childLists == null)
+ ? new GroupListBuilder[reservedSize]
+ : Arrays.copyOf(childLists, reservedSize);
}
GroupListBuilder ret = childLists[index];
if (ret == null) {