From 510848f037f17ce2e5c6516a62e035abd7e22e3c Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Tue, 24 Nov 2015 10:00:41 +0000 Subject: [PATCH] Aggregations Refactor: Refactor Scripted Metric Aggregation --- .../java/org/elasticsearch/script/Script.java | 20 +++- .../scripted/ScriptedMetricAggregator.java | 105 +++++++++++++++++- .../scripted/ScriptedMetricParser.java | 12 +- .../metrics/ScriptedMetricTests.java | 62 +++++++++++ 4 files changed, 190 insertions(+), 9 deletions(-) create mode 100644 core/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricTests.java diff --git a/core/src/main/java/org/elasticsearch/script/Script.java b/core/src/main/java/org/elasticsearch/script/Script.java index fb2226e97a219..dc0e3835c3435 100644 --- a/core/src/main/java/org/elasticsearch/script/Script.java +++ b/core/src/main/java/org/elasticsearch/script/Script.java @@ -34,12 +34,24 @@ import java.io.IOException; import java.util.Map; +import java.util.function.Supplier; /** * Script holds all the parameters necessary to compile or find in cache and then execute a script. */ public class Script implements ToXContent, Streamable { + /** + * A {@link Supplier} implementation for use when reading a {@link Script} + * using {@link StreamInput#readOptionalStreamable(Supplier)} + */ + public static final Supplier