krishan1390 commented on code in PR #16845: URL: https://github.com/apache/pinot/pull/16845#discussion_r2403684423
########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/stats/NoDictColumnStatisticsCollector.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.pinot.segment.local.segment.creator.impl.stats; + +import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; +import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.pinot.segment.spi.creator.StatsCollectorConfig; +import org.apache.pinot.spi.utils.BigDecimalUtils; +import org.apache.pinot.spi.utils.ByteArray; +import org.apache.pinot.spi.utils.CommonConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * Column statistics collector for no-dictionary columns that avoids storing unique values and thus reduces memory + * Behavior: + * - getUniqueValuesSet() throws NotImplementedException + * - getCardinality() returns approximate cardinality using HLL++ + * - Doesn't handle cases where values are of different types (e.g. int and long). This is expected. + * Individual type collectors (e.g. IntColumnPreIndexStatsCollector) also don't handle this case. + * At this point in the Pinot process, the type consistency of a key should already be enforced. + * So if such a case is encountered, it will be raised as an exception during collect() + * Doesn't handle MAP data type as MapColumnPreIndexStatsCollector is optimized for no-dictionary collection + */ +@SuppressWarnings({"rawtypes"}) +public class NoDictColumnStatisticsCollector extends AbstractColumnStatisticsCollector { Review Comment: Initially I had added the noDict handling to each collector. But that required modifying each class to make more and more changes (like adding HLL / ULL, or changing behaviour of getUniqueValuesSet() , etc) So moved to common class to handle noDict uniformly. There are tradeoffs in both approach but I think having in 1 class has made it easy to iterate on this. I have tested with all data types in the test class. -- 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]
