siddharthteotia commented on a change in pull request #4535: Implement DISTINCT clause URL: https://github.com/apache/incubator-pinot/pull/4535#discussion_r320624053
########## File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/DistinctTable.java ########## @@ -0,0 +1,235 @@ +/** + * 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.core.query.aggregation; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import org.apache.pinot.common.data.FieldSpec; +import org.apache.pinot.common.utils.DataSchema; +import org.apache.pinot.common.utils.DataTable; +import org.apache.pinot.core.common.datatable.DataTableBuilder; +import org.apache.pinot.core.common.datatable.DataTableFactory; +import org.apache.pinot.core.data.table.Key; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This serves the following purposes: + * + * (1) Intermediate result object for Distinct aggregation function + * (2) The same object is serialized by the server inside the data table + * for sending the results to broker. Broker deserializes it. + */ +public class DistinctTable { + private static final Logger LOGGER = LoggerFactory.getLogger(DistinctTable.class); + private final static int INITIAL_CAPACITY = 64000; Review comment: If the user specified limit is small (or in case user didn't specify and we defaulted to 10), then yes 64k is high and wastage. If not (may be the user is aware of the cardinality and appropriately used LIMIT N), then using high initial capacity will reduce the number of resize/rehash. Currently using max initial capacity as 64k and setting the initial capacity as min(max, limit/loadFactor) ---------------------------------------------------------------- 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]
