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 2020/01/17 02:57:53 UTC
[GitHub] [druid] jon-wei commented on a change in pull request #9183: fix
topn aggregation on numeric columns with null values
jon-wei commented on a change in pull request #9183: fix topn aggregation on numeric columns with null values
URL: https://github.com/apache/druid/pull/9183#discussion_r367748677
##########
File path: processing/src/main/java/org/apache/druid/query/topn/types/NullableNumericTopNColumnAggregatesProcessor.java
##########
@@ -0,0 +1,137 @@
+/*
+ * 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.topn.types;
+
+import org.apache.druid.common.config.NullHandling;
+import org.apache.druid.query.aggregation.Aggregator;
+import org.apache.druid.query.topn.BaseTopNAlgorithm;
+import org.apache.druid.query.topn.TopNParams;
+import org.apache.druid.query.topn.TopNQuery;
+import org.apache.druid.query.topn.TopNResultBuilder;
+import org.apache.druid.segment.BaseNullableColumnValueSelector;
+import org.apache.druid.segment.Cursor;
+import org.apache.druid.segment.StorageAdapter;
+
+import java.util.Map;
+import java.util.function.Function;
+
+public abstract class NullableNumericTopNColumnAggregatesProcessor<Selector extends BaseNullableColumnValueSelector>
+ implements TopNColumnAggregatesProcessor<Selector>
+{
+ private final boolean hasNulls = !NullHandling.replaceWithDefault();
+ final Function<Object, Comparable<?>> converter;
+ Aggregator[] nullValueAggregates;
+
+ protected NullableNumericTopNColumnAggregatesProcessor(Function<Object, Comparable<?>> converter)
+ {
+ this.converter = converter;
+ }
+
+ abstract Aggregator[] getValueAggregators(TopNQuery query, Selector selector, Cursor cursor);
+
+ abstract Map<?, Aggregator[]> getAggregatesStore();
+
+ abstract Comparable<?> convertAggregatorStoreKeyToColumnValue(Object aggregatorStoreKey);
+
+ @Override
+ public int getCardinality(Selector selector)
+ {
+ return TopNParams.CARDINALITY_UNKNOWN;
+ }
+
+ @Override
+ public Aggregator[][] getRowSelector(TopNQuery query, TopNParams params, StorageAdapter storageAdapter)
+ {
+ return null;
+ }
+
+ @Override
+ public long scanAndAggregate(
+ TopNQuery query,
+ Selector selector,
+ Cursor cursor,
+ Aggregator[][] rowSelector
+ )
+ {
+ initAggregateStore();
Review comment:
I think the `initAggregateStore` call could be moved into `HeapBasedTopNAlgorithm.scanAndAggregate` since both impls call it as the first step
----------------------------------------------------------------
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:
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