jihoonson commented on a change in pull request #7331: TDigest backed sketch aggregators URL: https://github.com/apache/incubator-druid/pull/7331#discussion_r279903582
########## File path: extensions-contrib/tdigestsketch/src/main/java/org/apache/druid/query/aggregation/tdigestsketch/TDigestBuildSketchAggregatorFactory.java ########## @@ -0,0 +1,269 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.query.aggregation.tdigestsketch; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.tdunning.math.stats.MergingDigest; +import com.tdunning.math.stats.TDigest; +import org.apache.druid.query.aggregation.Aggregator; +import org.apache.druid.query.aggregation.AggregatorFactory; +import org.apache.druid.query.aggregation.AggregatorFactoryNotMergeableException; +import org.apache.druid.query.aggregation.AggregatorUtil; +import org.apache.druid.query.aggregation.BufferAggregator; +import org.apache.druid.query.cache.CacheKeyBuilder; +import org.apache.druid.segment.ColumnSelectorFactory; +import org.apache.druid.segment.ColumnValueSelector; +import org.apache.druid.segment.column.ColumnCapabilities; +import org.apache.druid.segment.column.ValueType; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; + +/** + * Aggregation operations over the tdigest-based quantile sketch + * available on <a href="https://github.com/tdunning/t-digest">github</a> and described + * in the paper + * <a href="https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf"> + * Computing extremely accurate quantiles using t-digests</a>. + * <p> + * <p> + * At the time of writing this implementation, there are two flavors of {@link TDigest} + * available - {@link MergingDigest} and {@link com.tdunning.math.stats.AVLTreeDigest}. + * This implementation uses {@link MergingDigest} since it is more suited for the cases + * when we have to merge intermediate aggregations which Druid needs to do as + * part of query processing. + */ +public class TDigestBuildSketchAggregatorFactory extends AggregatorFactory +{ + + // Default compression + public static final int DEFAULT_COMRESSION = 100; + + @Nonnull + private final String name; + @Nonnull + private final String fieldName; + @Nonnull + final Integer compression; Review comment: Btw, you can add a `package-info` file which claims everything is non null by default as in https://github.com/apache/incubator-druid/blob/master/processing/src/main/java/org/apache/druid/segment/package-info.java. You don't have to add this file in this PR, but may help you in the future. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
