├── .gitignore ├── .maven.xml ├── .travis.yml ├── LICENSE ├── NOTICE ├── README.md ├── pom.xml └── src ├── main └── java │ └── in │ └── zapr │ └── druid │ └── druidry │ ├── aggregator │ ├── CardinalityAggregator.java │ ├── CountAggregator.java │ ├── DoubleFirstAggregator.java │ ├── DoubleLastAggregator.java │ ├── DoubleMaxAggregator.java │ ├── DoubleMinAggregator.java │ ├── DoubleSumAggregator.java │ ├── DruidAggregator.java │ ├── FilteredAggregator.java │ ├── FloatFirstAggregator.java │ ├── FloatLastAggregator.java │ ├── HyperUniqueAggregator.java │ ├── JavaScriptAggregator.java │ ├── LongFirstAggregator.java │ ├── LongLastAggregator.java │ ├── LongMaxAggregator.java │ ├── LongMinAggregator.java │ ├── LongSumAggregator.java │ ├── StringFirstAggregator.java │ └── StringLastAggregator.java │ ├── averager │ ├── DoubleMaxAverager.java │ ├── DoubleMeanAverager.java │ ├── DoubleMeanNoNullsAverager.java │ ├── DoubleMinAverager.java │ ├── DoubleSumAverager.java │ ├── DruidAverager.java │ ├── LongMaxAverager.java │ ├── LongMeanAverager.java │ ├── LongMeanNoNullsAverager.java │ ├── LongMinAverager.java │ └── LongSumAverager.java │ ├── client │ ├── DruidClient.java │ ├── DruidConfiguration.java │ ├── DruidError.java │ ├── DruidJerseyClient.java │ ├── DruidQueryProtocol.java │ └── exception │ │ ├── ConnectionException.java │ │ ├── DruidryException.java │ │ └── QueryException.java │ ├── dataSource │ ├── DataSource.java │ ├── DataSourceType.java │ ├── QueryDataSource.java │ ├── TableDataSource.java │ └── UnionDataSource.java │ ├── dimension │ ├── DefaultDimension.java │ ├── DimensionSpec.java │ ├── DruidDimension.java │ ├── ExtractionDimension.java │ ├── FilteredDimension.java │ ├── ListFilteredDimension.java │ ├── PrefixFilteredDimension.java │ ├── RegexFilteredDimension.java │ ├── SimpleDimension.java │ └── enums │ │ ├── FilteredDimensionType.java │ │ └── OutputType.java │ ├── extensions │ ├── datasketches │ │ ├── aggregator │ │ │ ├── HllSketchBuildAggregator.java │ │ │ ├── HllSketchMergeAggregator.java │ │ │ ├── QuantilesSketchAggregator.java │ │ │ ├── TargetHllType.java │ │ │ ├── ThetaSketchAggregator.java │ │ │ └── TupleSketchAggregator.java │ │ └── postAggregator │ │ │ ├── HllSketchEstimateWithBoundsPostAggregator.java │ │ │ ├── HllSketchToStringPostAggregator.java │ │ │ ├── HllSketchUnionPostAggregator.java │ │ │ ├── QuantilesSketchToHistogramPostAggregator.java │ │ │ ├── QuantilesSketchToQuantilePostAggregator.java │ │ │ ├── QuantilesSketchToQuantilesPostAggregator.java │ │ │ ├── QuantilesSketchToStringPostAggregator.java │ │ │ ├── ThetaSketchEstimatePostAggregator.java │ │ │ ├── ThetaSketchFunction.java │ │ │ ├── ThetaSketchSetOpPostAggregator.java │ │ │ ├── TupleSketchOperation.java │ │ │ ├── TupleSketchSetOpPostAggregator.java │ │ │ ├── TupleSketchTTestPostAggregator.java │ │ │ ├── TupleSketchToEstimateAndBoundsPostAggregator.java │ │ │ ├── TupleSketchToEstimatePostAggregator.java │ │ │ ├── TupleSketchToMeansPostAggregator.java │ │ │ ├── TupleSketchToNumEntriesPostAggregator.java │ │ │ ├── TupleSketchToQuantilesSketchPostAggregator.java │ │ │ ├── TupleSketchToStringPostAggregator.java │ │ │ └── TupleSketchToVariancesPostAggregator.java │ ├── distinctcount │ │ └── aggregator │ │ │ └── DistinctCountAggregator.java │ └── histogram │ │ ├── aggregator │ │ ├── ApproxHistogramAggregator.java │ │ ├── ApproxHistogramFoldAggregator.java │ │ └── QuantilePostAggregator.java │ │ └── postAggregator │ │ ├── CustomBucketsPostAggregator.java │ │ ├── EqualBucketsPostAggregator.java │ │ ├── MaxPostAggregator.java │ │ ├── MinPostAggregator.java │ │ ├── QuantilePostAggregator.java │ │ └── QuantilesPostAggregator.java │ ├── extractionFunctions │ ├── CascadeExtractionFunction.java │ ├── ExtractionFunction.java │ ├── JavascriptExtractionFunction.java │ ├── LookUpExtractionFunction.java │ ├── PartialExtractionFunction.java │ ├── RegexExtractionFunction.java │ ├── RegisteredLookUpExtractionFunction.java │ ├── SearchQueryExtractionFunction.java │ ├── StrLenExtractionFunction.java │ ├── StringFormatExtractionFunction.java │ ├── SubStringExtractionFunction.java │ ├── TimeFormatExtractionFunction.java │ └── TimeParsingExtractionFunction.java │ ├── filter │ ├── AndFilter.java │ ├── BoundFilter.java │ ├── DruidFilter.java │ ├── InFilter.java │ ├── IntervalFilter.java │ ├── JavaScriptFilter.java │ ├── NotFilter.java │ ├── OrFilter.java │ ├── RegexFilter.java │ ├── SearchFilter.java │ ├── SelectorFilter.java │ ├── havingSpec │ │ ├── AndHaving.java │ │ ├── DimSelectorHaving.java │ │ ├── EqualToHaving.java │ │ ├── FilterHaving.java │ │ ├── GreaterThanHaving.java │ │ ├── HavingSpec.java │ │ ├── LessThanHaving.java │ │ ├── NotHaving.java │ │ └── OrHaving.java │ └── searchQuerySpec │ │ ├── ContainsSearchQuerySpec.java │ │ ├── FragmentSearchQuerySpec.java │ │ ├── InsensitiveContainsSearchQuerySpec.java │ │ ├── RegexSearchQuerySpec.java │ │ └── SearchQuerySpec.java │ ├── granularity │ ├── DurationGranularity.java │ ├── Granularity.java │ ├── PeriodGranularity.java │ ├── PredefinedGranularity.java │ └── SimpleGranularity.java │ ├── limitSpec │ ├── DefaultLimitSpec.java │ └── orderByColumnSpec │ │ ├── OrderByColumnSpec.java │ │ ├── OrderByColumnSpecMap.java │ │ └── OrderByColumnSpecString.java │ ├── lookUpSpec │ └── LookUpSpec.java │ ├── postAggregator │ ├── ArithmeticFunction.java │ ├── ArithmeticOrdering.java │ ├── ArithmeticPostAggregator.java │ ├── ConstantPostAggregator.java │ ├── DruidPostAggregator.java │ ├── FieldAccessPostAggregator.java │ ├── HyperUniqueCardinalityPostAggregator.java │ └── JavaScriptPostAggregator.java │ ├── query │ ├── DruidQuery.java │ ├── QueryType.java │ ├── aggregation │ │ ├── DruidAggregationQuery.java │ │ ├── DruidGroupByQuery.java │ │ ├── DruidMovingAverageQuery.java │ │ ├── DruidTimeSeriesQuery.java │ │ └── DruidTopNQuery.java │ ├── config │ │ ├── Context.java │ │ ├── GroupByStrategy.java │ │ ├── Interval.java │ │ ├── SortingOrder.java │ │ └── Vectorize.java │ ├── metadata │ │ ├── DruidDataSourceMetadataQuery.java │ │ ├── DruidMetadataQuery.java │ │ ├── DruidSegmentMetadataQuery.java │ │ └── DruidTimeBoundaryQuery.java │ ├── scan │ │ ├── DruidScanQuery.java │ │ └── ResultFormat.java │ ├── search │ │ ├── DruidSearchQuery.java │ │ └── SearchSortSpec.java │ └── select │ │ ├── DruidSelectQuery.java │ │ └── PagingSpec.java │ ├── topNMetric │ ├── DimensionMetric.java │ ├── InvertedMetric.java │ ├── NumericMetric.java │ ├── SimpleMetric.java │ └── TopNMetric.java │ └── virtualColumn │ ├── DruidVirtualColumn.java │ └── ExpressionVirtualColumn.java └── test ├── java └── in │ └── zapr │ └── druid │ └── druidry │ ├── aggregator │ ├── CardinalityAggregatorTest.java │ ├── CountAggregatorTest.java │ ├── DoubleFirstAggregatorTest.java │ ├── DoubleLastAggregatorTest.java │ ├── DoubleMaxAggregatorTest.java │ ├── DoubleMinAggregatorTest.java │ ├── DoubleSumAggregatorTest.java │ ├── FilteredAggregatorTest.java │ ├── FloatFirstAggregatorTest.java │ ├── FloatLastAggregatorTest.java │ ├── HyperUniqueAggregatorTest.java │ ├── JavaScriptAggregatorTest.java │ ├── LongFirstAggregatorTest.java │ ├── LongLastAggregatorTest.java │ ├── LongMaxAggregatorTest.java │ ├── LongMinAggregatorTest.java │ ├── LongSumAggregatorTest.java │ ├── StringFirstAggregatorTest.java │ └── StringLastAggregatorTest.java │ ├── client │ ├── DruidClientTest.java │ └── DruidConfigurationTest.java │ ├── dataSource │ ├── QueryDataSourceTest.java │ ├── TableDataSourceTest.java │ └── UnionDataSourceTest.java │ ├── dimension │ ├── DefaultDimensionTest.java │ ├── ExtractionDimensionTest.java │ ├── ListFilteredDimensionTest.java │ ├── PrefixFilteredDimensionTest.java │ ├── RegexFilteredDimensionTest.java │ └── SimpleDimensionTest.java │ ├── extensions │ ├── datasketches │ │ ├── aggregator │ │ │ ├── HllSketchBuildAggregatorTest.java │ │ │ ├── HllSketchMergeAggregatorTest.java │ │ │ ├── QuantilesSketchAggregatorTest.java │ │ │ ├── ThetaSketchAggregatorTest.java │ │ │ └── TupleSketchAggregatorTest.java │ │ └── postAggregator │ │ │ ├── HllSketchEstimateWithBoundsPostAggregatorTest.java │ │ │ ├── HllSketchToStringPostAggregatorTest.java │ │ │ ├── HllSketchUnionPostAggregatorTest.java │ │ │ ├── QuantilesSketchToHistogramPostAggregatorTest.java │ │ │ ├── QuantilesSketchToQuantilePostAggregatorTest.java │ │ │ ├── QuantilesSketchToQuantilesPostAggregatorTest.java │ │ │ ├── QuantilesSketchToStringPostAggregatorTest.java │ │ │ ├── ThetaSketchEstimatePostAggregatorTest.java │ │ │ ├── ThetaSketchSetOpPostAggregatorTest.java │ │ │ ├── TupleSketchSetOpPostAggregatorTest.java │ │ │ ├── TupleSketchTTestPostAggregatorTest.java │ │ │ ├── TupleSketchToEstimateAndBoundsPostAggregatorTest.java │ │ │ ├── TupleSketchToEstimatePostAggregatorTest.java │ │ │ ├── TupleSketchToMeansPostAggregatorTest.java │ │ │ ├── TupleSketchToNumEntriesPostAggregatorTest.java │ │ │ ├── TupleSketchToQuantilesSketchPostAggregatorTest.java │ │ │ ├── TupleSketchToStringPostAggregatorTest.java │ │ │ └── TupleSketchToVariancesPostAggregatorTest.java │ ├── distinctcount │ │ └── aggregator │ │ │ └── DistinctCountAggregatorTest.java │ └── histogram │ │ ├── aggregator │ │ ├── ApproxHistogramAggregatorTest.java │ │ ├── ApproxHistogramFoldAggregatorTest.java │ │ └── QuantilePostAggregatorTest.java │ │ └── postAggregator │ │ ├── CustomBucketsPostAggregatorTest.java │ │ ├── EqualBucketsPostAggregatorTest.java │ │ ├── MaxPostAggregatorTest.java │ │ ├── MinPostAggregatorTest.java │ │ ├── QuantilePostAggregatorTest.java │ │ └── QuantilesPostAggregatorTest.java │ ├── extractionFunctions │ ├── CascadeExtractionFunctionTest.java │ ├── JavascriptExtractionFunctionTest.java │ ├── PartialExtractionFunctionTest.java │ ├── RegexExtractionFunctionTest.java │ ├── SearchQueryExtractionFunctionTest.java │ ├── StrLenExtractionFunctionTest.java │ ├── SubStringExtractionFunctionTest.java │ ├── TimeFormatExtractionFunctionTest.java │ └── TimeParsingExtractionFunctionTest.java │ ├── filter │ ├── AndFilterTest.java │ ├── BoundFilterTest.java │ ├── InFilterTest.java │ ├── IntervalFilterTest.java │ ├── JavascriptFilterTest.java │ ├── NotFilterTest.java │ ├── OrFilterTest.java │ ├── RegexFilterTest.java │ ├── SelectorFilterTest.java │ ├── havingSpec │ │ ├── AndHavingTest.java │ │ ├── DimSelectionHavingTest.java │ │ ├── EqualToHavingTest.java │ │ ├── FilterHavingTest.java │ │ ├── GreaterThanHavingTest.java │ │ ├── LessThanHavingTest.java │ │ ├── NotHavingTest.java │ │ └── OrHavingTest.java │ └── searchQuerySpec │ │ ├── ContainsSearchQuerySpecTest.java │ │ ├── FragmentSearchQuerySpecTest.java │ │ ├── InsensitiveContainsSearchQuerySpecTest.java │ │ └── RegexSearchQuerySpecTest.java │ ├── granularity │ ├── DurationGranularityTest.java │ ├── PeriodGranularityTest.java │ └── SimpleGranularityTest.java │ ├── limitSpec │ ├── DefaultLimitSpecTest.java │ └── OrderByColumnSpecMapTest.java │ ├── postAggregator │ ├── ArithmeticPostAggregatorTest.java │ ├── ConstantPostAggregatorTest.java │ ├── FieldAccessPostAggregatorTest.java │ ├── HyperUniqueCardinalityPostAggregatorTest.java │ └── JavascriptPostAggregatorTest.java │ ├── query │ ├── aggregation │ │ ├── GroupByTest.java │ │ ├── MovingAverageCreators.java │ │ ├── MovingAverageTest.java │ │ ├── TimeSeriesTest.java │ │ └── TopNQueryTest.java │ ├── config │ │ ├── ContextTest.java │ │ └── IntervalTest.java │ ├── scan │ │ └── DruidScanQueryTest.java │ ├── search │ │ └── DruidSearchQueryTest.java │ └── select │ │ └── DruidSelectQueryTest.java │ ├── topNMetric │ ├── DimensionMetricTest.java │ ├── InvertedMetricTest.java │ └── NumericMetricTest.java │ └── virtualColumn │ └── ExpressionVirtualColumnTest.java └── resources └── query └── aggregation └── moving_average ├── allFields.json ├── averager_type ├── doubleMax.json ├── doubleMean.json ├── doubleMeanNoNulls.json ├── doubleMin.json ├── doubleSum.json ├── longMax.json ├── longMean.json ├── longMeanNoNulls.json ├── longMin.json └── longSum.json └── simple.json /.maven.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | ossrh 7 | ${env.SONATYPE_USERNAME} 8 | ${env.SONATYPE_PASSWORD} 9 | 10 | 11 | 12 | 13 | 14 | ossrh 15 | 16 | true 17 | 18 | 19 | ${env.GPG_EXECUTABLE} 20 | ${env.GPG_PASSPHRASE} 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | cache: 4 | directories: 5 | - $HOME/.m2 6 | 7 | #before_install: 8 | # - echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import 9 | # - echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --import-ownertrust 10 | 11 | install: 12 | mvn --settings .maven.xml install -DskipTests=true -Dgpg.skip -Dmaven.javadoc.skip=true -B -V 13 | 14 | #script: 15 | # mvn clean deploy --settings .maven.xml -DskipTests=true -B -U -Prelease 16 | 17 | before_deploy: 18 | - echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import 19 | - echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --import-ownertrust 20 | - mvn help:evaluate -N -Dexpression=project.version|grep -v '\[' 21 | - export project_version=$(mvn help:evaluate -N -Dexpression=project.version|grep -v '\[') 22 | 23 | deploy: 24 | provider: script 25 | script: mvn clean deploy --settings .maven.xml -DskipTests=true -B -U -Prelease 26 | skip_cleanup: true 27 | on: 28 | branch: master 29 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Druidry - a Java Druid Client 2 | Copyright 2018-present ZAPR Media Labs 3 | 4 | This product includes software developed at 5 | ZAPR Media Labs (https://www.zapr.in/) 6 | 7 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/CardinalityAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.aggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import java.util.List; 22 | 23 | import lombok.Builder; 24 | import lombok.EqualsAndHashCode; 25 | import lombok.Getter; 26 | import lombok.NonNull; 27 | 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @Getter 30 | @EqualsAndHashCode(callSuper = true) 31 | public class CardinalityAggregator extends DruidAggregator { 32 | 33 | private static final String CARDINALITY_AGGREGATOR_TYPE = "cardinality"; 34 | private List fields; 35 | private Boolean byRow; 36 | 37 | @Builder 38 | private CardinalityAggregator(@NonNull String name, @NonNull List fields, Boolean byRow) { 39 | this.type = CARDINALITY_AGGREGATOR_TYPE; 40 | this.name = name; 41 | this.fields = fields; 42 | this.byRow = byRow; 43 | } 44 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/CountAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.aggregator; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.NonNull; 21 | 22 | @EqualsAndHashCode(callSuper = true) 23 | public class CountAggregator extends DruidAggregator { 24 | 25 | private static final String COUNT_TYPE_AGGREGATOR = "count"; 26 | 27 | public CountAggregator(@NonNull String name) { 28 | this.type = COUNT_TYPE_AGGREGATOR; 29 | this.name = name; 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/DoubleFirstAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package in.zapr.druid.druidry.aggregator; 17 | 18 | import lombok.EqualsAndHashCode; 19 | import lombok.Getter; 20 | import lombok.NonNull; 21 | 22 | @Getter 23 | @EqualsAndHashCode(callSuper = true) 24 | public class DoubleFirstAggregator extends DruidAggregator { 25 | private static final String DOUBLE_FIRST_AGGREGATOR = "doubleFirst"; 26 | private String fieldName; 27 | 28 | public DoubleFirstAggregator(@NonNull String name, @NonNull String fieldName) { 29 | this.type = DOUBLE_FIRST_AGGREGATOR; 30 | this.name = name; 31 | this.fieldName = fieldName; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/DoubleLastAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.aggregator; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class DoubleLastAggregator extends DruidAggregator { 26 | private static final String DOUBLE_LAST_AGGREGATOR = "doubleLast"; 27 | private String fieldName; 28 | 29 | public DoubleLastAggregator(@NonNull String name, @NonNull String fieldName) { 30 | this.type = DOUBLE_LAST_AGGREGATOR; 31 | this.name = name; 32 | this.fieldName = fieldName; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/DruidAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.aggregator; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | 22 | @Getter 23 | @EqualsAndHashCode 24 | public abstract class DruidAggregator { 25 | 26 | protected String type; 27 | protected String name; 28 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/FilteredAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.aggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.filter.DruidFilter; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NonNull; 25 | 26 | @Getter 27 | @JsonInclude(JsonInclude.Include.NON_NULL) 28 | @EqualsAndHashCode(callSuper = true) 29 | public class FilteredAggregator extends DruidAggregator { 30 | 31 | private static final String FILTERED_AGGREGATOR_TYPE = "filtered"; 32 | 33 | private DruidFilter filter; 34 | private DruidAggregator aggregator; 35 | 36 | public FilteredAggregator(@NonNull DruidFilter filter, @NonNull DruidAggregator aggregator) { 37 | this.type = FILTERED_AGGREGATOR_TYPE; 38 | this.filter = filter; 39 | this.aggregator = aggregator; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/FloatFirstAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package in.zapr.druid.druidry.aggregator; 17 | 18 | import lombok.EqualsAndHashCode; 19 | import lombok.Getter; 20 | import lombok.NonNull; 21 | 22 | @Getter 23 | @EqualsAndHashCode(callSuper = true) 24 | public class FloatFirstAggregator extends DruidAggregator { 25 | private static final String FLOAT_FIRST_AGGREGATOR = "floatFirst"; 26 | private String fieldName; 27 | 28 | public FloatFirstAggregator(@NonNull String name, @NonNull String fieldName) { 29 | this.type = FLOAT_FIRST_AGGREGATOR; 30 | this.name = name; 31 | this.fieldName = fieldName; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/FloatLastAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package in.zapr.druid.druidry.aggregator; 17 | 18 | import lombok.EqualsAndHashCode; 19 | import lombok.Getter; 20 | import lombok.NonNull; 21 | 22 | @Getter 23 | @EqualsAndHashCode(callSuper = true) 24 | public class FloatLastAggregator extends DruidAggregator { 25 | private static final String FLOAT_LAST_AGGREGATOR = "floatLast"; 26 | private String fieldName; 27 | 28 | public FloatLastAggregator(@NonNull String name, @NonNull String fieldName) { 29 | this.type = FLOAT_LAST_AGGREGATOR; 30 | this.name = name; 31 | this.fieldName = fieldName; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/HyperUniqueAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.aggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import lombok.Builder; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NonNull; 25 | 26 | @Getter 27 | @EqualsAndHashCode(callSuper = true) 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | public class HyperUniqueAggregator extends DruidAggregator { 30 | 31 | private static final String HYPER_UNIQUE_TYPE_AGGREGATOR = "hyperUnique"; 32 | private String fieldName; 33 | private Boolean round; 34 | 35 | @Deprecated 36 | public HyperUniqueAggregator(@NonNull String name, @NonNull String fieldName) { 37 | this.type = HYPER_UNIQUE_TYPE_AGGREGATOR; 38 | this.name = name; 39 | this.fieldName = fieldName; 40 | } 41 | 42 | @Builder 43 | private HyperUniqueAggregator(@NonNull String name, @NonNull String fieldName, Boolean round) { 44 | this.type = HYPER_UNIQUE_TYPE_AGGREGATOR; 45 | this.name = name; 46 | this.fieldName = fieldName; 47 | this.round = round; 48 | } 49 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/LongFirstAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.aggregator; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class LongFirstAggregator extends DruidAggregator { 26 | private static final String LONG_FIRST_AGGREGATOR = "longFirst"; 27 | private String fieldName; 28 | 29 | public LongFirstAggregator(@NonNull String name, @NonNull String fieldName) { 30 | this.type = LONG_FIRST_AGGREGATOR; 31 | this.name = name; 32 | this.fieldName = fieldName; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/LongLastAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.aggregator; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class LongLastAggregator extends DruidAggregator { 26 | private static final String LONG_LAST_AGGREGATOR = "longLast"; 27 | private String fieldName; 28 | 29 | public LongLastAggregator(@NonNull String name, @NonNull String fieldName) { 30 | this.type = LONG_LAST_AGGREGATOR; 31 | this.name = name; 32 | this.fieldName = fieldName; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/StringFirstAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.aggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import lombok.Builder; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NonNull; 25 | 26 | @Getter 27 | @EqualsAndHashCode(callSuper = true) 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | public class StringFirstAggregator extends DruidAggregator { 30 | 31 | private static final String STRING_FIRST_TYPE = "stringFirst"; 32 | 33 | private String fieldName; 34 | private Integer maxStringBytes; 35 | 36 | @Builder 37 | private StringFirstAggregator(@NonNull String name, @NonNull String fieldName, 38 | Integer maxStringBytes) { 39 | this.type = STRING_FIRST_TYPE; 40 | this.name = name; 41 | this.fieldName = fieldName; 42 | this.maxStringBytes = maxStringBytes; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/aggregator/StringLastAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.aggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import lombok.Builder; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NonNull; 25 | 26 | @Getter 27 | @EqualsAndHashCode(callSuper = true) 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | public class StringLastAggregator extends DruidAggregator { 30 | 31 | private static final String STRING_LAST_TYPE = "stringLast"; 32 | 33 | private String fieldName; 34 | private Integer maxStringBytes; 35 | 36 | @Builder 37 | private StringLastAggregator(@NonNull String name, @NonNull String fieldName, 38 | Integer maxStringBytes) { 39 | this.type = STRING_LAST_TYPE; 40 | this.name = name; 41 | this.fieldName = fieldName; 42 | this.maxStringBytes = maxStringBytes; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/averager/DoubleMaxAverager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.averager; 18 | 19 | import lombok.Builder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class DoubleMaxAverager extends DruidAverager { 27 | 28 | private static final String DOUBLE_MAX_AVERAGER = "doubleMax"; 29 | 30 | @Builder 31 | private DoubleMaxAverager(@NonNull String name, @NonNull String fieldName, 32 | @NonNull Integer buckets, Integer cycleSize) { 33 | super(DOUBLE_MAX_AVERAGER, name, fieldName, buckets, cycleSize); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/averager/DoubleMeanAverager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.averager; 18 | 19 | import lombok.Builder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class DoubleMeanAverager extends DruidAverager { 27 | 28 | private static final String DOUBLE_MEAN_AVERAGER = "doubleMean"; 29 | 30 | @Builder 31 | private DoubleMeanAverager(@NonNull String name, @NonNull String fieldName, 32 | @NonNull Integer buckets, Integer cycleSize) { 33 | super(DOUBLE_MEAN_AVERAGER, name, fieldName, buckets, cycleSize); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/averager/DoubleMeanNoNullsAverager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.averager; 18 | 19 | import lombok.Builder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class DoubleMeanNoNullsAverager extends DruidAverager { 27 | 28 | private static final String DOUBLE_MEAN_NO_NULLS_AVERAGER = "doubleMeanNoNulls"; 29 | 30 | @Builder 31 | private DoubleMeanNoNullsAverager(@NonNull String name, @NonNull String fieldName, 32 | @NonNull Integer buckets, Integer cycleSize) { 33 | super(DOUBLE_MEAN_NO_NULLS_AVERAGER, name, fieldName, buckets, cycleSize); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/averager/DoubleMinAverager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.averager; 18 | 19 | import lombok.Builder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class DoubleMinAverager extends DruidAverager { 27 | 28 | private static final String DOUBLE_MIN_AVERAGER = "doubleMin"; 29 | 30 | @Builder 31 | private DoubleMinAverager(@NonNull String name, @NonNull String fieldName, 32 | @NonNull Integer buckets, Integer cycleSize) { 33 | super(DOUBLE_MIN_AVERAGER, name, fieldName, buckets, cycleSize); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/averager/DoubleSumAverager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.averager; 18 | 19 | import lombok.Builder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class DoubleSumAverager extends DruidAverager { 27 | 28 | private static final String DOUBLE_SUM_AVERAGER = "doubleSum"; 29 | 30 | @Builder 31 | private DoubleSumAverager(@NonNull String name, @NonNull String fieldName, 32 | @NonNull Integer buckets, Integer cycleSize) { 33 | super(DOUBLE_SUM_AVERAGER, name, fieldName, buckets, cycleSize); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/averager/DruidAverager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 19 | * 20 | * Licensed under the Apache License, Version 2.0 (the "License"); 21 | * you may not use this file except in compliance with the License. 22 | * You may obtain a copy of the License at 23 | * 24 | * http://www.apache.org/licenses/LICENSE-2.0 25 | * 26 | * Unless required by applicable law or agreed to in writing, software 27 | * distributed under the License is distributed on an "AS IS" BASIS, 28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | * See the License for the specific language governing permissions and 30 | * limitations under the License. 31 | */ 32 | 33 | package in.zapr.druid.druidry.averager; 34 | 35 | import com.fasterxml.jackson.annotation.JsonInclude; 36 | import lombok.AllArgsConstructor; 37 | import lombok.EqualsAndHashCode; 38 | import lombok.Getter; 39 | 40 | @Getter 41 | @EqualsAndHashCode 42 | @AllArgsConstructor 43 | @JsonInclude(JsonInclude.Include.NON_NULL) 44 | public abstract class DruidAverager { 45 | 46 | protected String type; 47 | protected String name; 48 | protected String fieldName; 49 | protected Integer buckets; 50 | protected Integer cycleSize; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/averager/LongMaxAverager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.averager; 18 | 19 | import lombok.Builder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class LongMaxAverager extends DruidAverager { 27 | 28 | private static final String LONG_MAX_AVERAGER = "longMax"; 29 | 30 | @Builder 31 | private LongMaxAverager(@NonNull String name, @NonNull String fieldName, 32 | @NonNull Integer buckets, Integer cycleSize) { 33 | super(LONG_MAX_AVERAGER, name, fieldName, buckets, cycleSize); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/averager/LongMeanAverager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.averager; 18 | 19 | import lombok.Builder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class LongMeanAverager extends DruidAverager { 27 | 28 | private static final String LONG_MEAN_AVERAGER = "longMean"; 29 | 30 | @Builder 31 | private LongMeanAverager(@NonNull String name, @NonNull String fieldName, 32 | @NonNull Integer buckets, Integer cycleSize) { 33 | super(LONG_MEAN_AVERAGER, name, fieldName, buckets, cycleSize); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/averager/LongMeanNoNullsAverager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.averager; 18 | 19 | import lombok.Builder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class LongMeanNoNullsAverager extends DruidAverager { 27 | 28 | private static final String LONG_MEAN_NO_NULLS_AVERAGER = "longMeanNoNulls"; 29 | 30 | @Builder 31 | private LongMeanNoNullsAverager(@NonNull String name, @NonNull String fieldName, 32 | @NonNull Integer buckets, Integer cycleSize) { 33 | super(LONG_MEAN_NO_NULLS_AVERAGER, name, fieldName, buckets, cycleSize); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/averager/LongMinAverager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.averager; 18 | 19 | import lombok.Builder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class LongMinAverager extends DruidAverager { 27 | 28 | private static final String LONG_MIN_AVERAGER = "longMin"; 29 | 30 | @Builder 31 | private LongMinAverager(@NonNull String name, @NonNull String fieldName, 32 | @NonNull Integer buckets, Integer cycleSize) { 33 | super(LONG_MIN_AVERAGER, name, fieldName, buckets, cycleSize); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/averager/LongSumAverager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.averager; 18 | 19 | import lombok.Builder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class LongSumAverager extends DruidAverager { 27 | 28 | private static final String LONG_SUM_AVERAGER = "longSum"; 29 | 30 | @Builder 31 | private LongSumAverager(@NonNull String name, @NonNull String fieldName, 32 | @NonNull Integer buckets, Integer cycleSize) { 33 | super(LONG_SUM_AVERAGER, name, fieldName, buckets, cycleSize); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/client/DruidError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.client; 18 | 19 | import lombok.Getter; 20 | 21 | @Getter 22 | public class DruidError { 23 | 24 | private String error; 25 | private String errorMessage; 26 | private String errorClass; 27 | private String host; 28 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/client/DruidQueryProtocol.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.client; 18 | 19 | public enum DruidQueryProtocol { 20 | HTTP("http"), 21 | HTTPS("https"); 22 | 23 | private String protocol; 24 | 25 | DruidQueryProtocol(String protocol) { 26 | this.protocol = protocol; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return this.protocol; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/client/exception/ConnectionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.client.exception; 18 | 19 | public class ConnectionException extends DruidryException { 20 | public ConnectionException(Exception e) { 21 | super(e); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/client/exception/DruidryException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.client.exception; 18 | 19 | public class DruidryException extends Exception { 20 | 21 | protected DruidryException(Exception e) { 22 | super(e); 23 | } 24 | 25 | protected DruidryException(String message) { 26 | super(message); 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/client/exception/QueryException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.client.exception; 18 | 19 | import in.zapr.druid.druidry.client.DruidError; 20 | import lombok.Getter; 21 | 22 | public class QueryException extends DruidryException { 23 | 24 | @Getter 25 | private DruidError druidError; 26 | 27 | public QueryException(Exception e) { 28 | super(e); 29 | } 30 | 31 | public QueryException(String message) { 32 | super(message); 33 | } 34 | 35 | public QueryException(DruidError error) { 36 | super(error.getErrorMessage()); 37 | this.druidError = error; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dataSource/DataSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dataSource; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | /** 26 | * Generate datasource for druid query. See documentation 27 | * 28 | * http://druid.io/docs/latest/querying/datasource.html 29 | * 30 | */ 31 | @Getter 32 | @JsonInclude(JsonInclude.Include.NON_NULL) 33 | @EqualsAndHashCode 34 | public abstract class DataSource { 35 | 36 | @NonNull 37 | protected DataSourceType type; 38 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dataSource/DataSourceType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dataSource; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum DataSourceType { 22 | 23 | TABLE("table"), 24 | UNION("union"), 25 | QUERY("query"); 26 | 27 | private String value; 28 | 29 | DataSourceType(String value) { 30 | this.value = value; 31 | } 32 | 33 | @JsonValue 34 | public String getQueryType() { 35 | return value; 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dataSource/QueryDataSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dataSource; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.query.DruidQuery; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode(callSuper = true) 30 | public class QueryDataSource extends DataSource { 31 | 32 | @NonNull 33 | private DruidQuery query; 34 | 35 | @Builder 36 | public QueryDataSource(@NonNull DruidQuery query) { 37 | this.type = DataSourceType.QUERY; 38 | this.query = query; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dataSource/TableDataSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dataSource; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import lombok.Builder; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NonNull; 25 | 26 | @Getter 27 | @JsonInclude(JsonInclude.Include.NON_NULL) 28 | @EqualsAndHashCode(callSuper = true) 29 | public class TableDataSource extends DataSource { 30 | 31 | @NonNull 32 | private String name; 33 | 34 | @Builder 35 | public TableDataSource(@NonNull String name) { 36 | this.type = DataSourceType.TABLE; 37 | this.name = name; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dataSource/UnionDataSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dataSource; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import java.util.List; 22 | 23 | import lombok.Builder; 24 | import lombok.EqualsAndHashCode; 25 | import lombok.Getter; 26 | import lombok.NonNull; 27 | 28 | @Getter 29 | @JsonInclude(JsonInclude.Include.NON_NULL) 30 | @EqualsAndHashCode(callSuper = true) 31 | public class UnionDataSource extends DataSource { 32 | 33 | @NonNull 34 | private List dataSources; 35 | 36 | @Builder 37 | public UnionDataSource(@NonNull List dataSources) { 38 | this.type = DataSourceType.UNION; 39 | this.dataSources = dataSources; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dimension/DefaultDimension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dimension; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.dimension.enums.OutputType; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode(callSuper = true) 30 | public class DefaultDimension extends DimensionSpec { 31 | 32 | private static final String DEFAULT_TYPE = "default"; 33 | 34 | @Builder 35 | public DefaultDimension(@NonNull String dimension, @NonNull String outputName, 36 | OutputType outputType) { 37 | this.type = DefaultDimension.DEFAULT_TYPE; 38 | this.dimension = dimension; 39 | this.outputName = outputName; 40 | this.outputType = outputType; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dimension/DimensionSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dimension; 18 | 19 | import in.zapr.druid.druidry.dimension.enums.OutputType; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public abstract class DimensionSpec extends DruidDimension { 27 | 28 | @NonNull 29 | protected String type; 30 | 31 | @NonNull 32 | protected String dimension; 33 | 34 | @NonNull 35 | protected String outputName; 36 | 37 | protected OutputType outputType; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dimension/DruidDimension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dimension; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | 22 | @Getter 23 | @EqualsAndHashCode 24 | public abstract class DruidDimension { 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dimension/FilteredDimension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dimension; 18 | 19 | import in.zapr.druid.druidry.dimension.enums.FilteredDimensionType; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public abstract class FilteredDimension extends DruidDimension { 27 | @NonNull 28 | protected DimensionSpec delegate; 29 | @NonNull 30 | protected FilteredDimensionType type; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dimension/ListFilteredDimension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dimension; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | 22 | import java.util.List; 23 | 24 | import in.zapr.druid.druidry.dimension.enums.FilteredDimensionType; 25 | import lombok.Builder; 26 | import lombok.EqualsAndHashCode; 27 | import lombok.Getter; 28 | import lombok.NonNull; 29 | 30 | @Getter 31 | @JsonInclude(JsonInclude.Include.NON_NULL) 32 | @EqualsAndHashCode(callSuper = true) 33 | public class ListFilteredDimension extends FilteredDimension { 34 | private List values; 35 | @JsonProperty(value = "isWhitelist") 36 | private Boolean whitelist; 37 | 38 | @Builder 39 | public ListFilteredDimension(@NonNull DimensionSpec dimensionSpec, @NonNull List values, Boolean whitelist) { 40 | this.delegate = dimensionSpec; 41 | this.type = FilteredDimensionType.LIST_FILTERED; 42 | this.values = values; 43 | this.whitelist = whitelist; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dimension/PrefixFilteredDimension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dimension; 18 | 19 | 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | 22 | import in.zapr.druid.druidry.dimension.enums.FilteredDimensionType; 23 | import lombok.Builder; 24 | import lombok.EqualsAndHashCode; 25 | import lombok.Getter; 26 | import lombok.NonNull; 27 | 28 | @Getter 29 | @JsonInclude(JsonInclude.Include.NON_NULL) 30 | @EqualsAndHashCode(callSuper = true) 31 | public class PrefixFilteredDimension extends FilteredDimension { 32 | private String prefix; 33 | 34 | @Builder 35 | public PrefixFilteredDimension(@NonNull DimensionSpec dimensionSpec, @NonNull String prefix) { 36 | this.prefix = prefix; 37 | this.delegate = dimensionSpec; 38 | this.type = FilteredDimensionType.PREFIX_FILTERED; 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dimension/RegexFilteredDimension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dimension; 18 | 19 | 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | 22 | import in.zapr.druid.druidry.dimension.enums.FilteredDimensionType; 23 | import lombok.Builder; 24 | import lombok.EqualsAndHashCode; 25 | import lombok.Getter; 26 | import lombok.NonNull; 27 | 28 | @Getter 29 | @JsonInclude(JsonInclude.Include.NON_NULL) 30 | @EqualsAndHashCode(callSuper = true) 31 | public class RegexFilteredDimension extends FilteredDimension { 32 | private String pattern; 33 | 34 | @Builder 35 | public RegexFilteredDimension(@NonNull DimensionSpec dimensionSpec, @NonNull String pattern) { 36 | this.pattern = pattern; 37 | this.delegate = dimensionSpec; 38 | this.type = FilteredDimensionType.REGEX_FILTERED; 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dimension/SimpleDimension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dimension; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | import lombok.EqualsAndHashCode; 22 | 23 | @EqualsAndHashCode(callSuper = true) 24 | public class SimpleDimension extends DruidDimension { 25 | 26 | private String dimension; 27 | 28 | public SimpleDimension(String dimension) { 29 | this.dimension = dimension; 30 | } 31 | 32 | @JsonValue 33 | public String getDimension() { 34 | return this.dimension; 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dimension/enums/FilteredDimensionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dimension.enums; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | public enum FilteredDimensionType { 22 | 23 | @JsonProperty(value = "listFiltered") 24 | LIST_FILTERED, 25 | @JsonProperty(value = "regexFiltered") 26 | REGEX_FILTERED, 27 | @JsonProperty(value = "prefixFiltered") 28 | PREFIX_FILTERED 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/dimension/enums/OutputType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.dimension.enums; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum OutputType { 22 | STRING, LONG, FLOAT, DOUBLE; 23 | 24 | @JsonValue 25 | public String getName() { 26 | return this.name(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/aggregator/TargetHllType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.aggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum TargetHllType { 22 | 23 | HLL_4("HLL_4"), 24 | HLL_6("HLL_6"), 25 | HLL_8("HLL_8"); 26 | 27 | private String value; 28 | 29 | TargetHllType(String value) { 30 | this.value = value; 31 | } 32 | 33 | @JsonValue 34 | public String getValue() { 35 | return value; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchEstimateWithBoundsPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode(callSuper = true) 30 | public class HllSketchEstimateWithBoundsPostAggregator extends DruidPostAggregator { 31 | 32 | private static final String HLL_SKETCH_ESTIMATE_WITH_BOUNDS_POST_AGGREGATOR_TYPE = "HLLSketchEstimateWithBounds"; 33 | private DruidPostAggregator field; 34 | private Integer numStdDev; 35 | 36 | @Builder 37 | private HllSketchEstimateWithBoundsPostAggregator(@NonNull String name, 38 | @NonNull DruidPostAggregator field, 39 | Integer numStdDev) { 40 | this.type = HLL_SKETCH_ESTIMATE_WITH_BOUNDS_POST_AGGREGATOR_TYPE; 41 | this.name = name; 42 | this.field = field; 43 | this.numStdDev = numStdDev; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/HllSketchToStringPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode(callSuper = true) 30 | public class HllSketchToStringPostAggregator extends DruidPostAggregator { 31 | 32 | private static final String HLL_SKETCH_TO_STRING_POST_AGGREGATOR_TYPE = "HLLSketchToString"; 33 | private DruidPostAggregator field; 34 | 35 | @Builder 36 | private HllSketchToStringPostAggregator(@NonNull String name, 37 | @NonNull DruidPostAggregator field) { 38 | this.type = HLL_SKETCH_TO_STRING_POST_AGGREGATOR_TYPE; 39 | this.name = name; 40 | this.field = field; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToQuantilePostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode(callSuper = true) 30 | public class QuantilesSketchToQuantilePostAggregator extends DruidPostAggregator { 31 | 32 | private static final String QUANTILES_SKETCH_TO_QUANTILE_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToQuantile"; 33 | private DruidPostAggregator field; 34 | private Double fraction; 35 | 36 | @Builder 37 | private QuantilesSketchToQuantilePostAggregator(@NonNull String name, 38 | @NonNull DruidPostAggregator field, 39 | @NonNull Double fraction) { 40 | this.type = QUANTILES_SKETCH_TO_QUANTILE_POST_AGGREGATOR_TYPE; 41 | this.name = name; 42 | this.field = field; 43 | this.fraction = fraction; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/QuantilesSketchToStringPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode(callSuper = true) 30 | public class QuantilesSketchToStringPostAggregator extends DruidPostAggregator { 31 | 32 | private static final String QUANTILES_SKETCH_TO_STRING_POST_AGGREGATOR_TYPE = "quantilesDoublesSketchToString"; 33 | private DruidPostAggregator field; 34 | 35 | @Builder 36 | private QuantilesSketchToStringPostAggregator(@NonNull String name, 37 | @NonNull DruidPostAggregator field) { 38 | this.type = QUANTILES_SKETCH_TO_STRING_POST_AGGREGATOR_TYPE; 39 | this.name = name; 40 | this.field = field; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/ThetaSketchFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum ThetaSketchFunction { 22 | 23 | INTERSECT("INTERSECT"), 24 | UNION("UNION"), 25 | NOT("NOT"); 26 | 27 | private String value; 28 | 29 | ThetaSketchFunction(String value) { 30 | this.value = value; 31 | } 32 | 33 | @JsonValue 34 | public String getValue() { 35 | return value; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum TupleSketchOperation { 22 | 23 | INTERSECT("INTERSECT"), 24 | UNION("UNION"), 25 | NOT("NOT"); 26 | 27 | private String value; 28 | 29 | TupleSketchOperation(String value) { 30 | this.value = value; 31 | } 32 | 33 | @JsonValue 34 | public String getValue() { 35 | return value; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchTTestPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import java.util.List; 22 | 23 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 24 | import lombok.Builder; 25 | import lombok.EqualsAndHashCode; 26 | import lombok.Getter; 27 | import lombok.NonNull; 28 | 29 | @Getter 30 | @JsonInclude(JsonInclude.Include.NON_NULL) 31 | @EqualsAndHashCode(callSuper = true) 32 | public class TupleSketchTTestPostAggregator extends DruidPostAggregator { 33 | 34 | private static final String TUPLE_SKETCH_TTEST_AGGREGATOR_TYPE = "arrayOfDoublesSketchTTest"; 35 | private List fields; 36 | 37 | @Builder 38 | private TupleSketchTTestPostAggregator(@NonNull String name, 39 | @NonNull List fields) { 40 | this.type = TUPLE_SKETCH_TTEST_AGGREGATOR_TYPE; 41 | this.name = name; 42 | this.fields = fields; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToEstimatePostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode(callSuper = true) 30 | public class TupleSketchToEstimatePostAggregator extends DruidPostAggregator { 31 | 32 | private static final String TUPLE_SKETCH_TO_ESTIMATE_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToEstimate"; 33 | private DruidPostAggregator field; 34 | 35 | @Builder 36 | private TupleSketchToEstimatePostAggregator(@NonNull String name, 37 | @NonNull DruidPostAggregator field) { 38 | this.type = TUPLE_SKETCH_TO_ESTIMATE_POST_AGGREGATOR_TYPE; 39 | this.name = name; 40 | this.field = field; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToMeansPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode(callSuper = true) 30 | public class TupleSketchToMeansPostAggregator extends DruidPostAggregator { 31 | 32 | private static final String TUPLE_SKETCH_TO_MEANS_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToMeans"; 33 | private DruidPostAggregator field; 34 | 35 | @Builder 36 | private TupleSketchToMeansPostAggregator(@NonNull String name, 37 | @NonNull DruidPostAggregator field) { 38 | this.type = TUPLE_SKETCH_TO_MEANS_POST_AGGREGATOR_TYPE; 39 | this.name = name; 40 | this.field = field; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToNumEntriesPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode(callSuper = true) 30 | public class TupleSketchToNumEntriesPostAggregator extends DruidPostAggregator { 31 | 32 | private static final String TUPLE_SKETCH_TO_NUM_ENTRIES_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToNumEntries"; 33 | private DruidPostAggregator field; 34 | 35 | @Builder 36 | private TupleSketchToNumEntriesPostAggregator(@NonNull String name, 37 | @NonNull DruidPostAggregator field) { 38 | this.type = TUPLE_SKETCH_TO_NUM_ENTRIES_POST_AGGREGATOR_TYPE; 39 | this.name = name; 40 | this.field = field; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToStringPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode(callSuper = true) 30 | public class TupleSketchToStringPostAggregator extends DruidPostAggregator { 31 | 32 | private static final String TUPLE_SKETCH_TO_STRING_AGGREGATOR_TYPE = "arrayOfDoublesSketchToString"; 33 | private DruidPostAggregator field; 34 | 35 | @Builder 36 | private TupleSketchToStringPostAggregator(@NonNull String name, 37 | @NonNull DruidPostAggregator field) { 38 | this.type = TUPLE_SKETCH_TO_STRING_AGGREGATOR_TYPE; 39 | this.name = name; 40 | this.field = field; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/datasketches/postAggregator/TupleSketchToVariancesPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.datasketches.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode(callSuper = true) 30 | public class TupleSketchToVariancesPostAggregator extends DruidPostAggregator { 31 | 32 | private static final String TUPLE_SKETCH_TO_VARIANCES_POST_AGGREGATOR_TYPE = "arrayOfDoublesSketchToVariances"; 33 | private DruidPostAggregator field; 34 | 35 | @Builder 36 | private TupleSketchToVariancesPostAggregator(@NonNull String name, 37 | @NonNull DruidPostAggregator field) { 38 | this.type = TUPLE_SKETCH_TO_VARIANCES_POST_AGGREGATOR_TYPE; 39 | this.name = name; 40 | this.field = field; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/distinctcount/aggregator/DistinctCountAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.distinctcount.aggregator; 18 | 19 | import in.zapr.druid.druidry.aggregator.DruidAggregator; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class DistinctCountAggregator extends DruidAggregator { 27 | 28 | private static final String DISTINCT_COUNT_AGGREGATOR_TYPE = "distinctCount"; 29 | private String fieldName; 30 | 31 | public DistinctCountAggregator(@NonNull String name, @NonNull String fieldName) { 32 | this.type = DISTINCT_COUNT_AGGREGATOR_TYPE; 33 | this.name = name; 34 | this.fieldName = fieldName; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/histogram/aggregator/QuantilePostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.histogram.aggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 22 | import lombok.Builder; 23 | import lombok.Getter; 24 | import lombok.NonNull; 25 | 26 | @Getter 27 | @JsonInclude(JsonInclude.Include.NON_NULL) 28 | public class QuantilePostAggregator extends DruidPostAggregator { 29 | 30 | private static final String QUANTILE_POST_AGGREGATOR_TYPE = "quantile"; 31 | private String fieldName; 32 | private Float probability; 33 | 34 | @Builder 35 | private QuantilePostAggregator(@NonNull String name, @NonNull String fieldName, 36 | @NonNull Float probability) { 37 | this.type = QUANTILE_POST_AGGREGATOR_TYPE; 38 | this.name = name; 39 | this.fieldName = fieldName; 40 | this.probability = probability; 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/histogram/postAggregator/CustomBucketsPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.histogram.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import java.util.Set; 22 | 23 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 24 | import lombok.Builder; 25 | import lombok.Getter; 26 | import lombok.NonNull; 27 | 28 | @Getter 29 | @JsonInclude(JsonInclude.Include.NON_NULL) 30 | public class CustomBucketsPostAggregator extends DruidPostAggregator { 31 | 32 | private static final String CUSTOMBUCKET_POST_AGGREGATOR_TYPE = "customBuckets"; 33 | private String fieldName; 34 | private Set breaks; 35 | 36 | @Builder 37 | private CustomBucketsPostAggregator(@NonNull String name, @NonNull String fieldName, 38 | @NonNull Set breaks) { 39 | this.type = CUSTOMBUCKET_POST_AGGREGATOR_TYPE; 40 | this.name = name; 41 | this.fieldName = fieldName; 42 | this.breaks = breaks; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/histogram/postAggregator/EqualBucketsPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.histogram.postAggregator; 18 | 19 | import com.google.common.base.Preconditions; 20 | 21 | import com.fasterxml.jackson.annotation.JsonInclude; 22 | import com.fasterxml.jackson.annotation.JsonProperty; 23 | 24 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 25 | import lombok.Getter; 26 | import lombok.NonNull; 27 | 28 | @Getter 29 | @JsonInclude(JsonInclude.Include.NON_NULL) 30 | public class EqualBucketsPostAggregator extends DruidPostAggregator { 31 | private static final String EQUAL_BUCKET_POST_AGGREGATOR_TYPE = "equalBuckets"; 32 | private String fieldName; 33 | @JsonProperty("numBuckets") 34 | private Integer numberOfBuckets; 35 | 36 | public EqualBucketsPostAggregator(@NonNull String name, @NonNull String fieldName, 37 | @NonNull Integer numberOfBuckets) { 38 | Preconditions.checkArgument(numberOfBuckets > 1, 39 | "numberOfBuckets should be greater than 1"); 40 | 41 | this.type = EQUAL_BUCKET_POST_AGGREGATOR_TYPE; 42 | this.name = name; 43 | this.fieldName = fieldName; 44 | this.numberOfBuckets = numberOfBuckets; 45 | } 46 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/histogram/postAggregator/MaxPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.histogram.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @JsonInclude(JsonInclude.Include.NON_NULL) 27 | public class MaxPostAggregator extends DruidPostAggregator { 28 | 29 | private static final String MAX_POST_AGGREGATOR_TYPE = "max"; 30 | private String fieldName; 31 | 32 | public MaxPostAggregator(@NonNull String name, @NonNull String fieldName) { 33 | this.type = MAX_POST_AGGREGATOR_TYPE; 34 | this.name = name; 35 | this.fieldName = fieldName; 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/histogram/postAggregator/MinPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.histogram.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @JsonInclude(JsonInclude.Include.NON_NULL) 27 | public class MinPostAggregator extends DruidPostAggregator { 28 | 29 | private static final String MIN_POST_AGGREGATOR_TYPE = "min"; 30 | private String fieldName; 31 | 32 | public MinPostAggregator(@NonNull String name, @NonNull String fieldName) { 33 | this.type = MIN_POST_AGGREGATOR_TYPE; 34 | this.name = name; 35 | this.fieldName = fieldName; 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/histogram/postAggregator/QuantilePostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.histogram.postAggregator; 18 | 19 | import com.google.common.base.Preconditions; 20 | 21 | import com.fasterxml.jackson.annotation.JsonInclude; 22 | 23 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 24 | import lombok.Builder; 25 | import lombok.Getter; 26 | import lombok.NonNull; 27 | 28 | @Getter 29 | @JsonInclude(JsonInclude.Include.NON_NULL) 30 | public class QuantilePostAggregator extends DruidPostAggregator { 31 | 32 | private static final String QUANTILE_POST_AGGREGATOR_TYPE = "quantile"; 33 | private String fieldName; 34 | private Float probability; 35 | 36 | @Builder 37 | private QuantilePostAggregator(@NonNull String name, @NonNull String fieldName, 38 | @NonNull Float probability) { 39 | 40 | Preconditions.checkArgument(probability >= 0f && probability <= 1f, 41 | "Probability should lie between 0 and 1"); 42 | 43 | this.type = QUANTILE_POST_AGGREGATOR_TYPE; 44 | this.name = name; 45 | this.fieldName = fieldName; 46 | this.probability = probability; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extensions/histogram/postAggregator/QuantilesPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extensions.histogram.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import java.util.Set; 22 | 23 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 24 | import lombok.Builder; 25 | import lombok.Getter; 26 | import lombok.NonNull; 27 | 28 | @Getter 29 | @JsonInclude(JsonInclude.Include.NON_NULL) 30 | public class QuantilesPostAggregator extends DruidPostAggregator { 31 | 32 | private static final String QUANTILE_POST_AGGREGATOR_TYPE = "quantiles"; 33 | private String fieldName; 34 | private Set probabilities; 35 | 36 | @Builder 37 | private QuantilesPostAggregator(@NonNull String name, @NonNull String fieldName, 38 | @NonNull Set probabilities) { 39 | this.type = QUANTILE_POST_AGGREGATOR_TYPE; 40 | this.name = name; 41 | this.fieldName = fieldName; 42 | this.probabilities = probabilities; 43 | } 44 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/CascadeExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import java.util.List; 20 | 21 | import lombok.Builder; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | public class CascadeExtractionFunction extends ExtractionFunction { 27 | 28 | private List extractionFns; 29 | 30 | @Builder 31 | private CascadeExtractionFunction(@NonNull List extractionFns) { 32 | this.type = ExtractionFunction.CASCADE_TYPE; 33 | this.extractionFns = extractionFns; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/ExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode 25 | public abstract class ExtractionFunction { 26 | protected static final String REGEX_TYPE = "regex"; 27 | protected static final String PARTIAL_TYPE = "partial"; 28 | protected static final String SEARCH_QUERY_TYPE = "searchQuery"; 29 | protected static final String SUB_STRING_TYPE = "substring"; 30 | protected static final String STRING_LENGTH_TYPE = "strlen"; 31 | protected static final String TIME_FORMAT_TYPE = "timeFormat"; 32 | protected static final String TIME_PARSING_TYPE = "time"; 33 | protected static final String JAVASCRIPT_TYPE = "javascript"; 34 | protected static final String LOOPUP_TYPE = "lookup"; 35 | 36 | // todo: bottom 3 are left to code. Also check for timeZone in timeformat type. lookup is also left 37 | protected static final String REGISTERED_LOOKUP_TYPE = "registeredLookup"; 38 | protected static final String CASCADE_TYPE = "cascade"; 39 | protected static final String STRING_FORMAT_TYPE = "stringFormat"; 40 | 41 | @NonNull 42 | protected String type; 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/JavascriptExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import lombok.Builder; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @JsonInclude(JsonInclude.Include.NON_NULL) 27 | public class JavascriptExtractionFunction extends ExtractionFunction { 28 | 29 | private String function; 30 | private Boolean injective; 31 | 32 | @Builder 33 | private JavascriptExtractionFunction(@NonNull String function, Boolean injective) { 34 | this.type = JAVASCRIPT_TYPE; 35 | this.function = function; 36 | this.injective = injective; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/LookUpExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.lookUpSpec.LookUpSpec; 22 | import lombok.Builder; 23 | import lombok.Getter; 24 | 25 | @Getter 26 | @JsonInclude(JsonInclude.Include.NON_NULL) 27 | public class LookUpExtractionFunction extends ExtractionFunction { 28 | 29 | private LookUpSpec lookUp; 30 | private Boolean retainMissingValue; 31 | private Boolean injective; 32 | private String replaceMissingValueWith; 33 | private Boolean optimize; 34 | 35 | @Builder 36 | private LookUpExtractionFunction(LookUpSpec lookUp, Boolean retainMissingValue, Boolean injective, String 37 | replaceMissingValueWith, Boolean optimize) { 38 | this.type = ExtractionFunction.LOOPUP_TYPE; 39 | this.lookUp = lookUp; 40 | this.retainMissingValue = retainMissingValue; 41 | this.injective = injective; 42 | this.replaceMissingValueWith = replaceMissingValueWith; 43 | this.optimize = optimize; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/PartialExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import lombok.Builder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class PartialExtractionFunction extends ExtractionFunction { 27 | 28 | private String expr; 29 | 30 | @Builder 31 | private PartialExtractionFunction(@NonNull String expr) { 32 | this.type = PARTIAL_TYPE; 33 | this.expr = expr; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/RegexExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import lombok.Builder; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @JsonInclude(JsonInclude.Include.NON_NULL) 27 | public class RegexExtractionFunction extends ExtractionFunction { 28 | 29 | 30 | private String expr; 31 | private Boolean replaceMissingValue; 32 | private String replaceMissingValueWith; 33 | 34 | @Builder 35 | private RegexExtractionFunction(@NonNull String expr, 36 | Boolean replaceMissingValue, 37 | String replaceMissingValueWith) { 38 | this.type = REGEX_TYPE; 39 | this.expr = expr; 40 | this.replaceMissingValue = replaceMissingValue; 41 | this.replaceMissingValueWith = replaceMissingValueWith; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/RegisteredLookUpExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.lookUpSpec.LookUpSpec; 22 | import lombok.Builder; 23 | import lombok.Getter; 24 | 25 | @Getter 26 | @JsonInclude(JsonInclude.Include.NON_NULL) 27 | public class RegisteredLookUpExtractionFunction extends ExtractionFunction { 28 | 29 | private LookUpSpec lookUp; 30 | private Boolean retainMissingValue; 31 | private Boolean injective; 32 | private String replaceMissingValueWith; 33 | private Boolean optimize; 34 | 35 | @Builder 36 | private RegisteredLookUpExtractionFunction(LookUpSpec lookUp, Boolean retainMissingValue, Boolean injective, 37 | String replaceMissingValueWith, Boolean optimize) { 38 | this.type = ExtractionFunction.LOOPUP_TYPE; 39 | this.lookUp = lookUp; 40 | this.retainMissingValue = retainMissingValue; 41 | this.injective = injective; 42 | this.replaceMissingValueWith = replaceMissingValueWith; 43 | this.optimize = optimize; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/SearchQueryExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import in.zapr.druid.druidry.filter.searchQuerySpec.SearchQuerySpec; 20 | import lombok.Builder; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | public class SearchQueryExtractionFunction extends ExtractionFunction { 26 | 27 | private SearchQuerySpec query; 28 | 29 | @Builder 30 | private SearchQueryExtractionFunction(@NonNull SearchQuerySpec query) { 31 | this.type = SEARCH_QUERY_TYPE; 32 | this.query = query; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/StrLenExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import lombok.Builder; 20 | import lombok.Getter; 21 | 22 | @Getter 23 | public class StrLenExtractionFunction extends ExtractionFunction { 24 | 25 | @Builder 26 | private StrLenExtractionFunction() { 27 | this.type = ExtractionFunction.STRING_LENGTH_TYPE; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/StringFormatExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import lombok.Getter; 20 | 21 | @Getter 22 | public class StringFormatExtractionFunction extends ExtractionFunction { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/SubStringExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import lombok.Builder; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @JsonInclude(JsonInclude.Include.NON_NULL) 27 | public class SubStringExtractionFunction extends ExtractionFunction { 28 | private Integer index; 29 | private Integer length; 30 | 31 | @Builder 32 | private SubStringExtractionFunction(@NonNull Integer index, Integer length) { 33 | this.type = SUB_STRING_TYPE; 34 | this.index = index; 35 | this.length = length; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/TimeFormatExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import java.util.Locale; 22 | 23 | import in.zapr.druid.druidry.granularity.Granularity; 24 | import lombok.Builder; 25 | import lombok.Getter; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | public class TimeFormatExtractionFunction extends ExtractionFunction { 30 | 31 | private String format; 32 | 33 | private Locale locale; 34 | private Granularity granularity; 35 | private Boolean asMillis; 36 | 37 | // TODO: search for a timezone library 38 | private String timeZone; 39 | 40 | @Builder 41 | private TimeFormatExtractionFunction(String format, Locale locale, Granularity granularity, String 42 | timeZone, Boolean asMillis) { 43 | this.type = TIME_FORMAT_TYPE; 44 | this.format = format; 45 | this.locale = locale; 46 | this.granularity = granularity; 47 | this.timeZone = timeZone; 48 | this.asMillis = asMillis; 49 | 50 | } 51 | 52 | public String getLocale() { 53 | return locale == null ? null : locale.toLanguageTag(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/extractionFunctions/TimeParsingExtractionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import java.text.SimpleDateFormat; 22 | 23 | import lombok.Builder; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | public class TimeParsingExtractionFunction extends ExtractionFunction { 30 | 31 | private SimpleDateFormat timeFormat; 32 | private SimpleDateFormat resultFormat; 33 | 34 | @Builder 35 | private TimeParsingExtractionFunction(@NonNull SimpleDateFormat timeFormat, @NonNull SimpleDateFormat 36 | resultFormat) { 37 | this.type = TIME_PARSING_TYPE; 38 | this.timeFormat = timeFormat; 39 | this.resultFormat = resultFormat; 40 | } 41 | 42 | public String getTimeFormat() { 43 | return timeFormat.toPattern(); 44 | } 45 | 46 | public String getResultFormat() { 47 | return resultFormat.toPattern(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/AndFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter; 18 | 19 | import java.util.List; 20 | 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @EqualsAndHashCode(callSuper = true) 27 | public class AndFilter extends DruidFilter { 28 | 29 | private static String AND_DRUID_FILTER_TYPE = "and"; 30 | private List fields; 31 | 32 | public AndFilter(@NonNull List fields) { 33 | this.type = AND_DRUID_FILTER_TYPE; 34 | this.fields = fields; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/DruidFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | 22 | @Getter 23 | @EqualsAndHashCode 24 | public abstract class DruidFilter { 25 | protected String type; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/InFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter; 18 | 19 | import java.util.List; 20 | 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @EqualsAndHashCode(callSuper = true) 27 | public class InFilter extends DruidFilter { 28 | private static String IN_DRUID_FILTER_TYPE = "in"; 29 | 30 | private String dimension; 31 | private List values; 32 | 33 | public InFilter(@NonNull String dimension, @NonNull List values) { 34 | this.type = IN_DRUID_FILTER_TYPE; 35 | this.dimension = dimension; 36 | this.values = values; 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/IntervalFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter; 18 | 19 | import java.util.List; 20 | 21 | import in.zapr.druid.druidry.query.config.Interval; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NonNull; 25 | 26 | @Getter 27 | @EqualsAndHashCode(callSuper = true) 28 | public class IntervalFilter extends DruidFilter { 29 | 30 | private static String INTERVAL_DRUID_FILTER_TYPE = "interval"; 31 | 32 | private String type; 33 | private String dimension; 34 | private List intervals; 35 | 36 | public IntervalFilter(@NonNull String dimension, @NonNull List intervals) { 37 | this.type = INTERVAL_DRUID_FILTER_TYPE; 38 | this.dimension = dimension; 39 | this.intervals = intervals; 40 | } 41 | 42 | // TODO: support for Extraction Function 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/JavaScriptFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class JavaScriptFilter extends DruidFilter { 26 | 27 | private static String JS_DRUID_FILTER_TYPE = "javascript"; 28 | 29 | private String dimension; 30 | private String function; 31 | 32 | public JavaScriptFilter(@NonNull String dimension, @NonNull String function) { 33 | this.type = JS_DRUID_FILTER_TYPE; 34 | 35 | this.dimension = dimension; 36 | this.function = function; 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/NotFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class NotFilter extends DruidFilter { 26 | 27 | private static String NOT_DRUID_FILTER_TYPE = "not"; 28 | 29 | private DruidFilter field; 30 | 31 | public NotFilter(@NonNull DruidFilter field) { 32 | this.type = NOT_DRUID_FILTER_TYPE; 33 | this.field = field; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/OrFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter; 18 | 19 | import java.util.List; 20 | 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @EqualsAndHashCode(callSuper = true) 27 | public class OrFilter extends DruidFilter { 28 | 29 | private static String OR_DRUID_FILTER_TYPE = "or"; 30 | private List fields; 31 | 32 | public OrFilter(@NonNull List fields) { 33 | this.type = OR_DRUID_FILTER_TYPE; 34 | this.fields = fields; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/RegexFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class RegexFilter extends DruidFilter { 26 | 27 | private static String REGEX_DRUID_FILTER_TYPE = "regex"; 28 | 29 | private String dimension; 30 | private String pattern; 31 | 32 | public RegexFilter(@NonNull String dimension, @NonNull String pattern) { 33 | this.type = REGEX_DRUID_FILTER_TYPE; 34 | this.dimension = dimension; 35 | this.pattern = pattern; 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/SearchFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter; 18 | 19 | import in.zapr.druid.druidry.filter.searchQuerySpec.SearchQuerySpec; 20 | import lombok.Builder; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @EqualsAndHashCode(callSuper = true) 27 | public class SearchFilter extends DruidFilter { 28 | 29 | private static String SEARCH_DRUID_FILTER_TYPE = "search"; 30 | private String dimension; 31 | private SearchQuerySpec query; 32 | 33 | @Builder 34 | private SearchFilter(@NonNull String dimension, @NonNull SearchQuerySpec searchQuerySpec) { 35 | 36 | this.type = SEARCH_DRUID_FILTER_TYPE; 37 | this.dimension = dimension; 38 | this.query = searchQuerySpec; 39 | } 40 | 41 | // TODO: Extraction Function 42 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/SelectorFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter; 18 | 19 | import java.util.Optional; 20 | 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @EqualsAndHashCode(callSuper = true) 27 | public class SelectorFilter extends DruidFilter { 28 | 29 | private static String SELECTOR_DRUID_FILTER_TYPE = "selector"; 30 | 31 | private String dimension; 32 | private Object value; 33 | 34 | private SelectorFilter(@NonNull String dimension) { 35 | this.type = SELECTOR_DRUID_FILTER_TYPE; 36 | this.dimension = dimension; 37 | } 38 | 39 | public SelectorFilter(@NonNull String dimension, String value) { 40 | this(dimension); 41 | this.value = value; 42 | } 43 | 44 | public SelectorFilter(@NonNull String dimension, Integer value) { 45 | this(dimension); 46 | this.value = value; 47 | } 48 | 49 | public SelectorFilter(@NonNull String dimension, Long value) { 50 | this(dimension); 51 | this.value = value; 52 | } 53 | 54 | public SelectorFilter(@NonNull String dimension, Optional value) { 55 | this(dimension); 56 | if (value.isPresent()) { 57 | this.value = value.get(); 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/havingSpec/AndHaving.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.havingSpec; 18 | 19 | import java.util.List; 20 | 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @EqualsAndHashCode(callSuper = true) 27 | public class AndHaving extends HavingSpec { 28 | private static String AND_DRUID_HAVING_TYPE = "and"; 29 | private List havingSpecs; 30 | 31 | public AndHaving(@NonNull List fields) { 32 | this.type = AND_DRUID_HAVING_TYPE; 33 | this.havingSpecs = fields; 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/havingSpec/DimSelectorHaving.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.havingSpec; 18 | 19 | import java.util.Optional; 20 | 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @EqualsAndHashCode(callSuper = true) 27 | public class DimSelectorHaving extends HavingSpec { 28 | private static String DIM_SELECTOR_DRUID_HAVING_TYPE = "dimSelector"; 29 | protected String dimension; 30 | protected Object value; 31 | 32 | 33 | private DimSelectorHaving(@NonNull String dimension) { 34 | this.type = DIM_SELECTOR_DRUID_HAVING_TYPE; 35 | this.dimension = dimension; 36 | } 37 | 38 | public DimSelectorHaving(@NonNull String dimension, Number value) { 39 | this(dimension); 40 | this.value = value; 41 | } 42 | 43 | public DimSelectorHaving(@NonNull String dimension, String value) { 44 | this(dimension); 45 | this.value = value; 46 | } 47 | 48 | public DimSelectorHaving(@NonNull String dimension, Optional value) { 49 | this(dimension); 50 | if (value.isPresent()) { 51 | this.value = value.get(); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/havingSpec/EqualToHaving.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.havingSpec; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class EqualToHaving extends HavingSpec { 26 | private static String EQUAL_TO_DRUID_HAVING_TYPE = "equalTo"; 27 | protected String aggregation; 28 | protected Number value; 29 | 30 | private EqualToHaving(@NonNull String metric) { 31 | this.type = EQUAL_TO_DRUID_HAVING_TYPE; 32 | this.aggregation = metric; 33 | } 34 | 35 | public EqualToHaving(@NonNull String metric, @NonNull Number value) { 36 | this(metric); 37 | this.value = value; 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/havingSpec/FilterHaving.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.havingSpec; 18 | 19 | import in.zapr.druid.druidry.filter.DruidFilter; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @Getter 25 | @EqualsAndHashCode(callSuper = true) 26 | public class FilterHaving extends HavingSpec { 27 | private static String FILTER_DRUID_HAVING_TYPE = "filter"; 28 | 29 | protected DruidFilter filter; 30 | 31 | public FilterHaving(@NonNull DruidFilter filter) { 32 | this.type = FILTER_DRUID_HAVING_TYPE; 33 | this.filter = filter; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/havingSpec/GreaterThanHaving.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.havingSpec; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class GreaterThanHaving extends HavingSpec { 26 | private static String GREATER_THAN_DRUID_HAVING_TYPE = "greaterThan"; 27 | protected String aggregation; 28 | protected Number value; 29 | 30 | private GreaterThanHaving(@NonNull String metric) { 31 | this.type = GREATER_THAN_DRUID_HAVING_TYPE; 32 | this.aggregation = metric; 33 | } 34 | 35 | public GreaterThanHaving(@NonNull String metric, @NonNull Number value) { 36 | this(metric); 37 | this.value = value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/havingSpec/HavingSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.havingSpec; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | 22 | @Getter 23 | @EqualsAndHashCode 24 | public abstract class HavingSpec { 25 | protected String type; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/havingSpec/LessThanHaving.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.havingSpec; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class LessThanHaving extends HavingSpec { 26 | private static String LESS_THAN_DRUID_HAVING_TYPE = "lessThan"; 27 | protected String aggregation; 28 | protected Number value; 29 | 30 | private LessThanHaving(@NonNull String metric) { 31 | this.type = LESS_THAN_DRUID_HAVING_TYPE; 32 | this.aggregation = metric; 33 | } 34 | 35 | public LessThanHaving(@NonNull String metric, @NonNull Number value) { 36 | this(metric); 37 | this.value = value; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/havingSpec/NotHaving.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.havingSpec; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class NotHaving extends HavingSpec { 26 | private static String NOT_DRUID_HAVING_TYPE = "not"; 27 | protected HavingSpec havingSpec; 28 | 29 | public NotHaving(@NonNull HavingSpec field) { 30 | this.type = NOT_DRUID_HAVING_TYPE; 31 | this.havingSpec = field; 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/havingSpec/OrHaving.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.havingSpec; 18 | 19 | import java.util.List; 20 | 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @EqualsAndHashCode(callSuper = true) 27 | public class OrHaving extends HavingSpec { 28 | private static String OR_DRUID_HAVING_TYPE = "or"; 29 | protected List havingSpecs; 30 | 31 | public OrHaving(@NonNull List fields) { 32 | this.type = OR_DRUID_HAVING_TYPE; 33 | this.havingSpecs = fields; 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/searchQuerySpec/ContainsSearchQuerySpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.searchQuerySpec; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import lombok.Getter; 22 | import lombok.NonNull; 23 | 24 | @JsonInclude(JsonInclude.Include.NON_NULL) 25 | @Getter 26 | public class ContainsSearchQuerySpec extends SearchQuerySpec { 27 | 28 | private final static String CONTAINS_SEARCH_QUERY_SPEC = "contains"; 29 | 30 | private String value; 31 | private Boolean caseSensitive; 32 | 33 | public ContainsSearchQuerySpec(@NonNull String value) { 34 | this(value, null); 35 | } 36 | 37 | public ContainsSearchQuerySpec(@NonNull String value, Boolean isCaseSensitive) { 38 | this.type = CONTAINS_SEARCH_QUERY_SPEC; 39 | this.value = value; 40 | this.caseSensitive = isCaseSensitive; 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/searchQuerySpec/FragmentSearchQuerySpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.searchQuerySpec; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import java.util.List; 22 | 23 | import lombok.Getter; 24 | import lombok.NonNull; 25 | 26 | @JsonInclude(JsonInclude.Include.NON_NULL) 27 | @Getter 28 | public class FragmentSearchQuerySpec extends SearchQuerySpec { 29 | 30 | private final static String FRAGMENT_SEARCH_QUERY_SPEC = "fragment"; 31 | 32 | private List values; 33 | private Boolean caseSensitive; 34 | 35 | public FragmentSearchQuerySpec(@NonNull List values) { 36 | this(values, null); 37 | } 38 | 39 | public FragmentSearchQuerySpec(@NonNull List values, Boolean isCaseSensitive) { 40 | this.type = FRAGMENT_SEARCH_QUERY_SPEC; 41 | this.values = values; 42 | this.caseSensitive = isCaseSensitive; 43 | } 44 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/searchQuerySpec/InsensitiveContainsSearchQuerySpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.searchQuerySpec; 18 | 19 | import lombok.Getter; 20 | import lombok.NonNull; 21 | 22 | @Getter 23 | public class InsensitiveContainsSearchQuerySpec extends SearchQuerySpec { 24 | 25 | private final static String INSENSITIVE_CONTAINS = "insensitive_contains"; 26 | 27 | private String value; 28 | 29 | public InsensitiveContainsSearchQuerySpec(@NonNull String value) { 30 | this.type = INSENSITIVE_CONTAINS; 31 | this.value = value; 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/searchQuerySpec/RegexSearchQuerySpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.searchQuerySpec; 18 | 19 | import lombok.Builder; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | public class RegexSearchQuerySpec extends SearchQuerySpec { 25 | private final static String REGEX_SEARCH_QUERY_SPEC = "regex"; 26 | 27 | private String pattern; 28 | 29 | @Builder 30 | private RegexSearchQuerySpec(@NonNull String pattern) { 31 | this.type = REGEX_SEARCH_QUERY_SPEC; 32 | this.pattern = pattern; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/filter/searchQuerySpec/SearchQuerySpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.filter.searchQuerySpec; 18 | 19 | import lombok.Getter; 20 | 21 | @Getter 22 | public abstract class SearchQuerySpec { 23 | protected String type; 24 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/granularity/DurationGranularity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.granularity; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | 22 | import org.joda.time.DateTime; 23 | 24 | import lombok.EqualsAndHashCode; 25 | import lombok.Getter; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode(callSuper = true) 30 | public class DurationGranularity extends Granularity { 31 | 32 | private static final String DURATION_GRANULARITY_TYPE = "duration"; 33 | 34 | private final String type; 35 | @JsonProperty("duration") 36 | private long durationInMilliSeconds; 37 | private DateTime origin; 38 | 39 | public DurationGranularity(long durationInMilliSeconds) { 40 | this(durationInMilliSeconds, null); 41 | } 42 | 43 | public DurationGranularity(long durationInMilliSeconds, DateTime origin) { 44 | this.type = DURATION_GRANULARITY_TYPE; 45 | this.durationInMilliSeconds = durationInMilliSeconds; 46 | this.origin = origin; 47 | } 48 | 49 | public String getOrigin() { 50 | return origin == null ? null : origin.toDateTimeISO().toString(); 51 | } 52 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/granularity/Granularity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.granularity; 18 | 19 | import lombok.EqualsAndHashCode; 20 | 21 | @EqualsAndHashCode 22 | public abstract class Granularity { 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/granularity/PeriodGranularity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.granularity; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import org.joda.time.DateTime; 22 | import org.joda.time.DateTimeZone; 23 | 24 | import lombok.Builder; 25 | import lombok.EqualsAndHashCode; 26 | import lombok.Getter; 27 | 28 | @Builder 29 | @Getter 30 | @JsonInclude(JsonInclude.Include.NON_NULL) 31 | @EqualsAndHashCode(callSuper = true) 32 | public class PeriodGranularity extends Granularity { 33 | private static final String PERIOD_GRANULARITY_TYPE = "period"; 34 | private static final String DEFAULT_TIMEZONE = "UTC"; 35 | 36 | private final String type = PERIOD_GRANULARITY_TYPE; 37 | 38 | // TODO: ISO-8601 Period validation, Check it is alright 39 | // TODO: while building make sure that it is required 40 | private String period; 41 | 42 | // TODO: Check if it is alright 43 | private DateTimeZone timeZone; 44 | private DateTime origin; 45 | 46 | public String getOrigin() { 47 | return origin == null ? null : origin.toDateTimeISO().toString(); 48 | } 49 | 50 | public String getTimeZone() { 51 | return timeZone == null ? DEFAULT_TIMEZONE : timeZone.getID(); 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/granularity/PredefinedGranularity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.granularity; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum PredefinedGranularity { 22 | 23 | NONE("none"), 24 | ALL("all"), 25 | SECOND("second"), 26 | MINUTE("minute"), 27 | FIFTEEN_MINUTE("fifteen_minute"), 28 | THIRTY_MINUTE("thirty_minute"), 29 | HOUR("hour"), 30 | DAY("day"), 31 | WEEK("week"), 32 | MONTH("month"), 33 | QUARTER("quarter"), 34 | YEAR("year"); 35 | 36 | private String value; 37 | 38 | PredefinedGranularity(String value) { 39 | this.value = value; 40 | } 41 | 42 | @JsonValue 43 | public String getPredefinedGranularityString() { 44 | return value; 45 | } 46 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/granularity/SimpleGranularity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.granularity; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | 24 | @Getter 25 | @EqualsAndHashCode 26 | public class SimpleGranularity extends Granularity { 27 | 28 | private PredefinedGranularity granularity; 29 | 30 | public SimpleGranularity(PredefinedGranularity granularity) { 31 | this.granularity = granularity; 32 | } 33 | 34 | @JsonValue 35 | public PredefinedGranularity getGranularity() { 36 | return granularity; 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/limitSpec/DefaultLimitSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.limitSpec; 18 | 19 | import java.util.List; 20 | 21 | import in.zapr.druid.druidry.limitSpec.orderByColumnSpec.OrderByColumnSpec; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NonNull; 25 | 26 | @Getter 27 | @EqualsAndHashCode 28 | public class DefaultLimitSpec { 29 | private static final String DEFAULT_LIMIT_SPEC_TYPE = "default"; 30 | 31 | private String type; 32 | private int limit; 33 | private List columns; 34 | 35 | public DefaultLimitSpec(int limit, @NonNull List columns) { 36 | this.type = DEFAULT_LIMIT_SPEC_TYPE; 37 | this.limit = limit; 38 | this.columns = columns; 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/limitSpec/orderByColumnSpec/OrderByColumnSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.limitSpec.orderByColumnSpec; 18 | 19 | import lombok.EqualsAndHashCode; 20 | 21 | @EqualsAndHashCode 22 | public abstract class OrderByColumnSpec { 23 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/limitSpec/orderByColumnSpec/OrderByColumnSpecMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.limitSpec.orderByColumnSpec; 18 | 19 | import in.zapr.druid.druidry.query.config.SortingOrder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class OrderByColumnSpecMap extends OrderByColumnSpec { 26 | 27 | private static final String ASCENDING_ORDER = "ascending"; 28 | private static final String DESCENDING_ORDER = "descending"; 29 | 30 | private String dimension; 31 | private String direction; 32 | private SortingOrder dimensionOrder; 33 | 34 | public OrderByColumnSpecMap(String dimension, boolean isAscending, SortingOrder dimensionOrder) { 35 | this.dimension = dimension; 36 | this.direction = isAscending ? ASCENDING_ORDER : DESCENDING_ORDER; 37 | this.dimensionOrder = dimensionOrder; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/limitSpec/orderByColumnSpec/OrderByColumnSpecString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.limitSpec.orderByColumnSpec; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | import lombok.EqualsAndHashCode; 22 | import lombok.NonNull; 23 | 24 | @EqualsAndHashCode(callSuper = true) 25 | public class OrderByColumnSpecString extends OrderByColumnSpec { 26 | 27 | private String name; 28 | 29 | public OrderByColumnSpecString(@NonNull String name) { 30 | this.name = name; 31 | } 32 | 33 | @JsonValue 34 | public String getName() { 35 | return name; 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/lookUpSpec/LookUpSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.lookUpSpec; 18 | 19 | public abstract class LookUpSpec { 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/postAggregator/ArithmeticFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum ArithmeticFunction { 22 | PLUS("+"), 23 | MINUS("-"), 24 | MULTIPLY("*"), 25 | DIVIDE("/"), 26 | QUOTIENT("quotient"); 27 | 28 | 29 | private String value; 30 | 31 | ArithmeticFunction(String value) { 32 | this.value = value; 33 | } 34 | 35 | @JsonValue 36 | public String getValue() { 37 | return value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/postAggregator/ArithmeticOrdering.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum ArithmeticOrdering { 22 | NULL("null"), 23 | NUMERIC_FIRST("numericFirst"); 24 | 25 | private String value; 26 | 27 | ArithmeticOrdering(String value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonValue 32 | public String getValue() { 33 | return this.value; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/postAggregator/ConstantPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.postAggregator; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class ConstantPostAggregator extends DruidPostAggregator { 26 | 27 | private final static String CONSTANT_POST_AGGREGATOR_TYPE = "constant"; 28 | 29 | private Double value; 30 | 31 | public ConstantPostAggregator(@NonNull String name, @NonNull Double value) { 32 | this.type = CONSTANT_POST_AGGREGATOR_TYPE; 33 | this.name = name; 34 | this.value = value; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/postAggregator/DruidPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.postAggregator; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | 22 | @Getter 23 | @EqualsAndHashCode 24 | public abstract class DruidPostAggregator { 25 | protected String type; 26 | protected String name; 27 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/postAggregator/FieldAccessPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.postAggregator; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NonNull; 24 | 25 | @Getter 26 | @JsonInclude(JsonInclude.Include.NON_NULL) 27 | @EqualsAndHashCode(callSuper = true) 28 | public class FieldAccessPostAggregator extends DruidPostAggregator { 29 | 30 | private final static String FIELD_ACCESS_POST_AGGREGATOR_TYPE = "fieldAccess"; 31 | 32 | private String fieldName; 33 | 34 | public FieldAccessPostAggregator(@NonNull String name, @NonNull String fieldName) { 35 | this.type = FIELD_ACCESS_POST_AGGREGATOR_TYPE; 36 | this.name = name; 37 | this.fieldName = fieldName; 38 | } 39 | 40 | public FieldAccessPostAggregator(@NonNull String fieldName) { 41 | this.type = FIELD_ACCESS_POST_AGGREGATOR_TYPE; 42 | this.fieldName = fieldName; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/postAggregator/HyperUniqueCardinalityPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.postAggregator; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class HyperUniqueCardinalityPostAggregator extends DruidPostAggregator { 26 | private final static String HYPER_UNIQUE_POST_AGGREGATOR_TYPE = "hyperUniqueCardinality"; 27 | 28 | private String fieldName; 29 | 30 | public HyperUniqueCardinalityPostAggregator(@NonNull String name, @NonNull String fieldName) { 31 | this.type = HYPER_UNIQUE_POST_AGGREGATOR_TYPE; 32 | this.name = name; 33 | this.fieldName = fieldName; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/postAggregator/JavaScriptPostAggregator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.postAggregator; 18 | 19 | import java.util.List; 20 | 21 | import lombok.Builder; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NonNull; 25 | 26 | @Getter 27 | @EqualsAndHashCode(callSuper = true) 28 | public class JavaScriptPostAggregator extends DruidPostAggregator { 29 | 30 | private final static String JAVASCRIPT_POST_AGGREGATOR_TYPE = "javascript"; 31 | 32 | private List fieldNames; 33 | private String function; 34 | 35 | @Builder 36 | private JavaScriptPostAggregator(@NonNull String name, @NonNull List fieldNames, 37 | @NonNull String function) { 38 | 39 | this.type = JAVASCRIPT_POST_AGGREGATOR_TYPE; 40 | this.name = name; 41 | this.fieldNames = fieldNames; 42 | this.function = function; 43 | } 44 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/DruidQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.query.config.Context; 22 | import in.zapr.druid.druidry.dataSource.DataSource; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | @EqualsAndHashCode 30 | public abstract class DruidQuery { 31 | 32 | @NonNull 33 | protected DataSource dataSource; 34 | 35 | protected Context context; 36 | 37 | // Not making it public since this should be set by its children's constructor. 38 | @NonNull 39 | protected QueryType queryType; 40 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/QueryType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum QueryType { 22 | 23 | TIMESERIES("timeseries"), 24 | TOPN("topN"), 25 | GROUP_BY("groupBy"), 26 | TIME_BOUNDARY("timeBoundary"), 27 | SEGMENT_METADATA("segmentMetadata"), 28 | DATASOURCE_METADATA("dataSourceMetadata"), 29 | SEARCH("search"), 30 | SCAN("scan"), 31 | @Deprecated 32 | SELECT("select"), 33 | MOVING_AVERAGE("movingAverage"); 34 | 35 | private String value; 36 | 37 | QueryType(String value) { 38 | this.value = value; 39 | } 40 | 41 | @JsonValue 42 | public String getQueryType() { 43 | return value; 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/aggregation/DruidAggregationQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query.aggregation; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import java.util.List; 22 | 23 | import in.zapr.druid.druidry.query.config.Interval; 24 | import in.zapr.druid.druidry.aggregator.DruidAggregator; 25 | import in.zapr.druid.druidry.filter.DruidFilter; 26 | import in.zapr.druid.druidry.granularity.Granularity; 27 | import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; 28 | import in.zapr.druid.druidry.query.DruidQuery; 29 | import in.zapr.druid.druidry.virtualColumn.DruidVirtualColumn; 30 | import lombok.EqualsAndHashCode; 31 | import lombok.Getter; 32 | 33 | @JsonInclude(JsonInclude.Include.NON_NULL) 34 | @Getter 35 | @EqualsAndHashCode(callSuper = true) 36 | public abstract class DruidAggregationQuery extends DruidQuery { 37 | protected List intervals; 38 | protected Granularity granularity; 39 | protected List virtualColumns; 40 | protected DruidFilter filter; 41 | protected List aggregations; 42 | protected List postAggregations; 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/config/GroupByStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query.config; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum GroupByStrategy { 22 | 23 | STRATEGY_V1("v1"), 24 | STRATEGY_V2("v2"); 25 | 26 | private String value; 27 | 28 | GroupByStrategy(String value) { 29 | this.value = value; 30 | } 31 | 32 | @JsonValue 33 | public String getValue() { 34 | return value; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/config/Interval.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query.config; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | import org.joda.time.DateTime; 22 | 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | 27 | @Getter 28 | @EqualsAndHashCode 29 | public class Interval { 30 | 31 | private final static String DRUID_INTERVAL_FORMAT = "%s/%s"; 32 | 33 | private DateTime startTime; 34 | private DateTime endTime; 35 | 36 | public Interval(@NonNull DateTime startTime, @NonNull DateTime endTime) { 37 | this.startTime = startTime; 38 | this.endTime = endTime; 39 | } 40 | 41 | @JsonValue 42 | private String getIntervalAsString() { 43 | return String.format(DRUID_INTERVAL_FORMAT, startTime.toDateTimeISO(), endTime.toDateTimeISO()); 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/config/SortingOrder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query.config; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum SortingOrder { 22 | LEXICOGRAPHIC("lexicographic"), 23 | ALPHANUMERIC("alphanumeric"), 24 | NUMERIC("numeric"), 25 | STRLEN("strlen"); 26 | 27 | private String value; 28 | 29 | SortingOrder(String value) { 30 | this.value = value; 31 | } 32 | 33 | @JsonValue 34 | public String getSortingOrder() { 35 | return value; 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/config/Vectorize.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query.config; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum Vectorize { 22 | 23 | FALSE("false"), 24 | TRUE("true"), 25 | FORCE("force"); 26 | 27 | private String value; 28 | 29 | Vectorize(String value) { 30 | this.value = value; 31 | } 32 | 33 | @JsonValue 34 | public String getValue() { 35 | return value; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/metadata/DruidDataSourceMetadataQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query.metadata; 18 | 19 | import lombok.EqualsAndHashCode; 20 | 21 | @EqualsAndHashCode(callSuper = true) 22 | class DruidDataSourceMetadataQuery extends DruidMetadataQuery { 23 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/metadata/DruidMetadataQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query.metadata; 18 | 19 | import in.zapr.druid.druidry.query.DruidQuery; 20 | import lombok.EqualsAndHashCode; 21 | 22 | @EqualsAndHashCode(callSuper = true) 23 | abstract class DruidMetadataQuery extends DruidQuery { 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/metadata/DruidSegmentMetadataQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query.metadata; 18 | 19 | import lombok.EqualsAndHashCode; 20 | 21 | @EqualsAndHashCode(callSuper = true) 22 | class DruidSegmentMetadataQuery extends DruidMetadataQuery { 23 | 24 | public String intervals; 25 | public String toInclude; 26 | public String merge; 27 | public String analysisTypes; 28 | public String lenientAggregatorMerge; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/metadata/DruidTimeBoundaryQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query.metadata; 18 | 19 | import lombok.EqualsAndHashCode; 20 | 21 | @EqualsAndHashCode(callSuper = true) 22 | class DruidTimeBoundaryQuery extends DruidMetadataQuery { 23 | 24 | public String bound; 25 | public String filter; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/scan/ResultFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query.scan; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | 21 | public enum ResultFormat { 22 | 23 | LIST("list"), 24 | COMPACTED_LIST("compactedList"), 25 | VALUE_VECTOR("valueVector"); 26 | 27 | private String value; 28 | 29 | ResultFormat(String value) { 30 | this.value = value; 31 | } 32 | 33 | @JsonValue 34 | public String getResultFormat() { 35 | return value; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/search/SearchSortSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.query.search; 18 | 19 | import in.zapr.druid.druidry.query.config.SortingOrder; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | 23 | @Getter 24 | @EqualsAndHashCode 25 | public class SearchSortSpec { 26 | 27 | private SortingOrder type; 28 | 29 | public SearchSortSpec(SortingOrder sortingOrder) { 30 | this.type = sortingOrder; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/query/select/PagingSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package in.zapr.druid.druidry.query.select; 17 | 18 | import com.fasterxml.jackson.annotation.JsonInclude; 19 | 20 | import java.util.Map; 21 | 22 | import lombok.AllArgsConstructor; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NonNull; 26 | import lombok.RequiredArgsConstructor; 27 | 28 | @Getter 29 | @JsonInclude(JsonInclude.Include.NON_NULL) 30 | @RequiredArgsConstructor 31 | @AllArgsConstructor 32 | @EqualsAndHashCode 33 | public class PagingSpec { 34 | @NonNull 35 | private Integer threshold; 36 | 37 | private Boolean fromNext; 38 | 39 | @NonNull 40 | private Map pagingIdentifiers; 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/topNMetric/DimensionMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.topNMetric; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import in.zapr.druid.druidry.query.config.SortingOrder; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | 26 | @Getter 27 | @EqualsAndHashCode(callSuper = true) 28 | @JsonInclude(JsonInclude.Include.NON_NULL) 29 | public class DimensionMetric extends TopNMetric { 30 | 31 | private static final String DIMENSION_METRIC_TYPE = "dimension"; 32 | 33 | private String type; 34 | private SortingOrder ordering; 35 | private String previousStop; 36 | 37 | @Builder 38 | private DimensionMetric(SortingOrder ordering, String previousStop) { 39 | this.type = DIMENSION_METRIC_TYPE; 40 | this.ordering = ordering; 41 | this.previousStop = previousStop; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/topNMetric/InvertedMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.topNMetric; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class InvertedMetric extends TopNMetric { 26 | 27 | private static final String INVERTED_METRIC_TYPE = "inverted"; 28 | 29 | private String type; 30 | private TopNMetric metric; 31 | 32 | public InvertedMetric(@NonNull TopNMetric topNMetric) { 33 | this.type = INVERTED_METRIC_TYPE; 34 | this.metric = topNMetric; 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/topNMetric/NumericMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.topNMetric; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | import lombok.NonNull; 22 | 23 | @Getter 24 | @EqualsAndHashCode(callSuper = true) 25 | public class NumericMetric extends TopNMetric { 26 | 27 | private static final String NUMERIC_METRIC_TYPE = "numeric"; 28 | 29 | private String type; 30 | private String metric; 31 | 32 | public NumericMetric(@NonNull String metric) { 33 | this.type = NUMERIC_METRIC_TYPE; 34 | this.metric = metric; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/topNMetric/SimpleMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.topNMetric; 18 | 19 | import com.fasterxml.jackson.annotation.JsonValue; 20 | import lombok.EqualsAndHashCode; 21 | 22 | @EqualsAndHashCode(callSuper = true) 23 | public class SimpleMetric extends TopNMetric { 24 | 25 | private String metric; 26 | 27 | public SimpleMetric(String metric) { 28 | this.metric = metric; 29 | } 30 | 31 | @JsonValue 32 | public String getMetric() { 33 | return this.metric; 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/topNMetric/TopNMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.topNMetric; 18 | 19 | import lombok.EqualsAndHashCode; 20 | import lombok.Getter; 21 | 22 | @Getter 23 | @EqualsAndHashCode 24 | public abstract class TopNMetric { 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/virtualColumn/DruidVirtualColumn.java: -------------------------------------------------------------------------------- 1 | package in.zapr.druid.druidry.virtualColumn; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | 5 | import in.zapr.druid.druidry.dimension.enums.OutputType; 6 | import lombok.EqualsAndHashCode; 7 | import lombok.Getter; 8 | import lombok.NonNull; 9 | 10 | @Getter 11 | @EqualsAndHashCode 12 | @JsonInclude(JsonInclude.Include.NON_NULL) 13 | public abstract class DruidVirtualColumn { 14 | @NonNull 15 | protected String type; 16 | 17 | @NonNull 18 | protected String name; 19 | 20 | protected OutputType outputType; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/in/zapr/druid/druidry/virtualColumn/ExpressionVirtualColumn.java: -------------------------------------------------------------------------------- 1 | package in.zapr.druid.druidry.virtualColumn; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | 5 | import in.zapr.druid.druidry.dimension.enums.OutputType; 6 | import lombok.Builder; 7 | import lombok.EqualsAndHashCode; 8 | import lombok.Getter; 9 | import lombok.NonNull; 10 | 11 | @Getter 12 | @EqualsAndHashCode(callSuper = true) 13 | @JsonInclude(JsonInclude.Include.NON_NULL) 14 | public class ExpressionVirtualColumn extends DruidVirtualColumn { 15 | private static final String EXPRESSION_VIRTUAL_COLUMN = "expression"; 16 | 17 | @NonNull 18 | private String expression; 19 | 20 | @Builder 21 | public ExpressionVirtualColumn(@NonNull String name, @NonNull String expression, OutputType outputType) { 22 | this.type = EXPRESSION_VIRTUAL_COLUMN; 23 | this.name = name; 24 | this.outputType = outputType; 25 | this.expression = expression; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/in/zapr/druid/druidry/client/DruidClientTest.java: -------------------------------------------------------------------------------- 1 | package in.zapr.druid.druidry.client; 2 | 3 | import static org.testng.Assert.assertFalse; 4 | import static org.testng.Assert.assertTrue; 5 | 6 | import in.zapr.druid.druidry.query.DruidQuery; 7 | import org.testng.annotations.Test; 8 | 9 | import java.util.List; 10 | 11 | public class DruidClientTest { 12 | 13 | private boolean wasClientClosed; 14 | 15 | @Test 16 | public void testAutoClosing() { 17 | assertFalse(wasClientClosed, "Client closing indicator is not initialized properly"); 18 | try (TestDruidClient client = new TestDruidClient()) { 19 | client.connect(); 20 | } 21 | assertTrue(wasClientClosed, "Close method has not been called"); 22 | } 23 | 24 | private class TestDruidClient implements DruidClient { 25 | 26 | @Override 27 | public void connect() { 28 | 29 | } 30 | 31 | @Override 32 | public void close() { 33 | wasClientClosed = true; 34 | } 35 | 36 | @Override 37 | public String query(DruidQuery druidQuery) { 38 | return null; 39 | } 40 | 41 | @Override 42 | public List query(DruidQuery druidQuery, Class className) { 43 | return null; 44 | } 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/in/zapr/druid/druidry/extractionFunctions/StrLenExtractionFunctionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Red Brick Lane Marketing Solutions Pvt. Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.zapr.druid.druidry.extractionFunctions; 18 | 19 | import com.fasterxml.jackson.core.JsonProcessingException; 20 | import com.fasterxml.jackson.databind.ObjectMapper; 21 | 22 | import org.json.JSONException; 23 | import org.skyscreamer.jsonassert.JSONAssert; 24 | import org.skyscreamer.jsonassert.JSONCompareMode; 25 | import org.testng.annotations.BeforeClass; 26 | import org.testng.annotations.Test; 27 | 28 | public class StrLenExtractionFunctionTest { 29 | private static ObjectMapper objectMapper; 30 | 31 | @BeforeClass 32 | public void init() { 33 | objectMapper = new ObjectMapper(); 34 | } 35 | 36 | @Test 37 | public void testAllFields() throws JsonProcessingException, JSONException { 38 | StrLenExtractionFunction strLenExtractionFunction = StrLenExtractionFunction.builder().build(); 39 | 40 | String actualJSON = objectMapper.writeValueAsString(strLenExtractionFunction); 41 | 42 | String expectedJSONString = "{ \"type\" : \"strlen\" }\n"; 43 | 44 | JSONAssert.assertEquals(expectedJSONString, actualJSON, JSONCompareMode.NON_EXTENSIBLE); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/test/resources/query/aggregation/moving_average/allFields.json: -------------------------------------------------------------------------------- 1 | { 2 | "queryType": "movingAverage", 3 | "dataSource": { 4 | "type": "table", 5 | "name": "allFieldsDataSource" 6 | }, 7 | "dimensions": [ 8 | "dimension_1", 9 | "dimension_2" 10 | ], 11 | "limitSpec": { 12 | "type": "default", 13 | "limit": 5000, 14 | "columns": [ 15 | "column_1", 16 | "column_2" 17 | ] 18 | }, 19 | "having": { 20 | "type": "equalTo", 21 | "aggregation": "havingField", 22 | "value": 5 23 | }, 24 | "granularity": "fifteen_minute", 25 | "filter": { 26 | "type": "selector", 27 | "dimension": "selectorField", 28 | "value": "selectorValue" 29 | }, 30 | "aggregations": [ 31 | { 32 | "type": "doubleSum", 33 | "name": "averagedName", 34 | "fieldName": "aggregatedFieldName" 35 | } 36 | ], 37 | "postAggregations": [ 38 | { 39 | "type": "fieldAccess", 40 | "fieldName": "postAggregatedFieldName" 41 | } 42 | ], 43 | "intervals": [ 44 | "2020-02-01T00:00:00.000Z/2020-03-31T23:59:59.000Z" 45 | ], 46 | "context": { 47 | "useCache": true 48 | }, 49 | "averagers": [ 50 | { 51 | "type": "doubleMean", 52 | "name": "averagingResult", 53 | "fieldName": "averagedName", 54 | "buckets": 60, 55 | "cycleSize": 5 56 | } 57 | ], 58 | "postAveragers": [ 59 | { 60 | "type": "fieldAccess", 61 | "fieldName": "postAveragedFieldName" 62 | } 63 | ] 64 | } -------------------------------------------------------------------------------- /src/test/resources/query/aggregation/moving_average/averager_type/doubleMax.json: -------------------------------------------------------------------------------- 1 | { 2 | "queryType": "movingAverage", 3 | "dataSource": { 4 | "type": "table", 5 | "name": "simpleDataSource" 6 | }, 7 | "granularity": "day", 8 | "intervals": [ 9 | "2020-01-01T00:00:00.000Z/2020-02-29T23:59:59.000Z" 10 | ], 11 | "aggregations": [ 12 | { 13 | "name": "averagedName", 14 | "fieldName": "aggregatedFieldName", 15 | "type": "doubleSum" 16 | } 17 | ], 18 | "averagers": [ 19 | { 20 | "name": "averagingResult", 21 | "fieldName": "averagedName", 22 | "type": "doubleMax", 23 | "buckets": 31 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /src/test/resources/query/aggregation/moving_average/averager_type/doubleMean.json: -------------------------------------------------------------------------------- 1 | { 2 | "queryType": "movingAverage", 3 | "dataSource": { 4 | "type": "table", 5 | "name": "simpleDataSource" 6 | }, 7 | "granularity": "day", 8 | "intervals": [ 9 | "2020-01-01T00:00:00.000Z/2020-02-29T23:59:59.000Z" 10 | ], 11 | "aggregations": [ 12 | { 13 | "name": "averagedName", 14 | "fieldName": "aggregatedFieldName", 15 | "type": "doubleSum" 16 | } 17 | ], 18 | "averagers": [ 19 | { 20 | "name": "averagingResult", 21 | "fieldName": "averagedName", 22 | "type": "doubleMean", 23 | "buckets": 31 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /src/test/resources/query/aggregation/moving_average/averager_type/doubleMeanNoNulls.json: -------------------------------------------------------------------------------- 1 | { 2 | "queryType": "movingAverage", 3 | "dataSource": { 4 | "type": "table", 5 | "name": "simpleDataSource" 6 | }, 7 | "granularity": "day", 8 | "intervals": [ 9 | "2020-01-01T00:00:00.000Z/2020-02-29T23:59:59.000Z" 10 | ], 11 | "aggregations": [ 12 | { 13 | "name": "averagedName", 14 | "fieldName": "aggregatedFieldName", 15 | "type": "doubleSum" 16 | } 17 | ], 18 | "averagers": [ 19 | { 20 | "name": "averagingResult", 21 | "fieldName": "averagedName", 22 | "type": "doubleMeanNoNulls", 23 | "buckets": 31 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /src/test/resources/query/aggregation/moving_average/averager_type/doubleMin.json: -------------------------------------------------------------------------------- 1 | { 2 | "queryType": "movingAverage", 3 | "dataSource": { 4 | "type": "table", 5 | "name": "simpleDataSource" 6 | }, 7 | "granularity": "day", 8 | "intervals": [ 9 | "2020-01-01T00:00:00.000Z/2020-02-29T23:59:59.000Z" 10 | ], 11 | "aggregations": [ 12 | { 13 | "name": "averagedName", 14 | "fieldName": "aggregatedFieldName", 15 | "type": "doubleSum" 16 | } 17 | ], 18 | "averagers": [ 19 | { 20 | "name": "averagingResult", 21 | "fieldName": "averagedName", 22 | "type": "doubleMin", 23 | "buckets": 31 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /src/test/resources/query/aggregation/moving_average/averager_type/doubleSum.json: -------------------------------------------------------------------------------- 1 | { 2 | "queryType": "movingAverage", 3 | "dataSource": { 4 | "type": "table", 5 | "name": "simpleDataSource" 6 | }, 7 | "granularity": "day", 8 | "intervals": [ 9 | "2020-01-01T00:00:00.000Z/2020-02-29T23:59:59.000Z" 10 | ], 11 | "aggregations": [ 12 | { 13 | "name": "averagedName", 14 | "fieldName": "aggregatedFieldName", 15 | "type": "doubleSum" 16 | } 17 | ], 18 | "averagers": [ 19 | { 20 | "name": "averagingResult", 21 | "fieldName": "averagedName", 22 | "type": "doubleSum", 23 | "buckets": 31 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /src/test/resources/query/aggregation/moving_average/averager_type/longMax.json: -------------------------------------------------------------------------------- 1 | { 2 | "queryType": "movingAverage", 3 | "dataSource": { 4 | "type": "table", 5 | "name": "simpleDataSource" 6 | }, 7 | "granularity": "day", 8 | "intervals": [ 9 | "2020-01-01T00:00:00.000Z/2020-02-29T23:59:59.000Z" 10 | ], 11 | "aggregations": [ 12 | { 13 | "name": "averagedName", 14 | "fieldName": "aggregatedFieldName", 15 | "type": "doubleSum" 16 | } 17 | ], 18 | "averagers": [ 19 | { 20 | "name": "averagingResult", 21 | "fieldName": "averagedName", 22 | "type": "longMax", 23 | "buckets": 31 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /src/test/resources/query/aggregation/moving_average/averager_type/longMean.json: -------------------------------------------------------------------------------- 1 | { 2 | "queryType": "movingAverage", 3 | "dataSource": { 4 | "type": "table", 5 | "name": "simpleDataSource" 6 | }, 7 | "granularity": "day", 8 | "intervals": [ 9 | "2020-01-01T00:00:00.000Z/2020-02-29T23:59:59.000Z" 10 | ], 11 | "aggregations": [ 12 | { 13 | "name": "averagedName", 14 | "fieldName": "aggregatedFieldName", 15 | "type": "doubleSum" 16 | } 17 | ], 18 | "averagers": [ 19 | { 20 | "name": "averagingResult", 21 | "fieldName": "averagedName", 22 | "type": "longMean", 23 | "buckets": 31 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /src/test/resources/query/aggregation/moving_average/averager_type/longMeanNoNulls.json: -------------------------------------------------------------------------------- 1 | { 2 | "queryType": "movingAverage", 3 | "dataSource": { 4 | "type": "table", 5 | "name": "simpleDataSource" 6 | }, 7 | "granularity": "day", 8 | "intervals": [ 9 | "2020-01-01T00:00:00.000Z/2020-02-29T23:59:59.000Z" 10 | ], 11 | "aggregations": [ 12 | { 13 | "name": "averagedName", 14 | "fieldName": "aggregatedFieldName", 15 | "type": "doubleSum" 16 | } 17 | ], 18 | "averagers": [ 19 | { 20 | "name": "averagingResult", 21 | "fieldName": "averagedName", 22 | "type": "longMeanNoNulls", 23 | "buckets": 31 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /src/test/resources/query/aggregation/moving_average/averager_type/longMin.json: -------------------------------------------------------------------------------- 1 | { 2 | "queryType": "movingAverage", 3 | "dataSource": { 4 | "type": "table", 5 | "name": "simpleDataSource" 6 | }, 7 | "granularity": "day", 8 | "intervals": [ 9 | "2020-01-01T00:00:00.000Z/2020-02-29T23:59:59.000Z" 10 | ], 11 | "aggregations": [ 12 | { 13 | "name": "averagedName", 14 | "fieldName": "aggregatedFieldName", 15 | "type": "doubleSum" 16 | } 17 | ], 18 | "averagers": [ 19 | { 20 | "name": "averagingResult", 21 | "fieldName": "averagedName", 22 | "type": "longMin", 23 | "buckets": 31 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /src/test/resources/query/aggregation/moving_average/averager_type/longSum.json: -------------------------------------------------------------------------------- 1 | { 2 | "queryType": "movingAverage", 3 | "dataSource": { 4 | "type": "table", 5 | "name": "simpleDataSource" 6 | }, 7 | "granularity": "day", 8 | "intervals": [ 9 | "2020-01-01T00:00:00.000Z/2020-02-29T23:59:59.000Z" 10 | ], 11 | "aggregations": [ 12 | { 13 | "name": "averagedName", 14 | "fieldName": "aggregatedFieldName", 15 | "type": "doubleSum" 16 | } 17 | ], 18 | "averagers": [ 19 | { 20 | "name": "averagingResult", 21 | "fieldName": "averagedName", 22 | "type": "longSum", 23 | "buckets": 31 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /src/test/resources/query/aggregation/moving_average/simple.json: -------------------------------------------------------------------------------- 1 | { 2 | "queryType": "movingAverage", 3 | "dataSource": { 4 | "type": "table", 5 | "name": "simpleDataSource" 6 | }, 7 | "granularity": "day", 8 | "intervals": [ 9 | "2020-01-01T00:00:00.000Z/2020-02-29T23:59:59.000Z" 10 | ], 11 | "aggregations": [ 12 | { 13 | "name": "averagedName", 14 | "fieldName": "aggregatedFieldName", 15 | "type": "doubleSum" 16 | } 17 | ], 18 | "averagers": [ 19 | { 20 | "name": "averagingResult", 21 | "fieldName": "averagedName", 22 | "type": "doubleMean", 23 | "buckets": 31 24 | } 25 | ] 26 | } --------------------------------------------------------------------------------