Skip to content

Commit 0a6019b

Browse files
authored
CompositeSyntheticFieldLoader tweak (#128461) (#128474)
SourceLoader.SyntheticFieldLoader#write(...) is hot code, avoid using streams api and use loop and compute sum.
1 parent 201ba9a commit 0a6019b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

server/src/main/java/org/elasticsearch/index/mapper/CompositeSyntheticFieldLoader.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ public boolean hasValue() {
9191

9292
@Override
9393
public void write(XContentBuilder b) throws IOException {
94-
var totalCount = parts.stream().mapToLong(Layer::valueCount).sum();
94+
long totalCount = 0;
95+
for (Layer part : parts) {
96+
totalCount += part.valueCount();
97+
}
9598

9699
if (totalCount == 0) {
97100
return;

0 commit comments

Comments
 (0)