clintropolis commented on code in PR #15700:
URL: https://github.com/apache/druid/pull/15700#discussion_r1457413240


##########
processing/src/main/java/org/apache/druid/query/aggregation/SingleValueDoubleAggregatorFactory.java:
##########
@@ -0,0 +1,131 @@
+/*
+ * 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;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import org.apache.druid.segment.BaseDoubleColumnValueSelector;
+import org.apache.druid.segment.ColumnSelectorFactory;
+import org.apache.druid.segment.column.ColumnType;
+
+import javax.annotation.Nullable;
+import java.util.Objects;
+
+@JsonTypeName("singleValueDouble")
+public class SingleValueDoubleAggregatorFactory extends 
SingleValueAggregatorFactory
+{
+
+  @JsonCreator
+  public SingleValueDoubleAggregatorFactory(
+      @JsonProperty("name") String name,
+      @JsonProperty("fieldName") final String fieldName
+  )
+  {
+    super(name, fieldName);
+  }
+
+  @Override
+  public Aggregator factorize(ColumnSelectorFactory metricFactory)
+  {
+    final BaseDoubleColumnValueSelector valueSelector = 
metricFactory.makeColumnValueSelector(getFieldName());

Review Comment:
   instead of a separate aggregator factory for each type, why not call 
`metricFactory.getColumnCapabilities(getFieldName())` and pick the right type 
of aggregator.
   
   even further, do we even need aggs/buffer aggs for each type? Given that the 
typed aggs all appear to be storing values as Objects instead of java numeric 
primitives, why not just have a single `Aggregator` and `BufferAggregator` 
implementation. For the `BufferAggregator`, you could pass the `ColumnType` 
converted from `getColumnCapabilities` and use `.getNullableStrategy()` to 
write and read the value from the buffer.
   
   This seems like a lot of classes for something that is basically a value 
holder...



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to