From b95d1f02854ea298d9ae41a6614c409797182e54 Mon Sep 17 00:00:00 2001 From: Craig Taverner Date: Thu, 31 Oct 2024 10:17:18 +0100 Subject: [PATCH] Fix NPE for PushStatsToSource --- .../org/elasticsearch/xpack/esql/stats/SearchStats.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/stats/SearchStats.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/stats/SearchStats.java index 9b11670184159..b384849162043 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/stats/SearchStats.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/stats/SearchStats.java @@ -75,7 +75,7 @@ public long count() { } public long count(String field) { - var stat = cache.computeIfAbsent(field, s -> new FieldStat()); + var stat = cache.computeIfAbsent(field, this::makeFieldStat); if (stat.count == null) { var count = new long[] { 0 }; boolean completed = doWithContexts(r -> { @@ -156,7 +156,7 @@ public boolean hasDocValues(String field) { } public byte[] min(String field, DataType dataType) { - var stat = cache.computeIfAbsent(field, s -> new FieldStat()); + var stat = cache.computeIfAbsent(field, this::makeFieldStat); if (stat.min == null) { var min = new byte[][] { null }; doWithContexts(r -> { @@ -178,7 +178,7 @@ public byte[] min(String field, DataType dataType) { } public byte[] max(String field, DataType dataType) { - var stat = cache.computeIfAbsent(field, s -> new FieldStat()); + var stat = cache.computeIfAbsent(field, this::makeFieldStat); if (stat.max == null) { var max = new byte[][] { null }; doWithContexts(r -> { @@ -200,7 +200,7 @@ public byte[] max(String field, DataType dataType) { } public boolean isSingleValue(String field) { - var stat = cache.computeIfAbsent(field, s -> new FieldStat()); + var stat = cache.computeIfAbsent(field, this::makeFieldStat); if (stat.singleValue == null) { // there's no such field so no need to worry about multi-value fields if (exists(field) == false) {