From 9de170e182f0bc28107fdd9a1153b76aa4dd1d91 Mon Sep 17 00:00:00 2001 From: Aaron Stockton Date: Mon, 26 Nov 2018 10:11:47 -0700 Subject: [PATCH 01/20] Add errorBoundsStdDev to ThetaSketch postAggregation. Allow dimensions to be null in GroupByQuery as they are not required --- .../ThetaSketchEstimatePostAggregator.java | 13 ++++++++++ .../query/aggregation/DruidGroupByQuery.java | 4 +-- ...ThetaSketchEstimatePostAggregatorTest.java | 26 ++++++++++++++++++- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java index 23dae2b8..21b346c7 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java @@ -16,6 +16,7 @@ package in.zapr.druid.druidry.extensions.datasketches.postAggregator; +import com.fasterxml.jackson.annotation.JsonInclude; import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Getter; import lombok.NonNull; @@ -27,6 +28,9 @@ public class ThetaSketchEstimatePostAggregator extends DruidPostAggregator { private DruidPostAggregator field; + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + private int errorBoundsStdDev; + public ThetaSketchEstimatePostAggregator(@NonNull String name, @NonNull DruidPostAggregator field) { this.type = THETA_SKETCH_ESTIMATE_POST_AGGREGATOR_TYPE; @@ -34,4 +38,13 @@ public ThetaSketchEstimatePostAggregator(@NonNull String name, this.field = field; } + public ThetaSketchEstimatePostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field, + int errorBoundsStdDev) { + this.type = THETA_SKETCH_ESTIMATE_POST_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + this.errorBoundsStdDev = errorBoundsStdDev; + } + } diff --git a/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidGroupByQuery.java b/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidGroupByQuery.java index 94a2c786..e2e6a164 100644 --- a/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidGroupByQuery.java +++ b/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidGroupByQuery.java @@ -41,13 +41,11 @@ public class DruidGroupByQuery extends DruidAggregationQuery { private DefaultLimitSpec limitSpec; private String having; - - @NonNull private List dimensions; @Builder private DruidGroupByQuery(@NonNull String dataSource, - @NonNull List dimensions, + List dimensions, DefaultLimitSpec limitSpec, @NonNull Granularity granularity, DruidFilter filter, diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregatorTest.java index f29cf0dd..af677d76 100644 --- a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregatorTest.java +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregatorTest.java @@ -51,7 +51,7 @@ private JSONObject getFieldAccessJSON() throws JSONException { } @Test - public void testAllFieldsWithFieldAccess() throws JsonProcessingException, JSONException { + public void testRequiredFieldsWithFieldAccess() throws JsonProcessingException, JSONException { FieldAccessPostAggregator fieldAccessPostAggregator = new FieldAccessPostAggregator("stars"); @@ -73,6 +73,30 @@ public void testAllFieldsWithFieldAccess() throws JsonProcessingException, JSONE } + @Test + public void testAllFieldsWithFieldAccess() throws JsonProcessingException, JSONException { + + FieldAccessPostAggregator fieldAccessPostAggregator = + new FieldAccessPostAggregator("stars"); + + ThetaSketchEstimatePostAggregator thetaSketchEstimatePostAggregator = + new ThetaSketchEstimatePostAggregator("estimate_stars", fieldAccessPostAggregator, 2); + + + JSONObject fieldAccess = getFieldAccessJSON(); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "thetaSketchEstimate"); + jsonObject.put("name", "estimate_stars"); + jsonObject.put("errorBoundsStdDev", 2); + jsonObject.put("field", fieldAccess); + + String actualJSON = objectMapper.writeValueAsString(thetaSketchEstimatePostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + + } + @Test public void testAllFieldsWithThetaSketchSetOp() throws JsonProcessingException, JSONException { From b5a6a7bc7180c18200ce1b7bd0489058ed7ad94a Mon Sep 17 00:00:00 2001 From: Aaron Stockton Date: Thu, 6 Dec 2018 22:30:04 -0700 Subject: [PATCH 02/20] use builder, remove primitive, change jackson annotation --- .../ThetaSketchEstimatePostAggregator.java | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java index 21b346c7..c504769c 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java @@ -18,29 +18,23 @@ import com.fasterxml.jackson.annotation.JsonInclude; import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; import lombok.Getter; import lombok.NonNull; @Getter +@JsonInclude(JsonInclude.Include.NON_NULL) public class ThetaSketchEstimatePostAggregator extends DruidPostAggregator { private static final String THETA_SKETCH_ESTIMATE_POST_AGGREGATOR_TYPE = "thetaSketchEstimate"; - private DruidPostAggregator field; + private Integer errorBoundsStdDev; - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private int errorBoundsStdDev; - - public ThetaSketchEstimatePostAggregator(@NonNull String name, - @NonNull DruidPostAggregator field) { - this.type = THETA_SKETCH_ESTIMATE_POST_AGGREGATOR_TYPE; - this.name = name; - this.field = field; - } - - public ThetaSketchEstimatePostAggregator(@NonNull String name, - @NonNull DruidPostAggregator field, - int errorBoundsStdDev) { + @Builder + public ThetaSketchEstimatePostAggregator( + @NonNull String name, + @NonNull DruidPostAggregator field, + Integer errorBoundsStdDev) { this.type = THETA_SKETCH_ESTIMATE_POST_AGGREGATOR_TYPE; this.name = name; this.field = field; From 06e5c3371673039fb0f015f34b5dd2da0161337f Mon Sep 17 00:00:00 2001 From: Aaron Stockton Date: Thu, 6 Dec 2018 22:32:43 -0700 Subject: [PATCH 03/20] non-null dimensionin groupByQuery --- .../druid/druidry/query/aggregation/DruidGroupByQuery.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidGroupByQuery.java b/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidGroupByQuery.java index e2e6a164..ad13e8b3 100644 --- a/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidGroupByQuery.java +++ b/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidGroupByQuery.java @@ -41,11 +41,12 @@ public class DruidGroupByQuery extends DruidAggregationQuery { private DefaultLimitSpec limitSpec; private String having; + @NonNull private List dimensions; @Builder private DruidGroupByQuery(@NonNull String dataSource, - List dimensions, + @NonNull List dimensions, DefaultLimitSpec limitSpec, @NonNull Granularity granularity, DruidFilter filter, From a7105aef028f28c438920d50b3b73222a574d635 Mon Sep 17 00:00:00 2001 From: Viacheslav Chimishuk Date: Tue, 19 Feb 2019 20:18:06 +0200 Subject: [PATCH 04/20] Add virtual columns support. --- README.md | 3 ++ .../aggregation/DruidAggregationQuery.java | 2 + .../query/aggregation/DruidGroupByQuery.java | 5 ++- .../aggregation/DruidTimeSeriesQuery.java | 3 ++ .../query/aggregation/DruidTopNQuery.java | 3 ++ .../virtualColumn/DruidVirtualColumn.java | 18 ++++++++ .../ExpressionVirtualColumn.java | 28 ++++++++++++ .../ExpressionVirtualColumnTest.java | 45 +++++++++++++++++++ 8 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 src/main/java/in/zapr/druid/druidry/virtualColumn/DruidVirtualColumn.java create mode 100644 src/main/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumn.java create mode 100644 src/test/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumnTest.java diff --git a/README.md b/README.md index 2aa0c68f..27a2c7b2 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,9 @@ Supported Features * ThetaSketchEstimate * ThetaSketchSetOp +#### Virtual Columns +* Expression + #### Granularity * Duration * Period diff --git a/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidAggregationQuery.java b/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidAggregationQuery.java index bff05361..09219278 100644 --- a/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidAggregationQuery.java +++ b/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidAggregationQuery.java @@ -26,6 +26,7 @@ import in.zapr.druid.druidry.granularity.Granularity; import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import in.zapr.druid.druidry.query.DruidQuery; +import in.zapr.druid.druidry.virtualColumn.DruidVirtualColumn; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -35,6 +36,7 @@ public abstract class DruidAggregationQuery extends DruidQuery { protected List intervals; protected Granularity granularity; + protected List virtualColumns; protected DruidFilter filter; protected List aggregations; protected List postAggregations; diff --git a/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidGroupByQuery.java b/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidGroupByQuery.java index 94a2c786..5d65f133 100644 --- a/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidGroupByQuery.java +++ b/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidGroupByQuery.java @@ -29,6 +29,7 @@ import in.zapr.druid.druidry.limitSpec.DefaultLimitSpec; import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import in.zapr.druid.druidry.query.QueryType; +import in.zapr.druid.druidry.virtualColumn.DruidVirtualColumn; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -50,6 +51,7 @@ private DruidGroupByQuery(@NonNull String dataSource, @NonNull List dimensions, DefaultLimitSpec limitSpec, @NonNull Granularity granularity, + List virtualColumns, DruidFilter filter, List aggregators, List postAggregators, @@ -61,10 +63,11 @@ private DruidGroupByQuery(@NonNull String dataSource, this.dimensions = dimensions; this.limitSpec = limitSpec; this.granularity = granularity; + this.virtualColumns = virtualColumns; this.filter = filter; this.aggregations = aggregators; this.postAggregations = postAggregators; this.intervals = intervals; this.context = context; } -} \ No newline at end of file +} diff --git a/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidTimeSeriesQuery.java b/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidTimeSeriesQuery.java index c3c52bb2..76de8a97 100644 --- a/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidTimeSeriesQuery.java +++ b/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidTimeSeriesQuery.java @@ -27,6 +27,7 @@ import in.zapr.druid.druidry.granularity.Granularity; import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import in.zapr.druid.druidry.query.QueryType; +import in.zapr.druid.druidry.virtualColumn.DruidVirtualColumn; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -42,6 +43,7 @@ public class DruidTimeSeriesQuery extends DruidAggregationQuery { @Builder private DruidTimeSeriesQuery(@NonNull String dataSource, Boolean descending, @NonNull List intervals, @NonNull Granularity granularity, + List virtualColumns, DruidFilter filter, List aggregators, List postAggregators, Context context) { @@ -50,6 +52,7 @@ private DruidTimeSeriesQuery(@NonNull String dataSource, Boolean descending, this.descending = descending; this.intervals = intervals; this.granularity = granularity; + this.virtualColumns = virtualColumns; this.filter = filter; this.aggregations = aggregators; this.postAggregations = postAggregators; diff --git a/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidTopNQuery.java b/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidTopNQuery.java index ba12711e..0455664c 100644 --- a/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidTopNQuery.java +++ b/src/main/java/in/zapr/druid/druidry/query/aggregation/DruidTopNQuery.java @@ -31,6 +31,7 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import in.zapr.druid.druidry.query.QueryType; import in.zapr.druid.druidry.topNMetric.TopNMetric; +import in.zapr.druid.druidry.virtualColumn.DruidVirtualColumn; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -49,6 +50,7 @@ public class DruidTopNQuery extends DruidAggregationQuery { private DruidTopNQuery(@NonNull String dataSource, @NonNull List intervals, @NonNull Granularity granularity, + List virtualColumns, DruidFilter filter, List aggregators, List postAggregators, @@ -61,6 +63,7 @@ private DruidTopNQuery(@NonNull String dataSource, this.dataSource = dataSource; this.intervals = intervals; this.granularity = granularity; + this.virtualColumns = virtualColumns; this.filter = filter; this.aggregations = aggregators; this.postAggregations = postAggregators; diff --git a/src/main/java/in/zapr/druid/druidry/virtualColumn/DruidVirtualColumn.java b/src/main/java/in/zapr/druid/druidry/virtualColumn/DruidVirtualColumn.java new file mode 100644 index 00000000..b226ea53 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/virtualColumn/DruidVirtualColumn.java @@ -0,0 +1,18 @@ +package in.zapr.druid.druidry.virtualColumn; + +import in.zapr.druid.druidry.dimension.enums.OutputType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@EqualsAndHashCode +public abstract class DruidVirtualColumn { + @NonNull + protected String type; + + @NonNull + protected String name; + + protected OutputType outputType; +} diff --git a/src/main/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumn.java b/src/main/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumn.java new file mode 100644 index 00000000..c2ba8c1d --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumn.java @@ -0,0 +1,28 @@ +package in.zapr.druid.druidry.virtualColumn; + +import javax.annotation.Nonnull; + +import in.zapr.druid.druidry.dimension.enums.OutputType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@EqualsAndHashCode(callSuper = true) +public class ExpressionVirtualColumn extends DruidVirtualColumn { + private static final String EXPRESSION_VIRTUAL_COLUMN = "expression"; + + @NonNull + private String expression; + + public ExpressionVirtualColumn(@NonNull String name, @Nonnull String expression) { + this(name, expression, OutputType.FLOAT); + } + + public ExpressionVirtualColumn(@NonNull String name, @Nonnull String expression, OutputType outputType) { + this.type = EXPRESSION_VIRTUAL_COLUMN; + this.name = name; + this.outputType = outputType; + this.expression = expression; + } +} diff --git a/src/test/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumnTest.java b/src/test/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumnTest.java new file mode 100644 index 00000000..bb3c549c --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumnTest.java @@ -0,0 +1,45 @@ +package in.zapr.druid.druidry.virtualColumn; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import in.zapr.druid.druidry.dimension.enums.OutputType; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class ExpressionVirtualColumnTest { + private static ObjectMapper objectMapper; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + } + + @Test + public void testGeneratedJSON() throws JsonProcessingException, JSONException { + ExpressionVirtualColumn column = new ExpressionVirtualColumn("foo", "a + b"); + JSONObject expected = new JSONObject(); + expected.put("type", "expression"); + expected.put("name", "foo"); + expected.put("outputType", "FLOAT"); + expected.put("expression", "a + b"); + String output = objectMapper.writeValueAsString(column); + JSONAssert.assertEquals(expected.toString(), output, JSONCompareMode.NON_EXTENSIBLE); + + column = new ExpressionVirtualColumn("bar", "a + b", OutputType.LONG); + expected = new JSONObject(); + expected.put("type", "expression"); + expected.put("name", "bar"); + expected.put("outputType", "LONG"); + expected.put("expression", "a + b"); + output = objectMapper.writeValueAsString(column); + JSONAssert.assertEquals(expected.toString(), output, JSONCompareMode.NON_EXTENSIBLE); + } +} From 1fc7bcb2aa95dfe551c8f0050cef1dbebf80fec1 Mon Sep 17 00:00:00 2001 From: Viacheslav Chimishuk Date: Thu, 28 Feb 2019 15:47:36 +0200 Subject: [PATCH 05/20] Add virtual column support also for scan, search and select queries. Address code review comments --- .../druidry/dimension/enums/OutputType.java | 2 +- .../druidry/query/scan/DruidScanQuery.java | 8 +++-- .../query/search/DruidSearchQuery.java | 5 ++- .../query/select/DruidSelectQuery.java | 4 +++ .../virtualColumn/DruidVirtualColumn.java | 3 ++ .../ExpressionVirtualColumn.java | 11 +++--- .../query/scan/DruidScanQueryTest.java | 12 +++++-- .../query/search/DruidSearchQueryTest.java | 16 +++++++++ .../query/select/DruidSelectQueryTest.java | 10 +++++- .../ExpressionVirtualColumnTest.java | 34 +++++++++++++------ 10 files changed, 81 insertions(+), 24 deletions(-) diff --git a/src/main/java/in/zapr/druid/druidry/dimension/enums/OutputType.java b/src/main/java/in/zapr/druid/druidry/dimension/enums/OutputType.java index 66c51bc4..9c710484 100644 --- a/src/main/java/in/zapr/druid/druidry/dimension/enums/OutputType.java +++ b/src/main/java/in/zapr/druid/druidry/dimension/enums/OutputType.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonValue; public enum OutputType { - STRING, LONG, FLOAT; + STRING, LONG, FLOAT, DOUBLE; @JsonValue public String getName() { diff --git a/src/main/java/in/zapr/druid/druidry/query/scan/DruidScanQuery.java b/src/main/java/in/zapr/druid/druidry/query/scan/DruidScanQuery.java index 67530cb1..a20dcca9 100644 --- a/src/main/java/in/zapr/druid/druidry/query/scan/DruidScanQuery.java +++ b/src/main/java/in/zapr/druid/druidry/query/scan/DruidScanQuery.java @@ -27,6 +27,7 @@ import in.zapr.druid.druidry.filter.DruidFilter; import in.zapr.druid.druidry.query.DruidQuery; import in.zapr.druid.druidry.query.QueryType; +import in.zapr.druid.druidry.virtualColumn.DruidVirtualColumn; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -36,7 +37,7 @@ @JsonInclude(JsonInclude.Include.NON_NULL) @EqualsAndHashCode(callSuper = true) public class DruidScanQuery extends DruidQuery { - + private List virtualColumns; private DruidFilter filter; private Integer batchSize; private List intervals; @@ -46,7 +47,10 @@ public class DruidScanQuery extends DruidQuery { private Boolean legacy; @Builder - private DruidScanQuery(@NonNull String dataSource, DruidFilter filter, Integer batchSize, @NonNull List intervals, List columns, ResultFormat resultFormat, Long limit, Boolean legacy, Context context) { + private DruidScanQuery(@NonNull String dataSource, List virtualColumns, DruidFilter filter, + Integer batchSize, @NonNull List intervals, List columns, ResultFormat resultFormat, + Long limit, Boolean legacy, Context context) { + this.virtualColumns = virtualColumns; this.filter = filter; this.intervals = intervals; this.columns = columns; diff --git a/src/main/java/in/zapr/druid/druidry/query/search/DruidSearchQuery.java b/src/main/java/in/zapr/druid/druidry/query/search/DruidSearchQuery.java index 87287c55..57d5a414 100644 --- a/src/main/java/in/zapr/druid/druidry/query/search/DruidSearchQuery.java +++ b/src/main/java/in/zapr/druid/druidry/query/search/DruidSearchQuery.java @@ -16,7 +16,6 @@ package in.zapr.druid.druidry.query.search; - import com.fasterxml.jackson.annotation.JsonInclude; import java.util.List; @@ -30,6 +29,7 @@ import in.zapr.druid.druidry.granularity.Granularity; import in.zapr.druid.druidry.query.DruidQuery; import in.zapr.druid.druidry.query.QueryType; +import in.zapr.druid.druidry.virtualColumn.DruidVirtualColumn; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -41,6 +41,7 @@ public class DruidSearchQuery extends DruidQuery { private Granularity granularity; + private List virtualColumns; private DruidFilter filter; private Integer limit; private List intervals; @@ -51,6 +52,7 @@ public class DruidSearchQuery extends DruidQuery { @Builder private DruidSearchQuery(@NonNull String dataSource, @NonNull Granularity granularity, + List virtualColumns, DruidFilter filter, Integer limit, @NonNull List intervals, @@ -62,6 +64,7 @@ private DruidSearchQuery(@NonNull String dataSource, this.queryType = QueryType.SEARCH; this.dataSource = dataSource; this.granularity = granularity; + this.virtualColumns = virtualColumns; this.filter = filter; this.limit = limit; this.intervals = intervals; diff --git a/src/main/java/in/zapr/druid/druidry/query/select/DruidSelectQuery.java b/src/main/java/in/zapr/druid/druidry/query/select/DruidSelectQuery.java index d99a26f4..eb83627d 100644 --- a/src/main/java/in/zapr/druid/druidry/query/select/DruidSelectQuery.java +++ b/src/main/java/in/zapr/druid/druidry/query/select/DruidSelectQuery.java @@ -26,6 +26,7 @@ import in.zapr.druid.druidry.granularity.Granularity; import in.zapr.druid.druidry.query.DruidQuery; import in.zapr.druid.druidry.query.QueryType; +import in.zapr.druid.druidry.virtualColumn.DruidVirtualColumn; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -39,6 +40,7 @@ @EqualsAndHashCode(callSuper = true) public class DruidSelectQuery extends DruidQuery { private List intervals; + private List virtualColumns; private DruidFilter filter; private Boolean descending; private Granularity granularity; @@ -49,6 +51,7 @@ public class DruidSelectQuery extends DruidQuery { @Builder public DruidSelectQuery( @NonNull String dataSource, + List virtualColumns, DruidFilter filter, Boolean descending, Granularity granularity, @@ -60,6 +63,7 @@ public DruidSelectQuery( this.queryType = QueryType.SELECT; this.context = context; this.dataSource = dataSource; + this.virtualColumns = virtualColumns; this.filter = filter; this.descending = descending; this.granularity = granularity; diff --git a/src/main/java/in/zapr/druid/druidry/virtualColumn/DruidVirtualColumn.java b/src/main/java/in/zapr/druid/druidry/virtualColumn/DruidVirtualColumn.java index b226ea53..deba1a75 100644 --- a/src/main/java/in/zapr/druid/druidry/virtualColumn/DruidVirtualColumn.java +++ b/src/main/java/in/zapr/druid/druidry/virtualColumn/DruidVirtualColumn.java @@ -1,5 +1,7 @@ package in.zapr.druid.druidry.virtualColumn; +import com.fasterxml.jackson.annotation.JsonInclude; + import in.zapr.druid.druidry.dimension.enums.OutputType; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -7,6 +9,7 @@ @Getter @EqualsAndHashCode +@JsonInclude(JsonInclude.Include.NON_NULL) public abstract class DruidVirtualColumn { @NonNull protected String type; diff --git a/src/main/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumn.java b/src/main/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumn.java index c2ba8c1d..af186fc0 100644 --- a/src/main/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumn.java +++ b/src/main/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumn.java @@ -1,25 +1,24 @@ package in.zapr.druid.druidry.virtualColumn; -import javax.annotation.Nonnull; +import com.fasterxml.jackson.annotation.JsonInclude; import in.zapr.druid.druidry.dimension.enums.OutputType; +import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @EqualsAndHashCode(callSuper = true) +@JsonInclude(JsonInclude.Include.NON_NULL) public class ExpressionVirtualColumn extends DruidVirtualColumn { private static final String EXPRESSION_VIRTUAL_COLUMN = "expression"; @NonNull private String expression; - public ExpressionVirtualColumn(@NonNull String name, @Nonnull String expression) { - this(name, expression, OutputType.FLOAT); - } - - public ExpressionVirtualColumn(@NonNull String name, @Nonnull String expression, OutputType outputType) { + @Builder + public ExpressionVirtualColumn(@NonNull String name, @NonNull String expression, OutputType outputType) { this.type = EXPRESSION_VIRTUAL_COLUMN; this.name = name; this.outputType = outputType; diff --git a/src/test/java/in/zapr/druid/druidry/query/scan/DruidScanQueryTest.java b/src/test/java/in/zapr/druid/druidry/query/scan/DruidScanQueryTest.java index cb9b6319..ea737da2 100644 --- a/src/test/java/in/zapr/druid/druidry/query/scan/DruidScanQueryTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/scan/DruidScanQueryTest.java @@ -32,8 +32,10 @@ import java.util.List; import in.zapr.druid.druidry.Interval; +import in.zapr.druid.druidry.dimension.enums.OutputType; import in.zapr.druid.druidry.filter.DruidFilter; import in.zapr.druid.druidry.filter.SelectorFilter; +import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; public class DruidScanQueryTest { private static ObjectMapper objectMapper; @@ -62,6 +64,7 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { DruidScanQuery query = DruidScanQuery.builder() .dataSource("sample_datasource") .columns(searchDimensions) + .virtualColumns(Collections.singletonList(new ExpressionVirtualColumn("dim3", "dim1 + dim2", OutputType.FLOAT))) .filter(filter) .resultFormat(ResultFormat.LIST) .intervals(Collections.singletonList(interval)) @@ -77,6 +80,12 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { " \"dim1\",\n" + " \"dim2\"\n" + " ],\n" + + " \"virtualColumns\": [{\n" + + " \"type\": \"expression\",\n" + + " \"name\": \"dim3\",\n" + + " \"outputType\": \"FLOAT\",\n" + + " \"expression\": \"dim1 + dim2\"\n" + + " }],\n" + " \"filter\": {\n" + " \"type\": \"selector\",\n" + " \"dimension\": \"dim1\",\n" + @@ -92,7 +101,7 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { "}"; String actualJson = objectMapper.writeValueAsString(query); - JSONAssert.assertEquals(actualJson, expectedJsonAsString, JSONCompareMode.NON_EXTENSIBLE); + JSONAssert.assertEquals(expectedJsonAsString, actualJson, JSONCompareMode.NON_EXTENSIBLE); } @@ -207,4 +216,3 @@ public void testSampleQueryWithEmptyLines() throws JsonProcessingException, JSON } } - diff --git a/src/test/java/in/zapr/druid/druidry/query/search/DruidSearchQueryTest.java b/src/test/java/in/zapr/druid/druidry/query/search/DruidSearchQueryTest.java index 83884b48..94242eee 100644 --- a/src/test/java/in/zapr/druid/druidry/query/search/DruidSearchQueryTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/search/DruidSearchQueryTest.java @@ -36,12 +36,14 @@ import in.zapr.druid.druidry.SortingOrder; import in.zapr.druid.druidry.dimension.DruidDimension; import in.zapr.druid.druidry.dimension.SimpleDimension; +import in.zapr.druid.druidry.dimension.enums.OutputType; import in.zapr.druid.druidry.filter.DruidFilter; import in.zapr.druid.druidry.filter.SelectorFilter; import in.zapr.druid.druidry.filter.searchQuerySpec.InsensitiveContainsSearchQuerySpec; import in.zapr.druid.druidry.filter.searchQuerySpec.SearchQuerySpec; import in.zapr.druid.druidry.granularity.PredefinedGranularity; import in.zapr.druid.druidry.granularity.SimpleGranularity; +import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; public class DruidSearchQueryTest { private static ObjectMapper objectMapper; @@ -68,6 +70,7 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { DruidSearchQuery query = DruidSearchQuery.builder() .dataSource("sample_datasource") .granularity(new SimpleGranularity(PredefinedGranularity.DAY)) + .virtualColumns(Collections.singletonList(new ExpressionVirtualColumn("dim3", "dim1 + dim2", OutputType.FLOAT))) .searchDimensions(searchDimensions) .query(searchQuerySpec) .sort(SortingOrder.LEXICOGRAPHIC) @@ -78,6 +81,12 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { " \"queryType\": \"search\",\n" + " \"dataSource\": \"sample_datasource\",\n" + " \"granularity\": \"day\",\n" + + " \"virtualColumns\": [{\n" + + " \"type\": \"expression\",\n" + + " \"name\": \"dim3\",\n" + + " \"outputType\": \"FLOAT\",\n" + + " \"expression\": \"dim1 + dim2\"\n" + + " }],\n" + " \"searchDimensions\": [\n" + " \"dim1\",\n" + " \"dim2\"\n" + @@ -156,6 +165,7 @@ public void testAllFields() throws JsonProcessingException, JSONException { DruidSearchQuery query = DruidSearchQuery.builder() .dataSource("sample_datasource") .granularity(new SimpleGranularity(PredefinedGranularity.DAY)) + .virtualColumns(Collections.singletonList(new ExpressionVirtualColumn("dim3", "dim1 + dim2", OutputType.FLOAT))) .filter(druidFilter) .limit(16) .searchDimensions(searchDimensions) @@ -169,6 +179,12 @@ public void testAllFields() throws JsonProcessingException, JSONException { " \"queryType\": \"search\",\n" + " \"dataSource\": \"sample_datasource\",\n" + " \"granularity\": \"day\",\n" + + " \"virtualColumns\": [{\n" + + " \"type\": \"expression\",\n" + + " \"name\": \"dim3\",\n" + + " \"outputType\": \"FLOAT\",\n" + + " \"expression\": \"dim1 + dim2\"\n" + + " }],\n" + " \"filter\": {\n" + " \"type\": \"selector\",\n" + " \"dimension\": \"Dim\",\n" + diff --git a/src/test/java/in/zapr/druid/druidry/query/select/DruidSelectQueryTest.java b/src/test/java/in/zapr/druid/druidry/query/select/DruidSelectQueryTest.java index f6abe385..51f538c0 100644 --- a/src/test/java/in/zapr/druid/druidry/query/select/DruidSelectQueryTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/select/DruidSelectQueryTest.java @@ -31,9 +31,11 @@ import java.util.HashMap; import in.zapr.druid.druidry.Interval; +import in.zapr.druid.druidry.dimension.enums.OutputType; import in.zapr.druid.druidry.granularity.Granularity; import in.zapr.druid.druidry.granularity.PredefinedGranularity; import in.zapr.druid.druidry.granularity.SimpleGranularity; +import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; public class DruidSelectQueryTest { private static ObjectMapper objectMapper; @@ -60,6 +62,7 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { .dataSource("wikipedia") .descending(false) .granularity(granularity) + .virtualColumns(Collections.singletonList(new ExpressionVirtualColumn("dim3", "dim1 + dim2", OutputType.FLOAT))) .intervals(Collections.singletonList(interval)) .pagingSpec(pagingSpec) .build(); @@ -72,6 +75,12 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { " ]," + " \"descending\": false,\n" + " \"granularity\": \"all\",\n" + + " \"virtualColumns\": [{\n" + + " \"type\": \"expression\",\n" + + " \"name\": \"dim3\",\n" + + " \"outputType\": \"FLOAT\",\n" + + " \"expression\": \"dim1 + dim2\"\n" + + " }],\n" + " \"pagingSpec\": {\n" + " \"threshold\": 5,\n" + " \"pagingIdentifiers\": {}\n" + @@ -177,4 +186,3 @@ public void testNullablePagingSpec() { .build(); } } - diff --git a/src/test/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumnTest.java b/src/test/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumnTest.java index bb3c549c..d4aa6535 100644 --- a/src/test/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumnTest.java +++ b/src/test/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumnTest.java @@ -23,23 +23,35 @@ public void init() { } @Test - public void testGeneratedJSON() throws JsonProcessingException, JSONException { - ExpressionVirtualColumn column = new ExpressionVirtualColumn("foo", "a + b"); + public void testAllFields() throws JsonProcessingException, JSONException { + ExpressionVirtualColumn column = new ExpressionVirtualColumn("foo", "a + b", OutputType.LONG); JSONObject expected = new JSONObject(); expected.put("type", "expression"); expected.put("name", "foo"); - expected.put("outputType", "FLOAT"); + expected.put("outputType", "LONG"); expected.put("expression", "a + b"); - String output = objectMapper.writeValueAsString(column); - JSONAssert.assertEquals(expected.toString(), output, JSONCompareMode.NON_EXTENSIBLE); + String actualJSON = objectMapper.writeValueAsString(column); + JSONAssert.assertEquals(expected.toString(), actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } - column = new ExpressionVirtualColumn("bar", "a + b", OutputType.LONG); - expected = new JSONObject(); + @Test + public void testRequiredFields() throws JsonProcessingException, JSONException { + ExpressionVirtualColumn column = new ExpressionVirtualColumn("foo", "a + b", null); + JSONObject expected = new JSONObject(); expected.put("type", "expression"); - expected.put("name", "bar"); - expected.put("outputType", "LONG"); + expected.put("name", "foo"); expected.put("expression", "a + b"); - output = objectMapper.writeValueAsString(column); - JSONAssert.assertEquals(expected.toString(), output, JSONCompareMode.NON_EXTENSIBLE); + String actualJSON = objectMapper.writeValueAsString(column); + JSONAssert.assertEquals(expected.toString(), actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNameMissingFields() { + new ExpressionVirtualColumn(null, "a + b", null); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testExpressionMissingFields() { + new ExpressionVirtualColumn("foo", null, null); } } From f2f32bc0b3a0ee852008875dba133aeb30f51017 Mon Sep 17 00:00:00 2001 From: Gagan Gupta Date: Wed, 29 May 2019 00:56:01 +0530 Subject: [PATCH 06/20] Updated Jackson version to 2.9.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 37578228..f46dc093 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ UTF-8 - 2.9.8 + 2.9.9 2.9.7 1.16.14 6.11 From 90c353121c5f1d97db4bc89b44bbd969b3cd6570 Mon Sep 17 00:00:00 2001 From: Abhi Sapariya Date: Sun, 16 Jun 2019 00:31:10 +0530 Subject: [PATCH 07/20] change constructor to builder in test cases --- .../ThetaSketchEstimatePostAggregator.java | 1 + ...ThetaSketchEstimatePostAggregatorTest.java | 29 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java index c504769c..46871488 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java @@ -17,6 +17,7 @@ package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonInclude; + import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; import lombok.Getter; diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregatorTest.java index 90d66a49..859f4bd1 100644 --- a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregatorTest.java +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregatorTest.java @@ -55,8 +55,10 @@ public void testRequiredFieldsWithFieldAccess() throws JsonProcessingException, new FieldAccessPostAggregator("stars"); ThetaSketchEstimatePostAggregator thetaSketchEstimatePostAggregator = - new ThetaSketchEstimatePostAggregator("estimate_stars", fieldAccessPostAggregator); - + ThetaSketchEstimatePostAggregator.builder() + .name("estimate_stars") + .field(fieldAccessPostAggregator) + .build(); JSONObject fieldAccess = getFieldAccessJSON(); @@ -78,8 +80,11 @@ public void testAllFieldsWithFieldAccess() throws JsonProcessingException, JSONE new FieldAccessPostAggregator("stars"); ThetaSketchEstimatePostAggregator thetaSketchEstimatePostAggregator = - new ThetaSketchEstimatePostAggregator("estimate_stars", fieldAccessPostAggregator, 2); - + ThetaSketchEstimatePostAggregator.builder() + .name("estimate_stars") + .field(fieldAccessPostAggregator) + .errorBoundsStdDev(2) + .build(); JSONObject fieldAccess = getFieldAccessJSON(); @@ -108,8 +113,11 @@ public void testAllFieldsWithThetaSketchSetOp() throws JsonProcessingException, .build(); ThetaSketchEstimatePostAggregator thetaSketchEstimatePostAggregator = - new ThetaSketchEstimatePostAggregator("estimate_stars", thetaSketchSetOpPostAggregator); - + ThetaSketchEstimatePostAggregator.builder() + .name("estimate_stars") + .field(thetaSketchSetOpPostAggregator) + .errorBoundsStdDev(2) + .build(); JSONObject fieldAccess = getFieldAccessJSON(); @@ -124,6 +132,7 @@ public void testAllFieldsWithThetaSketchSetOp() throws JsonProcessingException, JSONObject jsonObject = new JSONObject(); jsonObject.put("type", "thetaSketchEstimate"); jsonObject.put("name", "estimate_stars"); + jsonObject.put("errorBoundsStdDev", 2); jsonObject.put("field", thetaSketchSetOp); String actualJSON = objectMapper.writeValueAsString(thetaSketchEstimatePostAggregator); @@ -135,14 +144,18 @@ public void testAllFieldsWithThetaSketchSetOp() throws JsonProcessingException, public void testNullName() { ThetaSketchEstimatePostAggregator thetaSketchEstimatePostAggregator = - new ThetaSketchEstimatePostAggregator(null, new FieldAccessPostAggregator("stars")); + ThetaSketchEstimatePostAggregator.builder() + .field(new FieldAccessPostAggregator("stars")) + .build(); } @Test(expectedExceptions = NullPointerException.class) public void testNullField() { ThetaSketchEstimatePostAggregator thetaSketchEstimatePostAggregator = - new ThetaSketchEstimatePostAggregator("estimate_stars", null); + ThetaSketchEstimatePostAggregator.builder() + .name("estimate_stars") + .build(); } } From a6688ccc54590527a1104bb54423a978c9acc0c7 Mon Sep 17 00:00:00 2001 From: Abhi Sapariya Date: Sun, 23 Jun 2019 00:03:50 +0530 Subject: [PATCH 08/20] two constructor rather than a builder because builder would be breaking change --- .../ThetaSketchEstimatePostAggregator.java | 14 ++++++---- ...ThetaSketchEstimatePostAggregatorTest.java | 28 ++++++------------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java index 46871488..c20cc949 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java @@ -19,7 +19,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; -import lombok.Builder; import lombok.Getter; import lombok.NonNull; @@ -31,14 +30,17 @@ public class ThetaSketchEstimatePostAggregator extends DruidPostAggregator { private DruidPostAggregator field; private Integer errorBoundsStdDev; - @Builder - public ThetaSketchEstimatePostAggregator( - @NonNull String name, - @NonNull DruidPostAggregator field, - Integer errorBoundsStdDev) { + public ThetaSketchEstimatePostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field) { this.type = THETA_SKETCH_ESTIMATE_POST_AGGREGATOR_TYPE; this.name = name; this.field = field; + } + + public ThetaSketchEstimatePostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field, + Integer errorBoundsStdDev) { + this(name, field); this.errorBoundsStdDev = errorBoundsStdDev; } diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregatorTest.java index 859f4bd1..e7de5ef4 100644 --- a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregatorTest.java +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregatorTest.java @@ -55,10 +55,8 @@ public void testRequiredFieldsWithFieldAccess() throws JsonProcessingException, new FieldAccessPostAggregator("stars"); ThetaSketchEstimatePostAggregator thetaSketchEstimatePostAggregator = - ThetaSketchEstimatePostAggregator.builder() - .name("estimate_stars") - .field(fieldAccessPostAggregator) - .build(); + new ThetaSketchEstimatePostAggregator("estimate_stars", fieldAccessPostAggregator); + JSONObject fieldAccess = getFieldAccessJSON(); @@ -80,11 +78,8 @@ public void testAllFieldsWithFieldAccess() throws JsonProcessingException, JSONE new FieldAccessPostAggregator("stars"); ThetaSketchEstimatePostAggregator thetaSketchEstimatePostAggregator = - ThetaSketchEstimatePostAggregator.builder() - .name("estimate_stars") - .field(fieldAccessPostAggregator) - .errorBoundsStdDev(2) - .build(); + new ThetaSketchEstimatePostAggregator("estimate_stars", fieldAccessPostAggregator, 2); + JSONObject fieldAccess = getFieldAccessJSON(); @@ -113,11 +108,8 @@ public void testAllFieldsWithThetaSketchSetOp() throws JsonProcessingException, .build(); ThetaSketchEstimatePostAggregator thetaSketchEstimatePostAggregator = - ThetaSketchEstimatePostAggregator.builder() - .name("estimate_stars") - .field(thetaSketchSetOpPostAggregator) - .errorBoundsStdDev(2) - .build(); + new ThetaSketchEstimatePostAggregator("estimate_stars", thetaSketchSetOpPostAggregator, 2); + JSONObject fieldAccess = getFieldAccessJSON(); @@ -144,18 +136,14 @@ public void testAllFieldsWithThetaSketchSetOp() throws JsonProcessingException, public void testNullName() { ThetaSketchEstimatePostAggregator thetaSketchEstimatePostAggregator = - ThetaSketchEstimatePostAggregator.builder() - .field(new FieldAccessPostAggregator("stars")) - .build(); + new ThetaSketchEstimatePostAggregator(null, new FieldAccessPostAggregator("stars")); } @Test(expectedExceptions = NullPointerException.class) public void testNullField() { ThetaSketchEstimatePostAggregator thetaSketchEstimatePostAggregator = - ThetaSketchEstimatePostAggregator.builder() - .name("estimate_stars") - .build(); + new ThetaSketchEstimatePostAggregator("estimate_stars", null); } } From 2b660a7a473c87fcb5d5121588d047cb8377ee17 Mon Sep 17 00:00:00 2001 From: Abhi Sapariya Date: Thu, 1 Aug 2019 22:16:49 +0530 Subject: [PATCH 09/20] Quantiles and Tuple Sketches Implementation --- .../aggregator/QuantilesSketchAggregator.java | 35 +++++++++++ .../aggregator/TupleSketchAggregator.java | 59 +++++++++++++++++++ ...ntilesSketchToHistogramPostAggregator.java | 28 +++++++++ ...antilesSketchToQuantilePostAggregator.java | 28 +++++++++ ...ntilesSketchToQuantilesPostAggregator.java | 28 +++++++++ ...QuantilesSketchToStringPostAggregator.java | 25 ++++++++ .../postAggregator/TupleSketchOperation.java | 22 +++++++ .../TupleSketchSetOpPostAggregator.java | 43 ++++++++++++++ .../TupleSketchTTestPostAggregator.java | 27 +++++++++ ...etchToEstimateAndBoundsPostAggregator.java | 28 +++++++++ .../TupleSketchToEstimatePostAggregator.java | 41 +++++++++++++ .../TupleSketchToMeansPostAggregator.java | 25 ++++++++ ...TupleSketchToNumEntriesPostAggregator.java | 25 ++++++++ ...SketchToQuantilesSketchPostAggregator.java | 31 ++++++++++ .../TupleSketchToStringPostAggregator.java | 25 ++++++++ .../TupleSketchToVariancesPostAggregator.java | 25 ++++++++ 16 files changed, 495 insertions(+) create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TupleSketchAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchOperation.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregator.java new file mode 100644 index 00000000..f87d38db --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregator.java @@ -0,0 +1,35 @@ +package in.zapr.druid.druidry.extensions.datasketches.aggregator; + +import com.google.common.base.Preconditions; +import com.google.common.math.LongMath; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.aggregator.DruidAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class QuantilesSketchAggregator extends DruidAggregator { + + private static final String QUANTILES_SKETCH_TYPE_AGGREGATOR = "quantilesDoublesSketch"; + private String fieldName; + private Integer k; + + @Builder + private QuantilesSketchAggregator(@NonNull String name, + @NonNull String fieldName, + Integer k) { + this.type = QUANTILES_SKETCH_TYPE_AGGREGATOR; + this.name = name; + this.fieldName = fieldName; + this.k = k; + + if (k != null) { + Preconditions.checkArgument(LongMath.isPowerOfTwo(k), "k must be a power of 2"); + } + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TupleSketchAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TupleSketchAggregator.java new file mode 100644 index 00000000..b7ebfb85 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TupleSketchAggregator.java @@ -0,0 +1,59 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.aggregator; + +import com.google.common.base.Preconditions; +import com.google.common.math.LongMath; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; + +import in.zapr.druid.druidry.aggregator.DruidAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TupleSketchAggregator extends DruidAggregator { + + private static final String TUPLE_SKETCH_TYPE_AGGREGATOR = "arrayOfDoublesSketch"; + private String fieldName; + private Integer nominalEntries; + private Integer numberOfValues; + private List metricColumns; + + @Builder + private TupleSketchAggregator(@NonNull String name, + @NonNull String fieldName, + Integer nominalEntries, + Integer numberOfValues, + List metricColumns) { + this.type = TUPLE_SKETCH_TYPE_AGGREGATOR; + this.name = name; + this.fieldName = fieldName; + this.nominalEntries = nominalEntries; + this.numberOfValues = numberOfValues; + this.metricColumns = metricColumns; + + if (nominalEntries != null) { + Preconditions.checkArgument(LongMath.isPowerOfTwo(nominalEntries), "nominalEntries must be a power of 2"); + } + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java new file mode 100644 index 00000000..bc93a262 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java @@ -0,0 +1,28 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class QuantilesSketchToHistogramPostAggregator extends DruidPostAggregator { + + private static final String QUANTILES_SKETCH_TO_HISTOGRAM_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToHistogram"; + private DruidPostAggregator field; + private double[] splitPoints; + + @Builder + private QuantilesSketchToHistogramPostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field, + @NonNull double[] splitPoints) { + this.type = QUANTILES_SKETCH_TO_HISTOGRAM_POST_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + this.splitPoints = splitPoints; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java new file mode 100644 index 00000000..1f3674cd --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java @@ -0,0 +1,28 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class QuantilesSketchToQuantilePostAggregator extends DruidPostAggregator { + + private static final String QUANTILES_SKETCH_TO_QUANTILE_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToQuantile"; + private DruidPostAggregator field; + private double fraction; + + @Builder + private QuantilesSketchToQuantilePostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field, + @NonNull double fraction) { + this.type = QUANTILES_SKETCH_TO_QUANTILE_POST_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + this.fraction = fraction; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java new file mode 100644 index 00000000..dfcde239 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java @@ -0,0 +1,28 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class QuantilesSketchToQuantilesPostAggregator extends DruidPostAggregator { + + private static final String QUANTILES_SKETCH_TO_QUANTILES_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToQuantiles"; + private DruidPostAggregator field; + private double[] fractions; + + @Builder + private QuantilesSketchToQuantilesPostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field, + @NonNull double[] fractions) { + this.type = QUANTILES_SKETCH_TO_QUANTILES_POST_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + this.fractions = fractions; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java new file mode 100644 index 00000000..c64e90d1 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java @@ -0,0 +1,25 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class QuantilesSketchToStringPostAggregator extends DruidPostAggregator { + + private static final String QUANTILES_SKETCH_TO_STRING_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToString"; + private DruidPostAggregator field; + + @Builder + private QuantilesSketchToStringPostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field) { + this.type = QUANTILES_SKETCH_TO_STRING_POST_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchOperation.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchOperation.java new file mode 100644 index 00000000..bf5e9623 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchOperation.java @@ -0,0 +1,22 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TupleSketchOperation { + + INTERSECT("INTERSECT"), + UNION("UNION"), + NOT("NOT"); + + private String value; + + TupleSketchOperation(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregator.java new file mode 100644 index 00000000..87af16cd --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregator.java @@ -0,0 +1,43 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.google.common.base.Preconditions; +import com.google.common.math.LongMath; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TupleSketchSetOpPostAggregator extends DruidPostAggregator { + + private static final String TUPLE_SKETCH_SET_OP_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchSetOp"; + private TupleSketchOperation operation; + private List fields; + private Integer nominalEntries; + private Integer numberOfValues; + + @Builder + private TupleSketchSetOpPostAggregator(@NonNull String name, + @NonNull TupleSketchOperation operation, + @NonNull List fields, + Integer nominalEntries, + Integer numberOfValues) { + this.type = TUPLE_SKETCH_SET_OP_POST_AGGREGATOR_TYPE; + this.name = name; + this.operation = operation; + this.fields = fields; + this.nominalEntries = nominalEntries; + this.numberOfValues = numberOfValues; + + if (nominalEntries != null) { + Preconditions.checkArgument(LongMath.isPowerOfTwo(nominalEntries), "nominalEntries must be a power of 2"); + } + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java new file mode 100644 index 00000000..3f7defb1 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java @@ -0,0 +1,27 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TupleSketchTTestPostAggregator extends DruidPostAggregator { + + private static final String TUPLE_SKETCH_TTEST_AGGREGATOR_TYPE = "arrayOfDoublesSketchTTest"; + private List fields; + + @Builder + private TupleSketchTTestPostAggregator(@NonNull String name, + @NonNull List fields) { + this.type = TUPLE_SKETCH_TTEST_AGGREGATOR_TYPE; + this.name = name; + this.fields = fields; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregator.java new file mode 100644 index 00000000..f49c2a16 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregator.java @@ -0,0 +1,28 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TupleSketchToEstimateAndBoundsPostAggregator extends DruidPostAggregator { + + private static final String TUPLE_SKETCH_TO_ESTIMATE_AND_BOUNDS_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToEstimateAndBounds"; + private DruidPostAggregator field; + private Integer numStdDevs; + + @Builder + private TupleSketchToEstimateAndBoundsPostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field, + Integer numStdDevs) { + this.type = TUPLE_SKETCH_TO_ESTIMATE_AND_BOUNDS_POST_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + this.numStdDevs = numStdDevs; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java new file mode 100644 index 00000000..83633381 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java @@ -0,0 +1,41 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TupleSketchToEstimatePostAggregator extends DruidPostAggregator { + + private static final String TUPLE_SKETCH_TO_ESTIMATE_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToEstimate"; + private DruidPostAggregator field; + + @Builder + private TupleSketchToEstimatePostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field) { + this.type = TUPLE_SKETCH_TO_ESTIMATE_POST_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java new file mode 100644 index 00000000..428d9ca5 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java @@ -0,0 +1,25 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TupleSketchToMeansPostAggregator extends DruidPostAggregator { + + private static final String TUPLE_SKETCH_TO_MEANS_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToMeans"; + private DruidPostAggregator field; + + @Builder + private TupleSketchToMeansPostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field) { + this.type = TUPLE_SKETCH_TO_MEANS_POST_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java new file mode 100644 index 00000000..b29c13fb --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java @@ -0,0 +1,25 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TupleSketchToNumEntriesPostAggregator extends DruidPostAggregator { + + private static final String TUPLE_SKETCH_TO_NUM_ENTRIES_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToNumEntries"; + private DruidPostAggregator field; + + @Builder + private TupleSketchToNumEntriesPostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field) { + this.type = TUPLE_SKETCH_TO_NUM_ENTRIES_POST_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregator.java new file mode 100644 index 00000000..20f6cd62 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregator.java @@ -0,0 +1,31 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TupleSketchToQuantilesSketchPostAggregator extends DruidPostAggregator { + + private static final String TUPLE_SKETCH_TO_QUANTILES_SKETCH_AGGREGATOR_TYPE = "arrayOfDoublesSketchToQuantilesSketch"; + private DruidPostAggregator field; + private Integer column; + private Integer k; + + @Builder + private TupleSketchToQuantilesSketchPostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field, + Integer column, + Integer k) { + this.type = TUPLE_SKETCH_TO_QUANTILES_SKETCH_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + this.column = column; + this.k = k; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java new file mode 100644 index 00000000..7d43bf2e --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java @@ -0,0 +1,25 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TupleSketchToStringPostAggregator extends DruidPostAggregator { + + private static final String TUPLE_SKETCH_TO_STRING_AGGREGATOR_TYPE = "arrayOfDoublesSketchTTest"; + private DruidPostAggregator field; + + @Builder + private TupleSketchToStringPostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field) { + this.type = TUPLE_SKETCH_TO_STRING_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java new file mode 100644 index 00000000..6a400942 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java @@ -0,0 +1,25 @@ +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TupleSketchToVariancesPostAggregator extends DruidPostAggregator { + + private static final String TUPLE_SKETCH_TO_VARIANCES_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToVariances"; + private DruidPostAggregator field; + + @Builder + private TupleSketchToVariancesPostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field) { + this.type = TUPLE_SKETCH_TO_VARIANCES_POST_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + } + +} From 4dae1d4aafec2a31abfce8be7fc941d6be5b1282 Mon Sep 17 00:00:00 2001 From: siddharthsa Date: Fri, 2 Aug 2019 14:20:14 +0530 Subject: [PATCH 10/20] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf7f7698..9c7bcfad 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ UTF-8 - 2.9.8 + 2.9.9.2 2.9.7 1.16.14 6.11 From 2dd68e8dad3ad972a4765544348fe2131fdd35df Mon Sep 17 00:00:00 2001 From: Abhi Sapariya Date: Sat, 3 Aug 2019 18:10:45 +0530 Subject: [PATCH 11/20] HLL sketch implementation & copyright licenses in all files --- .../aggregator/HllSketchBuildAggregator.java | 49 +++++++++++++++++ .../aggregator/HllSketchMergeAggregator.java | 50 ++++++++++++++++++ .../aggregator/QuantilesSketchAggregator.java | 16 ++++++ .../aggregator/TargetHllType.java | 38 ++++++++++++++ ...ketchEstimateWithBoundsPostAggregator.java | 44 ++++++++++++++++ .../HllSketchToStringPostAggregator.java | 41 +++++++++++++++ .../HllSketchUnionPostAggregator.java | 52 +++++++++++++++++++ ...ntilesSketchToHistogramPostAggregator.java | 16 ++++++ ...antilesSketchToQuantilePostAggregator.java | 16 ++++++ ...ntilesSketchToQuantilesPostAggregator.java | 16 ++++++ ...QuantilesSketchToStringPostAggregator.java | 16 ++++++ .../postAggregator/TupleSketchOperation.java | 16 ++++++ .../TupleSketchSetOpPostAggregator.java | 16 ++++++ .../TupleSketchTTestPostAggregator.java | 16 ++++++ ...etchToEstimateAndBoundsPostAggregator.java | 20 ++++++- .../TupleSketchToEstimatePostAggregator.java | 2 +- .../TupleSketchToMeansPostAggregator.java | 16 ++++++ ...TupleSketchToNumEntriesPostAggregator.java | 18 ++++++- ...SketchToQuantilesSketchPostAggregator.java | 18 ++++++- .../TupleSketchToStringPostAggregator.java | 16 ++++++ .../TupleSketchToVariancesPostAggregator.java | 16 ++++++ 21 files changed, 503 insertions(+), 5 deletions(-) create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchBuildAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchMergeAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TargetHllType.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregator.java create mode 100644 src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregator.java diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchBuildAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchBuildAggregator.java new file mode 100644 index 00000000..0224da81 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchBuildAggregator.java @@ -0,0 +1,49 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.aggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import in.zapr.druid.druidry.aggregator.DruidAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class HllSketchBuildAggregator extends DruidAggregator { + + private static final String HLL_SKETCH_BUILD_TYPE_AGGREGATOR = "HLLSketchBuild"; + private String fieldName; + private Integer lgK; + @JsonProperty("tgtHllType") + private TargetHllType targetHllType; + + @Builder + private HllSketchBuildAggregator(@NonNull String name, + @NonNull String fieldName, + Integer lgK, + TargetHllType targetHllType) { + this.type = HLL_SKETCH_BUILD_TYPE_AGGREGATOR; + this.name = name; + this.fieldName = fieldName; + this.lgK = lgK; + this.targetHllType = targetHllType; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchMergeAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchMergeAggregator.java new file mode 100644 index 00000000..8dee28ee --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchMergeAggregator.java @@ -0,0 +1,50 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.aggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import in.zapr.druid.druidry.aggregator.DruidAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class HllSketchMergeAggregator extends DruidAggregator { + + private static final String HLL_SKETCH_MERGE_TYPE_AGGREGATOR = "HLLSketchMerge"; + + private String fieldName; + private Integer lgK; + @JsonProperty("tgtHllType") + private TargetHllType targetHllType; + + @Builder + private HllSketchMergeAggregator(@NonNull String name, + @NonNull String fieldName, + Integer lgK, + TargetHllType targetHllType) { + this.type = HLL_SKETCH_MERGE_TYPE_AGGREGATOR; + this.name = name; + this.fieldName = fieldName; + this.lgK = lgK; + this.targetHllType = targetHllType; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregator.java index f87d38db..58bd39d4 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.aggregator; import com.google.common.base.Preconditions; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TargetHllType.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TargetHllType.java new file mode 100644 index 00000000..6345d285 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TargetHllType.java @@ -0,0 +1,38 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.aggregator; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TargetHllType { + + HLL_4("HLL_4"), + HLL_6("HLL_6"), + HLL_8("HLL_8"); + + private String value; + + TargetHllType(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregator.java new file mode 100644 index 00000000..0b815cc9 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregator.java @@ -0,0 +1,44 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class HllSketchEstimateWithBoundsPostAggregator extends DruidPostAggregator { + + private static final String HLL_SKETCH_ESTIMATE_WITH_BOUNDS_POST_AGGREGATOR_TYPE = "HLLSketchEstimateWithBounds"; + private DruidPostAggregator field; + private Integer numStdDev; + + @Builder + private HllSketchEstimateWithBoundsPostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field, + Integer numStdDev) { + this.type = HLL_SKETCH_ESTIMATE_WITH_BOUNDS_POST_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + this.numStdDev = numStdDev; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregator.java new file mode 100644 index 00000000..ebf3a12b --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregator.java @@ -0,0 +1,41 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class HllSketchToStringPostAggregator extends DruidPostAggregator { + + private static final String HLL_SKETCH_TO_STRING_POST_AGGREGATOR_TYPE = "HLLSketchToString"; + private DruidPostAggregator field; + + @Builder + private HllSketchToStringPostAggregator(@NonNull String name, + @NonNull DruidPostAggregator field) { + this.type = HLL_SKETCH_TO_STRING_POST_AGGREGATOR_TYPE; + this.name = name; + this.field = field; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregator.java new file mode 100644 index 00000000..7e1c5204 --- /dev/null +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregator.java @@ -0,0 +1,52 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +import in.zapr.druid.druidry.extensions.datasketches.aggregator.TargetHllType; +import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; + +@Getter +@JsonInclude(JsonInclude.Include.NON_NULL) +public class HllSketchUnionPostAggregator extends DruidPostAggregator { + + private static final String HLL_SKETCH_UNION_POST_AGGREGATOR_TYPE = "HLLSketchUnion"; + private List fields; + private Integer lgK; + @JsonProperty("tgtHllType") + private TargetHllType targetHllType; + + @Builder + private HllSketchUnionPostAggregator(@NonNull String name, + @NonNull List fields, + Integer lgK, + TargetHllType targetHllType) { + this.type = HLL_SKETCH_UNION_POST_AGGREGATOR_TYPE; + this.name = name; + this.fields = fields; + this.lgK = lgK; + this.targetHllType = targetHllType; + } + +} diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java index bc93a262..df32a1a8 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java index 1f3674cd..46f5d59a 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java index dfcde239..3a061614 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java index c64e90d1..f0e044f3 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchOperation.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchOperation.java index bf5e9623..030a0656 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchOperation.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchOperation.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregator.java index 87af16cd..3ba26870 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.google.common.base.Preconditions; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java index 3f7defb1..30149633 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregator.java index f49c2a16..4fe04ad5 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonInclude; @@ -17,8 +33,8 @@ public class TupleSketchToEstimateAndBoundsPostAggregator extends DruidPostAggre @Builder private TupleSketchToEstimateAndBoundsPostAggregator(@NonNull String name, - @NonNull DruidPostAggregator field, - Integer numStdDevs) { + @NonNull DruidPostAggregator field, + Integer numStdDevs) { this.type = TUPLE_SKETCH_TO_ESTIMATE_AND_BOUNDS_POST_AGGREGATOR_TYPE; this.name = name; this.field = field; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java index 83633381..b3518fa2 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java @@ -32,7 +32,7 @@ public class TupleSketchToEstimatePostAggregator extends DruidPostAggregator { @Builder private TupleSketchToEstimatePostAggregator(@NonNull String name, - @NonNull DruidPostAggregator field) { + @NonNull DruidPostAggregator field) { this.type = TUPLE_SKETCH_TO_ESTIMATE_POST_AGGREGATOR_TYPE; this.name = name; this.field = field; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java index 428d9ca5..a43cdea6 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java index b29c13fb..d7e7e523 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonInclude; @@ -16,7 +32,7 @@ public class TupleSketchToNumEntriesPostAggregator extends DruidPostAggregator { @Builder private TupleSketchToNumEntriesPostAggregator(@NonNull String name, - @NonNull DruidPostAggregator field) { + @NonNull DruidPostAggregator field) { this.type = TUPLE_SKETCH_TO_NUM_ENTRIES_POST_AGGREGATOR_TYPE; this.name = name; this.field = field; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregator.java index 20f6cd62..9c116f79 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonInclude; @@ -27,5 +43,5 @@ private TupleSketchToQuantilesSketchPostAggregator(@NonNull String name, this.column = column; this.k = k; } - + } diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java index 7d43bf2e..179b191c 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java index 6a400942..bb8d8cd9 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import com.fasterxml.jackson.annotation.JsonInclude; From 3691f0c416e12e07b3c14ab8838d9fe02abc94e3 Mon Sep 17 00:00:00 2001 From: Abhi Sapariya Date: Sat, 3 Aug 2019 18:34:46 +0530 Subject: [PATCH 12/20] readme update for data sketches --- README.md | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d23376af..80617990 100644 --- a/README.md +++ b/README.md @@ -204,9 +204,14 @@ Supported Features * LongSum * LongFirst * LongLast -* ThetaSketch * DistinctCount * Histogram +* [Data Sketches](https://druid.apache.org/docs/latest/development/extensions-core/datasketches-extension.html) + * ThetaSketch (thetaSketch) + * TupleSketch (arrayOfDoublesSketch) + * QuantilesSketch (quantilesDoublesSketch) + * HllSketchBuild (HLLSketchBuild) + * HllSketchMerge (HLLSketchMerge) #### Filters @@ -227,8 +232,29 @@ Supported Features * FieldAccess * HyperUniqueCardinality * Javascript -* ThetaSketchEstimate -* ThetaSketchSetOp +* [Data Sketches](https://druid.apache.org/docs/latest/development/extensions-core/datasketches-extension.html) + * [Theta Sketch](https://druid.apache.org/docs/latest/development/extensions-core/datasketches-theta.html) + * ThetaSketchEstimate (thetaSketchEstimate) + * ThetaSketchSetOp (thetaSketchSetOp) + * [Tuple Sketch](https://druid.apache.org/docs/latest/development/extensions-core/datasketches-tuple.html) + * TupleSketchToEstimate (arrayOfDoublesSketchToEstimate) + * TupleSketchToEstimateAndBounds(arrayOfDoublesSketchToEstimateAndBounds) + * TupleSketchToNumEntries (arrayOfDoublesSketchToNumEntries) + * TupleSketchToMeans (arrayOfDoublesSketchToMeans) + * TupleSketchToVariances (arrayOfDoublesSketchToVariances) + * TupleSketchToQuantilesSketch (arrayOfDoublesSketchToQuantilesSketch) + * TupleSketchSetOp (arrayOfDoublesSketchSetOp) + * TupleSketchTTest (arrayOfDoublesSketchTTest) + * TupleSketchToString (arrayOfDoublesSketchToString) + * [Quantiles Sketch](https://druid.apache.org/docs/latest/development/extensions-core/datasketches-quantiles.html) + * QuantilesSketchToQuantile (quantilesDoublesSketchToQuantile) + * QuantilesSketchToQuantiles (quantilesDoublesSketchToQuantiles) + * QuantilesSketchToHistogram (quantilesDoublesSketchToHistogram) + * QuantilesSketchToString (quantilesDoublesSketchToString) + * [HLL Sketch](https://druid.apache.org/docs/latest/development/extensions-core/datasketches-hll.html) + * HllSketchEstimateWithBounds (HLLSketchEstimateWithBounds) + * HllSketchUnion (HLLSketchUnion) + * HllSketchToString (HLLSketchToString) #### Granularity * Duration From b32815e40faa9a89f837e126dc6cb33b6118c9ed Mon Sep 17 00:00:00 2001 From: Abhi Sapariya Date: Sun, 4 Aug 2019 01:02:36 +0530 Subject: [PATCH 13/20] refactoring --- .../QuantilesSketchToHistogramPostAggregator.java | 6 ++++-- .../QuantilesSketchToQuantilePostAggregator.java | 4 ++-- .../QuantilesSketchToQuantilesPostAggregator.java | 6 ++++-- .../postAggregator/TupleSketchToStringPostAggregator.java | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java index df32a1a8..39d66345 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java @@ -18,6 +18,8 @@ import com.fasterxml.jackson.annotation.JsonInclude; +import java.util.List; + import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; import lombok.Getter; @@ -29,12 +31,12 @@ public class QuantilesSketchToHistogramPostAggregator extends DruidPostAggregato private static final String QUANTILES_SKETCH_TO_HISTOGRAM_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToHistogram"; private DruidPostAggregator field; - private double[] splitPoints; + private List splitPoints; @Builder private QuantilesSketchToHistogramPostAggregator(@NonNull String name, @NonNull DruidPostAggregator field, - @NonNull double[] splitPoints) { + @NonNull List splitPoints) { this.type = QUANTILES_SKETCH_TO_HISTOGRAM_POST_AGGREGATOR_TYPE; this.name = name; this.field = field; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java index 46f5d59a..cd8064e0 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java @@ -29,12 +29,12 @@ public class QuantilesSketchToQuantilePostAggregator extends DruidPostAggregator private static final String QUANTILES_SKETCH_TO_QUANTILE_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToQuantile"; private DruidPostAggregator field; - private double fraction; + private Double fraction; @Builder private QuantilesSketchToQuantilePostAggregator(@NonNull String name, @NonNull DruidPostAggregator field, - @NonNull double fraction) { + @NonNull Double fraction) { this.type = QUANTILES_SKETCH_TO_QUANTILE_POST_AGGREGATOR_TYPE; this.name = name; this.field = field; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java index 3a061614..bf11584b 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java @@ -18,6 +18,8 @@ import com.fasterxml.jackson.annotation.JsonInclude; +import java.util.List; + import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; import lombok.Getter; @@ -29,12 +31,12 @@ public class QuantilesSketchToQuantilesPostAggregator extends DruidPostAggregato private static final String QUANTILES_SKETCH_TO_QUANTILES_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToQuantiles"; private DruidPostAggregator field; - private double[] fractions; + private List fractions; @Builder private QuantilesSketchToQuantilesPostAggregator(@NonNull String name, @NonNull DruidPostAggregator field, - @NonNull double[] fractions) { + @NonNull List fractions) { this.type = QUANTILES_SKETCH_TO_QUANTILES_POST_AGGREGATOR_TYPE; this.name = name; this.field = field; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java index 179b191c..c67021c2 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java @@ -27,7 +27,7 @@ @JsonInclude(JsonInclude.Include.NON_NULL) public class TupleSketchToStringPostAggregator extends DruidPostAggregator { - private static final String TUPLE_SKETCH_TO_STRING_AGGREGATOR_TYPE = "arrayOfDoublesSketchTTest"; + private static final String TUPLE_SKETCH_TO_STRING_AGGREGATOR_TYPE = "arrayOfDoublesSketchToString"; private DruidPostAggregator field; @Builder From 1637e5de8210bc2201428c7c007c2d24bdef64ac Mon Sep 17 00:00:00 2001 From: Abhi Sapariya Date: Sun, 4 Aug 2019 01:07:24 +0530 Subject: [PATCH 14/20] refactoring README --- README.md | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 80617990..a7862677 100644 --- a/README.md +++ b/README.md @@ -207,11 +207,11 @@ Supported Features * DistinctCount * Histogram * [Data Sketches](https://druid.apache.org/docs/latest/development/extensions-core/datasketches-extension.html) - * ThetaSketch (thetaSketch) - * TupleSketch (arrayOfDoublesSketch) - * QuantilesSketch (quantilesDoublesSketch) - * HllSketchBuild (HLLSketchBuild) - * HllSketchMerge (HLLSketchMerge) + * ThetaSketch + * TupleSketch + * QuantilesSketch + * HllSketchBuild + * HllSketchMerge #### Filters @@ -234,27 +234,27 @@ Supported Features * Javascript * [Data Sketches](https://druid.apache.org/docs/latest/development/extensions-core/datasketches-extension.html) * [Theta Sketch](https://druid.apache.org/docs/latest/development/extensions-core/datasketches-theta.html) - * ThetaSketchEstimate (thetaSketchEstimate) - * ThetaSketchSetOp (thetaSketchSetOp) + * ThetaSketchEstimate + * ThetaSketchSetOp * [Tuple Sketch](https://druid.apache.org/docs/latest/development/extensions-core/datasketches-tuple.html) - * TupleSketchToEstimate (arrayOfDoublesSketchToEstimate) - * TupleSketchToEstimateAndBounds(arrayOfDoublesSketchToEstimateAndBounds) - * TupleSketchToNumEntries (arrayOfDoublesSketchToNumEntries) - * TupleSketchToMeans (arrayOfDoublesSketchToMeans) - * TupleSketchToVariances (arrayOfDoublesSketchToVariances) - * TupleSketchToQuantilesSketch (arrayOfDoublesSketchToQuantilesSketch) - * TupleSketchSetOp (arrayOfDoublesSketchSetOp) - * TupleSketchTTest (arrayOfDoublesSketchTTest) - * TupleSketchToString (arrayOfDoublesSketchToString) + * TupleSketchToEstimate + * TupleSketchToEstimateAndBounds + * TupleSketchToNumEntries + * TupleSketchToMeans + * TupleSketchToVariances + * TupleSketchToQuantilesSketch + * TupleSketchSetOp + * TupleSketchTTest + * TupleSketchToString * [Quantiles Sketch](https://druid.apache.org/docs/latest/development/extensions-core/datasketches-quantiles.html) - * QuantilesSketchToQuantile (quantilesDoublesSketchToQuantile) - * QuantilesSketchToQuantiles (quantilesDoublesSketchToQuantiles) - * QuantilesSketchToHistogram (quantilesDoublesSketchToHistogram) - * QuantilesSketchToString (quantilesDoublesSketchToString) + * QuantilesSketchToQuantile + * QuantilesSketchToQuantiles + * QuantilesSketchToHistogram + * QuantilesSketchToString * [HLL Sketch](https://druid.apache.org/docs/latest/development/extensions-core/datasketches-hll.html) - * HllSketchEstimateWithBounds (HLLSketchEstimateWithBounds) - * HllSketchUnion (HLLSketchUnion) - * HllSketchToString (HLLSketchToString) + * HllSketchEstimateWithBounds + * HllSketchUnion + * HllSketchToString #### Granularity * Duration From debbd9201f3982a29562e095f25c3fde20fcd993 Mon Sep 17 00:00:00 2001 From: Abhi Sapariya Date: Sun, 4 Aug 2019 01:09:33 +0530 Subject: [PATCH 15/20] datasketches test cases --- .../HllSketchBuildAggregatorTest.java | 97 +++++++++++ .../HllSketchMergeAggregatorTest.java | 97 +++++++++++ .../QuantilesSketchAggregatorTest.java | 105 ++++++++++++ .../aggregator/TupleSketchAggregatorTest.java | 111 +++++++++++++ ...hEstimateWithBoundsPostAggregatorTest.java | 112 +++++++++++++ .../HllSketchToStringPostAggregatorTest.java | 93 +++++++++++ .../HllSketchUnionPostAggregatorTest.java | 130 +++++++++++++++ ...esSketchToHistogramPostAggregatorTest.java | 112 +++++++++++++ ...lesSketchToQuantilePostAggregatorTest.java | 107 +++++++++++++ ...esSketchToQuantilesPostAggregatorTest.java | 112 +++++++++++++ ...tilesSketchToStringPostAggregatorTest.java | 93 +++++++++++ .../TupleSketchSetOpPostAggregatorTest.java | 150 ++++++++++++++++++ .../TupleSketchTTestPostAggregatorTest.java | 103 ++++++++++++ ...ToEstimateAndBoundsPostAggregatorTest.java | 112 +++++++++++++ ...pleSketchToEstimatePostAggregatorTest.java | 93 +++++++++++ .../TupleSketchToMeansPostAggregatorTest.java | 93 +++++++++++ ...eSketchToNumEntriesPostAggregatorTest.java | 93 +++++++++++ ...chToQuantilesSketchPostAggregatorTest.java | 114 +++++++++++++ ...TupleSketchToStringPostAggregatorTest.java | 93 +++++++++++ ...leSketchToVariancesPostAggregatorTest.java | 93 +++++++++++ 20 files changed, 2113 insertions(+) create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchBuildAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchMergeAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TupleSketchAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregatorTest.java create mode 100644 src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregatorTest.java diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchBuildAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchBuildAggregatorTest.java new file mode 100644 index 00000000..9afbaf74 --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchBuildAggregatorTest.java @@ -0,0 +1,97 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.aggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class HllSketchBuildAggregatorTest { + + private static ObjectMapper objectMapper; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + } + + private JSONObject getHllSketchBuildAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "HLLSketchBuild"); + jsonObject.put("name", "stars_hll"); + return jsonObject; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + HllSketchBuildAggregator hllSketchBuildAggregator = HllSketchBuildAggregator.builder() + .name("stars_hll") + .fieldName("stars") + .lgK(4) + .targetHllType(TargetHllType.HLL_4) + .build(); + + JSONObject jsonObject = getHllSketchBuildAggregatorJSON(); + jsonObject.put("fieldName", "stars"); + jsonObject.put("lgK", 4); + jsonObject.put("tgtHllType", "HLL_4"); + + String actualJSON = objectMapper.writeValueAsString(hllSketchBuildAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test + public void testRequiredFields() throws JsonProcessingException, JSONException { + + HllSketchBuildAggregator hllSketchBuildAggregator = HllSketchBuildAggregator.builder() + .name("stars_hll") + .fieldName("stars") + .build(); + + JSONObject jsonObject = getHllSketchBuildAggregatorJSON(); + jsonObject.put("fieldName", "stars"); + + String actualJSON = objectMapper.writeValueAsString(hllSketchBuildAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + HllSketchBuildAggregator hllSketchBuildAggregator = HllSketchBuildAggregator.builder() + .fieldName("stars") + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullFieldName() { + + HllSketchBuildAggregator hllSketchBuildAggregator = HllSketchBuildAggregator.builder() + .name("stars_hll") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchMergeAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchMergeAggregatorTest.java new file mode 100644 index 00000000..5aa74235 --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchMergeAggregatorTest.java @@ -0,0 +1,97 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.aggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class HllSketchMergeAggregatorTest { + + private static ObjectMapper objectMapper; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + } + + private JSONObject getHllSketchMergeAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "HLLSketchMerge"); + jsonObject.put("name", "stars_hll"); + return jsonObject; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + HllSketchMergeAggregator hllSketchMergeAggregator = HllSketchMergeAggregator.builder() + .name("stars_hll") + .fieldName("stars") + .lgK(4) + .targetHllType(TargetHllType.HLL_4) + .build(); + + JSONObject jsonObject = getHllSketchMergeAggregatorJSON(); + jsonObject.put("fieldName", "stars"); + jsonObject.put("lgK", 4); + jsonObject.put("tgtHllType", "HLL_4"); + + String actualJSON = objectMapper.writeValueAsString(hllSketchMergeAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test + public void testRequiredFields() throws JsonProcessingException, JSONException { + + HllSketchMergeAggregator hllSketchMergeAggregator = HllSketchMergeAggregator.builder() + .name("stars_hll") + .fieldName("stars") + .build(); + + JSONObject jsonObject = getHllSketchMergeAggregatorJSON(); + jsonObject.put("fieldName", "stars"); + + String actualJSON = objectMapper.writeValueAsString(hllSketchMergeAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + HllSketchMergeAggregator hllSketchMergeAggregator = HllSketchMergeAggregator.builder() + .fieldName("stars") + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullFieldName() { + + HllSketchMergeAggregator hllSketchMergeAggregator = HllSketchMergeAggregator.builder() + .name("stars_hll") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregatorTest.java new file mode 100644 index 00000000..82cc71e2 --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregatorTest.java @@ -0,0 +1,105 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.aggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class QuantilesSketchAggregatorTest { + + private static ObjectMapper objectMapper; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + } + + private JSONObject getQuantilesSketchAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "quantilesDoublesSketch"); + jsonObject.put("name", "star_age_quantiles_sketch"); + return jsonObject; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + QuantilesSketchAggregator quantilesSketchAggregator = QuantilesSketchAggregator.builder() + .name("star_age_quantiles_sketch") + .fieldName("star_age") + .k(1024) + .build(); + + JSONObject jsonObject = getQuantilesSketchAggregatorJSON(); + jsonObject.put("fieldName", "star_age"); + jsonObject.put("k", 1024); + + String actualJSON = objectMapper.writeValueAsString(quantilesSketchAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test + public void testRequiredFields() throws JsonProcessingException, JSONException { + + QuantilesSketchAggregator quantilesSketchAggregator = QuantilesSketchAggregator.builder() + .name("star_age_quantiles_sketch") + .fieldName("star_age") + .build(); + + JSONObject jsonObject = getQuantilesSketchAggregatorJSON(); + jsonObject.put("fieldName", "star_age"); + + String actualJSON = objectMapper.writeValueAsString(quantilesSketchAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void preconditionCheck() { + + QuantilesSketchAggregator quantilesSketchAggregator = QuantilesSketchAggregator.builder() + .name("star_age_quantiles_sketch") + .fieldName("star_age") + .k(3) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + QuantilesSketchAggregator quantilesSketchAggregator = QuantilesSketchAggregator.builder() + .fieldName("star_age") + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullFieldName() { + + QuantilesSketchAggregator quantilesSketchAggregator = QuantilesSketchAggregator.builder() + .name("star_age_quantiles_sketch") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TupleSketchAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TupleSketchAggregatorTest.java new file mode 100644 index 00000000..09264d63 --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TupleSketchAggregatorTest.java @@ -0,0 +1,111 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.aggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Arrays; + +public class TupleSketchAggregatorTest { + + private static ObjectMapper objectMapper; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + } + + private JSONObject getTupleSketchAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "arrayOfDoublesSketch"); + jsonObject.put("name", "galaxy_tuple_sketch"); + jsonObject.put("fieldName", "galaxy"); + return jsonObject; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + TupleSketchAggregator tupleSketchAggregator = TupleSketchAggregator.builder() + .name("galaxy_tuple_sketch") + .fieldName("galaxy") + .nominalEntries(1024) + .numberOfValues(1) + .metricColumns(Arrays.asList("no_of_stars")) + .build(); + + JSONObject jsonObject = getTupleSketchAggregatorJSON(); + jsonObject.put("nominalEntries", 1024); + jsonObject.put("numberOfValues", 1); + jsonObject.put("metricColumns", new JSONArray(Arrays.asList("no_of_stars"))); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test + public void testRequiredFields() throws JsonProcessingException, JSONException { + + TupleSketchAggregator tupleSketchAggregator = TupleSketchAggregator.builder() + .name("galaxy_tuple_sketch") + .fieldName("galaxy") + .build(); + + JSONObject jsonObject = getTupleSketchAggregatorJSON(); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void preconditionCheck() { + + TupleSketchAggregator tupleSketchAggregator = TupleSketchAggregator.builder() + .name("galaxy_tuple_sketch") + .fieldName("galaxy") + .nominalEntries(3) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + TupleSketchAggregator tupleSketchAggregator = TupleSketchAggregator.builder() + .fieldName("galaxy") + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullFieldName() { + + TupleSketchAggregator tupleSketchAggregator = TupleSketchAggregator.builder() + .name("galaxy_tuple_sketch") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregatorTest.java new file mode 100644 index 00000000..f021e01a --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregatorTest.java @@ -0,0 +1,112 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class HllSketchEstimateWithBoundsPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator starsHll; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + starsHll = new FieldAccessPostAggregator("stars_hll"); + } + + private JSONObject getHllSketchEstimateWithBoundsPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "HLLSketchEstimateWithBounds"); + jsonObject.put("name", "stars_estimate"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + HllSketchEstimateWithBoundsPostAggregator hllSketchEstimateWithBoundsPostAggregator = + HllSketchEstimateWithBoundsPostAggregator.builder() + .name("stars_estimate") + .field(starsHll) + .numStdDev(1) + .build(); + + JSONObject jsonObject = getHllSketchEstimateWithBoundsPostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("stars_hll")); + jsonObject.put("numStdDev", 1); + + String actualJSON = objectMapper.writeValueAsString(hllSketchEstimateWithBoundsPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test + public void testRequiredFields() throws JsonProcessingException, JSONException { + + HllSketchEstimateWithBoundsPostAggregator hllSketchEstimateWithBoundsPostAggregator = + HllSketchEstimateWithBoundsPostAggregator.builder() + .name("stars_estimate") + .field(starsHll) + .build(); + + JSONObject jsonObject = getHllSketchEstimateWithBoundsPostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("stars_hll")); + + String actualJSON = objectMapper.writeValueAsString(hllSketchEstimateWithBoundsPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + HllSketchEstimateWithBoundsPostAggregator hllSketchEstimateWithBoundsPostAggregator = + HllSketchEstimateWithBoundsPostAggregator.builder() + .field(starsHll) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + HllSketchEstimateWithBoundsPostAggregator hllSketchEstimateWithBoundsPostAggregator = + HllSketchEstimateWithBoundsPostAggregator.builder() + .name("stars_estimate") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregatorTest.java new file mode 100644 index 00000000..955995a5 --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregatorTest.java @@ -0,0 +1,93 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class HllSketchToStringPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator starsHll; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + starsHll = new FieldAccessPostAggregator("stars_hll"); + } + + private JSONObject getHllSketchToStringPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "HLLSketchToString"); + jsonObject.put("name", "stars_estimate"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + HllSketchToStringPostAggregator hllSketchToStringPostAggregator = + HllSketchToStringPostAggregator.builder() + .name("stars_estimate") + .field(starsHll) + .build(); + + JSONObject jsonObject = getHllSketchToStringPostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("stars_hll")); + + String actualJSON = objectMapper.writeValueAsString(hllSketchToStringPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + HllSketchToStringPostAggregator hllSketchToStringPostAggregator = + HllSketchToStringPostAggregator.builder() + .field(starsHll) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + HllSketchToStringPostAggregator hllSketchToStringPostAggregator = + HllSketchToStringPostAggregator.builder() + .name("stars_estimate") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregatorTest.java new file mode 100644 index 00000000..6e75f23f --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregatorTest.java @@ -0,0 +1,130 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Arrays; + +import in.zapr.druid.druidry.extensions.datasketches.aggregator.TargetHllType; +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class HllSketchUnionPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator milkyWayStarsHll; + private FieldAccessPostAggregator andromedaStarsHll; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + milkyWayStarsHll = new FieldAccessPostAggregator("milky_way_stars_hll"); + andromedaStarsHll = new FieldAccessPostAggregator("andromeda_stars_hll"); + } + + private JSONObject getHllSketchUnionPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "HLLSketchUnion"); + jsonObject.put("name", "andro_way_hll"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + HllSketchUnionPostAggregator hllSketchUnionPostAggregator = + HllSketchUnionPostAggregator.builder() + .name("andro_way_hll") + .fields(Arrays.asList(milkyWayStarsHll, andromedaStarsHll)) + .lgK(4) + .targetHllType(TargetHllType.HLL_4) + .build(); + + JSONObject jsonObject = getHllSketchUnionPostAggregatorJSON(); + jsonObject.put("fields", new JSONArray( + Arrays.asList( + getFieldAccessPostAggregatorJSON("milky_way_stars_hll"), + getFieldAccessPostAggregatorJSON("andromeda_stars_hll") + )) + ); + jsonObject.put("lgK", 4); + jsonObject.put("tgtHllType", "HLL_4"); + + String actualJSON = objectMapper.writeValueAsString(hllSketchUnionPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test + public void testRequiredFields() throws JsonProcessingException, JSONException { + + HllSketchUnionPostAggregator hllSketchUnionPostAggregator = + HllSketchUnionPostAggregator.builder() + .name("andro_way_hll") + .fields(Arrays.asList(milkyWayStarsHll, andromedaStarsHll)) + .build(); + + JSONObject jsonObject = getHllSketchUnionPostAggregatorJSON(); + jsonObject.put("fields", new JSONArray( + Arrays.asList( + getFieldAccessPostAggregatorJSON("milky_way_stars_hll"), + getFieldAccessPostAggregatorJSON("andromeda_stars_hll") + )) + ); + + String actualJSON = objectMapper.writeValueAsString(hllSketchUnionPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + HllSketchUnionPostAggregator hllSketchUnionPostAggregator = + HllSketchUnionPostAggregator.builder() + .fields(Arrays.asList(milkyWayStarsHll, andromedaStarsHll)) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + HllSketchUnionPostAggregator hllSketchUnionPostAggregator = + HllSketchUnionPostAggregator.builder() + .name("andro_way_hll") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregatorTest.java new file mode 100644 index 00000000..5d1cae21 --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregatorTest.java @@ -0,0 +1,112 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Arrays; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class QuantilesSketchToHistogramPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator starAgeQuantilesSketch; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + starAgeQuantilesSketch = new FieldAccessPostAggregator("star_age_quantiles_sketch"); + } + + private JSONObject getQuantilesSketchToHistogramPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "quantilesDoublesSketchToHistogram"); + jsonObject.put("name", "star_age_histogram"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + QuantilesSketchToHistogramPostAggregator quantilesSketchToHistogramPostAggregator = + QuantilesSketchToHistogramPostAggregator.builder() + .name("star_age_histogram") + .field(starAgeQuantilesSketch) + .splitPoints(Arrays.asList(1.1D, 2.2D)) + .build(); + + JSONObject jsonObject = getQuantilesSketchToHistogramPostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("star_age_quantiles_sketch")); + jsonObject.put("splitPoints", new JSONArray( + Arrays.asList(1.1D, 2.2D) + )); + + String actualJSON = objectMapper.writeValueAsString(quantilesSketchToHistogramPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + QuantilesSketchToHistogramPostAggregator quantilesSketchToHistogramPostAggregator = + QuantilesSketchToHistogramPostAggregator.builder() + .field(starAgeQuantilesSketch) + .splitPoints(Arrays.asList(1.1D, 2.2D)) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + QuantilesSketchToHistogramPostAggregator quantilesSketchToHistogramPostAggregator = + QuantilesSketchToHistogramPostAggregator.builder() + .name("star_age_histogram") + .splitPoints(Arrays.asList(1.1D, 2.2D)) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullSplitPoints() { + + QuantilesSketchToHistogramPostAggregator quantilesSketchToHistogramPostAggregator = + QuantilesSketchToHistogramPostAggregator.builder() + .name("star_age_histogram") + .field(starAgeQuantilesSketch) + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregatorTest.java new file mode 100644 index 00000000..0186fffb --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregatorTest.java @@ -0,0 +1,107 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class QuantilesSketchToQuantilePostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator starAgeQuantilesSketch; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + starAgeQuantilesSketch = new FieldAccessPostAggregator("star_age_quantiles_sketch"); + } + + private JSONObject getQuantilesSketchToQuantilePostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "quantilesDoublesSketchToQuantile"); + jsonObject.put("name", "star_age_quantile"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + QuantilesSketchToQuantilePostAggregator quantilesSketchToQuantilePostAggregator = + QuantilesSketchToQuantilePostAggregator.builder() + .name("star_age_quantile") + .field(starAgeQuantilesSketch) + .fraction(1.1D) + .build(); + + JSONObject jsonObject = getQuantilesSketchToQuantilePostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("star_age_quantiles_sketch")); + jsonObject.put("fraction", 1.1D); + + String actualJSON = objectMapper.writeValueAsString(quantilesSketchToQuantilePostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + QuantilesSketchToQuantilePostAggregator quantilesSketchToQuantilePostAggregator = + QuantilesSketchToQuantilePostAggregator.builder() + .field(starAgeQuantilesSketch) + .fraction(1.1D) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + QuantilesSketchToQuantilePostAggregator quantilesSketchToQuantilePostAggregator = + QuantilesSketchToQuantilePostAggregator.builder() + .name("star_age_quantile") + .fraction(1.1D) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullFraction() { + + QuantilesSketchToQuantilePostAggregator quantilesSketchToQuantilePostAggregator = + QuantilesSketchToQuantilePostAggregator.builder() + .name("star_age_quantile") + .field(starAgeQuantilesSketch) + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregatorTest.java new file mode 100644 index 00000000..286d65a6 --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregatorTest.java @@ -0,0 +1,112 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Arrays; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class QuantilesSketchToQuantilesPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator starAgeQuantilesSketch; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + starAgeQuantilesSketch = new FieldAccessPostAggregator("star_age_quantiles_sketch"); + } + + private JSONObject getQuantilesSketchToQuantilesPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "quantilesDoublesSketchToQuantiles"); + jsonObject.put("name", "star_age_quantiles"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + QuantilesSketchToQuantilesPostAggregator quantilesSketchToQuantilesPostAggregator = + QuantilesSketchToQuantilesPostAggregator.builder() + .name("star_age_quantiles") + .field(starAgeQuantilesSketch) + .fractions(Arrays.asList(1.1D, 2.2D)) + .build(); + + JSONObject jsonObject = getQuantilesSketchToQuantilesPostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("star_age_quantiles_sketch")); + jsonObject.put("fractions", new JSONArray( + Arrays.asList(1.1D, 2.2D) + )); + + String actualJSON = objectMapper.writeValueAsString(quantilesSketchToQuantilesPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + QuantilesSketchToQuantilesPostAggregator quantilesSketchToQuantilesPostAggregator = + QuantilesSketchToQuantilesPostAggregator.builder() + .field(starAgeQuantilesSketch) + .fractions(Arrays.asList(1.1D, 2.2D)) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + QuantilesSketchToQuantilesPostAggregator quantilesSketchToQuantilesPostAggregator = + QuantilesSketchToQuantilesPostAggregator.builder() + .name("star_age_quantiles") + .fractions(Arrays.asList(1.1D, 2.2D)) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullFractions() { + + QuantilesSketchToQuantilesPostAggregator quantilesSketchToQuantilesPostAggregator = + QuantilesSketchToQuantilesPostAggregator.builder() + .name("star_age_quantiles") + .field(starAgeQuantilesSketch) + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregatorTest.java new file mode 100644 index 00000000..14fdf41e --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregatorTest.java @@ -0,0 +1,93 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class QuantilesSketchToStringPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator starAgeQuantilesSketch; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + starAgeQuantilesSketch = new FieldAccessPostAggregator("star_age_quantiles_sketch"); + } + + private JSONObject getQuantilesSketchToStringPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "quantilesDoublesSketchToString"); + jsonObject.put("name", "star_age_info"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + QuantilesSketchToStringPostAggregator quantilesSketchToStringPostAggregator = + QuantilesSketchToStringPostAggregator.builder() + .name("star_age_info") + .field(starAgeQuantilesSketch) + .build(); + + JSONObject jsonObject = getQuantilesSketchToStringPostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("star_age_quantiles_sketch")); + + String actualJSON = objectMapper.writeValueAsString(quantilesSketchToStringPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + QuantilesSketchToStringPostAggregator quantilesSketchToStringPostAggregator = + QuantilesSketchToStringPostAggregator.builder() + .field(starAgeQuantilesSketch) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + QuantilesSketchToStringPostAggregator quantilesSketchToStringPostAggregator = + QuantilesSketchToStringPostAggregator.builder() + .name("star_age_info") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregatorTest.java new file mode 100644 index 00000000..831d5197 --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregatorTest.java @@ -0,0 +1,150 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Arrays; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class TupleSketchSetOpPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator milkyWay; + private FieldAccessPostAggregator andromeda; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + milkyWay = new FieldAccessPostAggregator("MilkyWay"); + andromeda = new FieldAccessPostAggregator("Andromeda"); + } + + private JSONObject getTupleSketchSetOpPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "arrayOfDoublesSketchSetOp"); + jsonObject.put("name", "AndroWay"); + jsonObject.put("operation", "UNION"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + TupleSketchSetOpPostAggregator tupleSketchSetOpPostAggregator = TupleSketchSetOpPostAggregator.builder() + .name("AndroWay") + .operation(TupleSketchOperation.UNION) + .fields(Arrays.asList(milkyWay, andromeda)) + .nominalEntries(1024) + .numberOfValues(1) + .build(); + + JSONObject jsonObject = getTupleSketchSetOpPostAggregatorJSON(); + jsonObject.put("fields", new JSONArray( + Arrays.asList( + getFieldAccessPostAggregatorJSON("MilkyWay"), + getFieldAccessPostAggregatorJSON("Andromeda") + )) + ); + jsonObject.put("nominalEntries", 1024); + jsonObject.put("numberOfValues", 1); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchSetOpPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test + public void testRequiredFields() throws JsonProcessingException, JSONException { + + TupleSketchSetOpPostAggregator tupleSketchSetOpPostAggregator = TupleSketchSetOpPostAggregator.builder() + .name("AndroWay") + .operation(TupleSketchOperation.UNION) + .fields(Arrays.asList(milkyWay, andromeda)) + .build(); + + JSONObject jsonObject = getTupleSketchSetOpPostAggregatorJSON(); + jsonObject.put("fields", new JSONArray( + Arrays.asList( + getFieldAccessPostAggregatorJSON("MilkyWay"), + getFieldAccessPostAggregatorJSON("Andromeda") + ) + )); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchSetOpPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void preconditionCheck() { + + TupleSketchSetOpPostAggregator tupleSketchSetOpPostAggregator = TupleSketchSetOpPostAggregator.builder() + .name("AndroWay") + .operation(TupleSketchOperation.UNION) + .fields(Arrays.asList(milkyWay, andromeda)) + .nominalEntries(3) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + TupleSketchSetOpPostAggregator tupleSketchSetOpPostAggregator = TupleSketchSetOpPostAggregator.builder() + .operation(TupleSketchOperation.UNION) + .fields(Arrays.asList(milkyWay, andromeda)) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullOperation() { + + TupleSketchSetOpPostAggregator tupleSketchSetOpPostAggregator = TupleSketchSetOpPostAggregator.builder() + .name("AndroWay") + .fields(Arrays.asList(milkyWay, andromeda)) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullFields() { + + TupleSketchSetOpPostAggregator tupleSketchSetOpPostAggregator = TupleSketchSetOpPostAggregator.builder() + .name("AndroWay") + .operation(TupleSketchOperation.UNION) + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregatorTest.java new file mode 100644 index 00000000..e0a3a3f1 --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregatorTest.java @@ -0,0 +1,103 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Arrays; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class TupleSketchTTestPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator milkyWay; + private FieldAccessPostAggregator andromeda; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + milkyWay = new FieldAccessPostAggregator("MilkyWay"); + andromeda = new FieldAccessPostAggregator("Andromeda"); + } + + private JSONObject getTupleSketchTTestPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "arrayOfDoublesSketchTTest"); + jsonObject.put("name", "androway_t_test"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + TupleSketchTTestPostAggregator tupleSketchTTestPostAggregator = + TupleSketchTTestPostAggregator.builder() + .name("androway_t_test") + .fields(Arrays.asList(milkyWay, andromeda)) + .build(); + + JSONObject jsonObject = getTupleSketchTTestPostAggregatorJSON(); + jsonObject.put("fields", new JSONArray( + Arrays.asList( + getFieldAccessPostAggregatorJSON("MilkyWay"), + getFieldAccessPostAggregatorJSON("Andromeda") + ) + )); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchTTestPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + TupleSketchTTestPostAggregator tupleSketchTTestPostAggregator = + TupleSketchTTestPostAggregator.builder() + .fields(Arrays.asList(milkyWay, andromeda)) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullFields() { + + TupleSketchTTestPostAggregator tupleSketchTTestPostAggregator = + TupleSketchTTestPostAggregator.builder() + .name("androway_t_test") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregatorTest.java new file mode 100644 index 00000000..4fddd73a --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregatorTest.java @@ -0,0 +1,112 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class TupleSketchToEstimateAndBoundsPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator milkyWay; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + milkyWay = new FieldAccessPostAggregator("MilkyWay"); + } + + private JSONObject getTupleSketchToEstimateAndBoundsPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "arrayOfDoublesSketchToEstimateAndBounds"); + jsonObject.put("name", "estimated_stars"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + TupleSketchToEstimateAndBoundsPostAggregator tupleSketchToEstimateAndBoundsPostAggregator = + TupleSketchToEstimateAndBoundsPostAggregator.builder() + .name("estimated_stars") + .field(milkyWay) + .numStdDevs(1) + .build(); + + JSONObject jsonObject = getTupleSketchToEstimateAndBoundsPostAggregatorJSON(); + jsonObject.put("field", (getFieldAccessPostAggregatorJSON("MilkyWay"))); + jsonObject.put("numStdDevs", 1); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchToEstimateAndBoundsPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test + public void testRequiredFields() throws JsonProcessingException, JSONException { + + TupleSketchToEstimateAndBoundsPostAggregator tupleSketchToEstimateAndBoundsPostAggregator = + TupleSketchToEstimateAndBoundsPostAggregator.builder() + .name("estimated_stars") + .field(milkyWay) + .build(); + + JSONObject jsonObject = getTupleSketchToEstimateAndBoundsPostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("MilkyWay")); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchToEstimateAndBoundsPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + TupleSketchToEstimateAndBoundsPostAggregator tupleSketchToEstimateAndBoundsPostAggregator = + TupleSketchToEstimateAndBoundsPostAggregator.builder() + .field(milkyWay) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + TupleSketchToEstimateAndBoundsPostAggregator tupleSketchToEstimateAndBoundsPostAggregator = + TupleSketchToEstimateAndBoundsPostAggregator.builder() + .name("estimated_stars") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregatorTest.java new file mode 100644 index 00000000..ff24f64a --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregatorTest.java @@ -0,0 +1,93 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class TupleSketchToEstimatePostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator milkyWay; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + milkyWay = new FieldAccessPostAggregator("MilkyWay"); + } + + private JSONObject getTupleSketchToEstimatePostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "arrayOfDoublesSketchToEstimate"); + jsonObject.put("name", "estimated_stars"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + TupleSketchToEstimatePostAggregator tupleSketchToEstimatePostAggregator = + TupleSketchToEstimatePostAggregator.builder() + .name("estimated_stars") + .field(milkyWay) + .build(); + + JSONObject jsonObject = getTupleSketchToEstimatePostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("MilkyWay")); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchToEstimatePostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + TupleSketchToEstimatePostAggregator tupleSketchToEstimatePostAggregator = + TupleSketchToEstimatePostAggregator.builder() + .field(milkyWay) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + TupleSketchToEstimatePostAggregator tupleSketchToEstimatePostAggregator = + TupleSketchToEstimatePostAggregator.builder() + .name("estimated_stars") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregatorTest.java new file mode 100644 index 00000000..70866a9d --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregatorTest.java @@ -0,0 +1,93 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class TupleSketchToMeansPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator milkyWay; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + milkyWay = new FieldAccessPostAggregator("MilkyWay"); + } + + private JSONObject getTupleSketchToMeansPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "arrayOfDoublesSketchToMeans"); + jsonObject.put("name", "mean_stars"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + TupleSketchToMeansPostAggregator tupleSketchToMeansPostAggregator = + TupleSketchToMeansPostAggregator.builder() + .name("mean_stars") + .field(milkyWay) + .build(); + + JSONObject jsonObject = getTupleSketchToMeansPostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("MilkyWay")); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchToMeansPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + TupleSketchToMeansPostAggregator tupleSketchToMeansPostAggregator = + TupleSketchToMeansPostAggregator.builder() + .field(milkyWay) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + TupleSketchToMeansPostAggregator tupleSketchToMeansPostAggregator = + TupleSketchToMeansPostAggregator.builder() + .name("mean_stars") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregatorTest.java new file mode 100644 index 00000000..7537d6a6 --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregatorTest.java @@ -0,0 +1,93 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class TupleSketchToNumEntriesPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator milkyWay; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + milkyWay = new FieldAccessPostAggregator("MilkyWay"); + } + + private JSONObject getTupleSketchToNumEntriesPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "arrayOfDoublesSketchToNumEntries"); + jsonObject.put("name", "total_stars"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + TupleSketchToNumEntriesPostAggregator tupleSketchToNumEntriesPostAggregator = + TupleSketchToNumEntriesPostAggregator.builder() + .name("total_stars") + .field(milkyWay) + .build(); + + JSONObject jsonObject = getTupleSketchToNumEntriesPostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("MilkyWay")); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchToNumEntriesPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + TupleSketchToNumEntriesPostAggregator tupleSketchToNumEntriesPostAggregator = + TupleSketchToNumEntriesPostAggregator.builder() + .field(milkyWay) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + TupleSketchToNumEntriesPostAggregator tupleSketchToNumEntriesPostAggregator = + TupleSketchToNumEntriesPostAggregator.builder() + .name("total_stars") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregatorTest.java new file mode 100644 index 00000000..2afdbd91 --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregatorTest.java @@ -0,0 +1,114 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class TupleSketchToQuantilesSketchPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator milkyWay; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + milkyWay = new FieldAccessPostAggregator("MilkyWay"); + } + + private JSONObject getTupleSketchToQuantilesSketchPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "arrayOfDoublesSketchToQuantilesSketch"); + jsonObject.put("name", "milky_way_quantile_sketch"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + TupleSketchToQuantilesSketchPostAggregator tupleSketchToQuantilesSketchPostAggregator = + TupleSketchToQuantilesSketchPostAggregator.builder() + .name("milky_way_quantile_sketch") + .field(milkyWay) + .column(1) + .k(1024) + .build(); + + JSONObject jsonObject = getTupleSketchToQuantilesSketchPostAggregatorJSON(); + jsonObject.put("field", (getFieldAccessPostAggregatorJSON("MilkyWay"))); + jsonObject.put("column", 1); + jsonObject.put("k", 1024); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchToQuantilesSketchPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test + public void testRequiredFields() throws JsonProcessingException, JSONException { + + TupleSketchToQuantilesSketchPostAggregator tupleSketchToQuantilesSketchPostAggregator = + TupleSketchToQuantilesSketchPostAggregator.builder() + .name("milky_way_quantile_sketch") + .field(milkyWay) + .build(); + + JSONObject jsonObject = getTupleSketchToQuantilesSketchPostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("MilkyWay")); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchToQuantilesSketchPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + TupleSketchToQuantilesSketchPostAggregator tupleSketchToQuantilesSketchPostAggregator = + TupleSketchToQuantilesSketchPostAggregator.builder() + .field(milkyWay) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + TupleSketchToQuantilesSketchPostAggregator tupleSketchToQuantilesSketchPostAggregator = + TupleSketchToQuantilesSketchPostAggregator.builder() + .name("milky_way_quantile_sketch") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregatorTest.java new file mode 100644 index 00000000..b75f355e --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregatorTest.java @@ -0,0 +1,93 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class TupleSketchToStringPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator milkyWay; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + milkyWay = new FieldAccessPostAggregator("MilkyWay"); + } + + private JSONObject getTupleSketchToStringPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "arrayOfDoublesSketchToString"); + jsonObject.put("name", "milky_way_info"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + TupleSketchToStringPostAggregator tupleSketchToStringPostAggregator = + TupleSketchToStringPostAggregator.builder() + .name("milky_way_info") + .field(milkyWay) + .build(); + + JSONObject jsonObject = getTupleSketchToStringPostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("MilkyWay")); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchToStringPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + TupleSketchToStringPostAggregator tupleSketchToStringPostAggregator = + TupleSketchToStringPostAggregator.builder() + .field(milkyWay) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + TupleSketchToStringPostAggregator tupleSketchToStringPostAggregator = + TupleSketchToStringPostAggregator.builder() + .name("milky_way_info") + .build(); + } +} \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregatorTest.java new file mode 100644 index 00000000..62bffd85 --- /dev/null +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregatorTest.java @@ -0,0 +1,93 @@ +/* + * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package in.zapr.druid.druidry.extensions.datasketches.postAggregator; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; + +public class TupleSketchToVariancesPostAggregatorTest { + + private static ObjectMapper objectMapper; + + private FieldAccessPostAggregator milkyWay; + + @BeforeClass + public void init() { + objectMapper = new ObjectMapper(); + milkyWay = new FieldAccessPostAggregator("MilkyWay"); + } + + private JSONObject getTupleSketchToVariancesPostAggregatorJSON() throws JSONException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type", "arrayOfDoublesSketchToVariances"); + jsonObject.put("name", "milky_way_variances"); + return jsonObject; + } + + private JSONObject getFieldAccessPostAggregatorJSON(String fieldName) throws JSONException { + JSONObject fieldAccess = new JSONObject(); + fieldAccess.put("type", "fieldAccess"); + fieldAccess.put("fieldName", fieldName); + + return fieldAccess; + } + + @Test + public void testAllFields() throws JsonProcessingException, JSONException { + + TupleSketchToVariancesPostAggregator tupleSketchToVariancesPostAggregator = + TupleSketchToVariancesPostAggregator.builder() + .name("milky_way_variances") + .field(milkyWay) + .build(); + + JSONObject jsonObject = getTupleSketchToVariancesPostAggregatorJSON(); + jsonObject.put("field", getFieldAccessPostAggregatorJSON("MilkyWay")); + + String actualJSON = objectMapper.writeValueAsString(tupleSketchToVariancesPostAggregator); + String expectedJSON = jsonObject.toString(); + JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullName() { + + TupleSketchToVariancesPostAggregator tupleSketchToVariancesPostAggregator = + TupleSketchToVariancesPostAggregator.builder() + .field(milkyWay) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullField() { + + TupleSketchToVariancesPostAggregator tupleSketchToVariancesPostAggregator = + TupleSketchToVariancesPostAggregator.builder() + .name("milky_way_variances") + .build(); + } +} \ No newline at end of file From aa69bbde880f7e929da8fa5b89f3f48c6ec52a84 Mon Sep 17 00:00:00 2001 From: Abhi Sapariya Date: Sun, 4 Aug 2019 01:51:48 +0530 Subject: [PATCH 16/20] EqualsAndHashCode --- .../datasketches/aggregator/HllSketchBuildAggregator.java | 2 ++ .../datasketches/aggregator/HllSketchMergeAggregator.java | 2 ++ .../datasketches/aggregator/QuantilesSketchAggregator.java | 2 ++ .../datasketches/aggregator/ThetaSketchAggregator.java | 2 ++ .../datasketches/aggregator/TupleSketchAggregator.java | 2 ++ .../HllSketchEstimateWithBoundsPostAggregator.java | 2 ++ .../postAggregator/HllSketchToStringPostAggregator.java | 2 ++ .../postAggregator/HllSketchUnionPostAggregator.java | 2 ++ .../QuantilesSketchToHistogramPostAggregator.java | 2 ++ .../postAggregator/QuantilesSketchToQuantilePostAggregator.java | 2 ++ .../QuantilesSketchToQuantilesPostAggregator.java | 2 ++ .../postAggregator/QuantilesSketchToStringPostAggregator.java | 2 ++ .../postAggregator/ThetaSketchEstimatePostAggregator.java | 2 ++ .../postAggregator/ThetaSketchSetOpPostAggregator.java | 2 ++ .../postAggregator/TupleSketchSetOpPostAggregator.java | 2 ++ .../postAggregator/TupleSketchTTestPostAggregator.java | 2 ++ .../TupleSketchToEstimateAndBoundsPostAggregator.java | 2 ++ .../postAggregator/TupleSketchToEstimatePostAggregator.java | 2 ++ .../postAggregator/TupleSketchToMeansPostAggregator.java | 2 ++ .../postAggregator/TupleSketchToNumEntriesPostAggregator.java | 2 ++ .../TupleSketchToQuantilesSketchPostAggregator.java | 2 ++ .../postAggregator/TupleSketchToStringPostAggregator.java | 2 ++ .../postAggregator/TupleSketchToVariancesPostAggregator.java | 2 ++ 23 files changed, 46 insertions(+) diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchBuildAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchBuildAggregator.java index 0224da81..a0535a4c 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchBuildAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchBuildAggregator.java @@ -21,11 +21,13 @@ import in.zapr.druid.druidry.aggregator.DruidAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class HllSketchBuildAggregator extends DruidAggregator { private static final String HLL_SKETCH_BUILD_TYPE_AGGREGATOR = "HLLSketchBuild"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchMergeAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchMergeAggregator.java index 8dee28ee..72157496 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchMergeAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/HllSketchMergeAggregator.java @@ -21,11 +21,13 @@ import in.zapr.druid.druidry.aggregator.DruidAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class HllSketchMergeAggregator extends DruidAggregator { private static final String HLL_SKETCH_MERGE_TYPE_AGGREGATOR = "HLLSketchMerge"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregator.java index 58bd39d4..a8bd31a0 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/QuantilesSketchAggregator.java @@ -23,11 +23,13 @@ import in.zapr.druid.druidry.aggregator.DruidAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class QuantilesSketchAggregator extends DruidAggregator { private static final String QUANTILES_SKETCH_TYPE_AGGREGATOR = "quantilesDoublesSketch"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/ThetaSketchAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/ThetaSketchAggregator.java index c4c490be..3b47e173 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/ThetaSketchAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/ThetaSketchAggregator.java @@ -23,11 +23,13 @@ import in.zapr.druid.druidry.aggregator.DruidAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class ThetaSketchAggregator extends DruidAggregator { private static final String THETA_SKETCH_TYPE_AGGREGATOR = "thetaSketch"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TupleSketchAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TupleSketchAggregator.java index b7ebfb85..c279bd53 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TupleSketchAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TupleSketchAggregator.java @@ -25,11 +25,13 @@ import in.zapr.druid.druidry.aggregator.DruidAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class TupleSketchAggregator extends DruidAggregator { private static final String TUPLE_SKETCH_TYPE_AGGREGATOR = "arrayOfDoublesSketch"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregator.java index 0b815cc9..606d3039 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregator.java @@ -20,11 +20,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class HllSketchEstimateWithBoundsPostAggregator extends DruidPostAggregator { private static final String HLL_SKETCH_ESTIMATE_WITH_BOUNDS_POST_AGGREGATOR_TYPE = "HLLSketchEstimateWithBounds"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregator.java index ebf3a12b..ad5443e7 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregator.java @@ -20,11 +20,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class HllSketchToStringPostAggregator extends DruidPostAggregator { private static final String HLL_SKETCH_TO_STRING_POST_AGGREGATOR_TYPE = "HLLSketchToString"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregator.java index 7e1c5204..8f03d81b 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregator.java @@ -24,11 +24,13 @@ import in.zapr.druid.druidry.extensions.datasketches.aggregator.TargetHllType; import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class HllSketchUnionPostAggregator extends DruidPostAggregator { private static final String HLL_SKETCH_UNION_POST_AGGREGATOR_TYPE = "HLLSketchUnion"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java index 39d66345..47b2ca02 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToHistogramPostAggregator.java @@ -22,11 +22,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class QuantilesSketchToHistogramPostAggregator extends DruidPostAggregator { private static final String QUANTILES_SKETCH_TO_HISTOGRAM_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToHistogram"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java index cd8064e0..f4c1d852 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java @@ -20,11 +20,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class QuantilesSketchToQuantilePostAggregator extends DruidPostAggregator { private static final String QUANTILES_SKETCH_TO_QUANTILE_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToQuantile"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java index bf11584b..e591f161 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilesPostAggregator.java @@ -22,11 +22,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class QuantilesSketchToQuantilesPostAggregator extends DruidPostAggregator { private static final String QUANTILES_SKETCH_TO_QUANTILES_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToQuantiles"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java index f0e044f3..51c33444 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java @@ -20,11 +20,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class QuantilesSketchToStringPostAggregator extends DruidPostAggregator { private static final String QUANTILES_SKETCH_TO_STRING_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToString"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java index 23dae2b8..ebd924a1 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchEstimatePostAggregator.java @@ -17,10 +17,12 @@ package in.zapr.druid.druidry.extensions.datasketches.postAggregator; import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter +@EqualsAndHashCode(callSuper = true) public class ThetaSketchEstimatePostAggregator extends DruidPostAggregator { private static final String THETA_SKETCH_ESTIMATE_POST_AGGREGATOR_TYPE = "thetaSketchEstimate"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchSetOpPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchSetOpPostAggregator.java index 84259043..8c76c8f6 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchSetOpPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchSetOpPostAggregator.java @@ -23,11 +23,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class ThetaSketchSetOpPostAggregator extends DruidPostAggregator { private static final String THETA_SKETCH_SET_OP_POST_AGGREGATOR_TYPE = "thetaSketchSetOp"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregator.java index 3ba26870..c51a8cd9 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchSetOpPostAggregator.java @@ -25,11 +25,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class TupleSketchSetOpPostAggregator extends DruidPostAggregator { private static final String TUPLE_SKETCH_SET_OP_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchSetOp"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java index 30149633..750002bf 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java @@ -22,11 +22,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class TupleSketchTTestPostAggregator extends DruidPostAggregator { private static final String TUPLE_SKETCH_TTEST_AGGREGATOR_TYPE = "arrayOfDoublesSketchTTest"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregator.java index 4fe04ad5..6c6f07e7 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimateAndBoundsPostAggregator.java @@ -20,11 +20,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class TupleSketchToEstimateAndBoundsPostAggregator extends DruidPostAggregator { private static final String TUPLE_SKETCH_TO_ESTIMATE_AND_BOUNDS_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToEstimateAndBounds"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java index b3518fa2..d86c6871 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java @@ -20,11 +20,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class TupleSketchToEstimatePostAggregator extends DruidPostAggregator { private static final String TUPLE_SKETCH_TO_ESTIMATE_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToEstimate"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java index a43cdea6..0fa96c59 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java @@ -20,11 +20,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class TupleSketchToMeansPostAggregator extends DruidPostAggregator { private static final String TUPLE_SKETCH_TO_MEANS_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToMeans"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java index d7e7e523..754fe5e9 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java @@ -20,11 +20,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class TupleSketchToNumEntriesPostAggregator extends DruidPostAggregator { private static final String TUPLE_SKETCH_TO_NUM_ENTRIES_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToNumEntries"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregator.java index 9c116f79..05087b1b 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToQuantilesSketchPostAggregator.java @@ -20,11 +20,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class TupleSketchToQuantilesSketchPostAggregator extends DruidPostAggregator { private static final String TUPLE_SKETCH_TO_QUANTILES_SKETCH_AGGREGATOR_TYPE = "arrayOfDoublesSketchToQuantilesSketch"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java index c67021c2..89a240f5 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java @@ -20,11 +20,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class TupleSketchToStringPostAggregator extends DruidPostAggregator { private static final String TUPLE_SKETCH_TO_STRING_AGGREGATOR_TYPE = "arrayOfDoublesSketchToString"; diff --git a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java index bb8d8cd9..fa778ce3 100644 --- a/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java +++ b/src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java @@ -20,11 +20,13 @@ import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import lombok.Builder; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode(callSuper = true) public class TupleSketchToVariancesPostAggregator extends DruidPostAggregator { private static final String TUPLE_SKETCH_TO_VARIANCES_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToVariances"; From 1d3726b4d3b44f4c9782f7baa6d1378a9c2fe206 Mon Sep 17 00:00:00 2001 From: Abhi Sapariya <43852557+abhi-zapr@users.noreply.github.com> Date: Sat, 10 Aug 2019 14:56:46 +0530 Subject: [PATCH 17/20] Version bumped to 2.14-SNAPSHOT Pending from last release. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf7f7698..e46bf18f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ in.zapr.druid druidry - 2.13 + 2.14-SNAPSHOT Druidry - Druid Java Client Druidry is an open-source Java based utility library which supports creating From 865f0dbb6d26905cca851a1cf5d22cc6958eec46 Mon Sep 17 00:00:00 2001 From: Abhi Sapariya Date: Sat, 10 Aug 2019 15:28:11 +0530 Subject: [PATCH 18/20] spellCheck refactor --- .../postAggregator/HllSketchUnionPostAggregatorTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregatorTest.java b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregatorTest.java index 6e75f23f..eb572627 100644 --- a/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregatorTest.java +++ b/src/test/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchUnionPostAggregatorTest.java @@ -120,7 +120,7 @@ public void testNullName() { } @Test(expectedExceptions = NullPointerException.class) - public void testNullField() { + public void testNullFields() { HllSketchUnionPostAggregator hllSketchUnionPostAggregator = HllSketchUnionPostAggregator.builder() From 48fdac333ef79fef192abca7cb8ecd287d6e47cd Mon Sep 17 00:00:00 2001 From: Abhi Sapariya <43852557+abhi-zapr@users.noreply.github.com> Date: Sat, 10 Aug 2019 17:12:59 +0530 Subject: [PATCH 19/20] seperating databind and datatype version separating as datatype didn't had 2.9.9.2 release --- pom.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9c7bcfad..0bc30dba 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,8 @@ UTF-8 - 2.9.9.2 + 2.9.9.2 + 2.9.9 2.9.7 1.16.14 6.11 @@ -38,13 +39,13 @@ com.fasterxml.jackson.core jackson-databind - ${jackson.version} + ${jackson.databind.version} com.fasterxml.jackson.datatype jackson-datatype-joda - ${jackson.version} + ${jackson.datatype.version} From 3ac68c04bd96ac3ab8b6ba5f89cd71b5adaa8d1b Mon Sep 17 00:00:00 2001 From: Abhi Sapariya <43852557+abhi-zapr@users.noreply.github.com> Date: Sat, 10 Aug 2019 17:34:40 +0530 Subject: [PATCH 20/20] Version bumped to 2.14 for next release --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2dd60efb..032f29a7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ in.zapr.druid druidry - 2.14-SNAPSHOT + 2.14 Druidry - Druid Java Client Druidry is an open-source Java based utility library which supports creating