You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2018/09/17 17:00:40 UTC
[GitHub] gianm commented on a change in pull request #5712: HllSketch module
gianm commented on a change in pull request #5712: HllSketch module
URL: https://github.com/apache/incubator-druid/pull/5712#discussion_r218149008
##########
File path: extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchAggregatorFactory.java
##########
@@ -0,0 +1,232 @@
+/*
+ * 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.datasketches.hll;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Objects;
+
+import javax.annotation.Nullable;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.yahoo.sketches.hll.HllSketch;
+import com.yahoo.sketches.hll.TgtHllType;
+import com.yahoo.sketches.hll.Union;
+
+import org.apache.druid.java.util.common.IAE;
+import org.apache.druid.query.aggregation.AggregateCombiner;
+import org.apache.druid.query.aggregation.AggregatorFactory;
+import org.apache.druid.query.aggregation.ObjectAggregateCombiner;
+import org.apache.druid.query.cache.CacheKeyBuilder;
+import org.apache.druid.segment.ColumnValueSelector;
+
+/**
+ * Base class for both build and merge factories
+ * @author Alexander Saydakov
+ */
+abstract class HllSketchAggregatorFactory extends AggregatorFactory
+{
+
+ static final int DEFAULT_LG_K = 12;
+ static final TgtHllType DEFAULT_TGT_HLL_TYPE = TgtHllType.HLL_4;
+
+ static final Comparator<HllSketch> COMPARATOR = Comparator.nullsFirst(Comparator.comparingDouble(HllSketch::getEstimate));
+
+ private final String name;
+ private final String fieldName;
+ private final int lgK;
+ private final TgtHllType tgtHllType;
+
+ HllSketchAggregatorFactory(final String name, final String fieldName, @Nullable final Integer lgK, @Nullable final String tgtHllType)
+ {
+ if (name == null) {
Review comment:
I think this line is fine the way it is. We don't have a codebase-wide rule about how to handle this stuff, and the way @AlexanderSaydakov did it is within bounds of reasonableness.
(Fwiw, I think if we had a codebase-wide rule for this, it should be geared towards what provides the nicest error messages for users. There are plenty of locations where error messages could be improved.)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org