diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-04-12 11:00:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 11:00:35 +0200 |
commit | 0bdf1aa3c98e1b985e64cd0483bc4709a429de4f (patch) | |
tree | a05a7d5f9c5760ebb63f3a357eaec92d980d9f2e /container-search | |
parent | 94f2951bef4bbdb4194742528822a097bbe98c8f (diff) | |
parent | de21897599ea05aecd75f64ed758d49bac4d4958 (diff) |
Merge pull request #22098 from vespa-engine/balder/optimize-for-the-leaf-groups
Optimize for the leaf groups that has no children since there are mos…
Diffstat (limited to 'container-search')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/grouping/vespa/ResultBuilder.java | 20 |
1 files changed, 13 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 2b8ab938347..695707bfc50 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,12 @@ 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 minSize = index + 1; + int reservedSize = ((minSize + (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) { |