siddharthteotia commented on a change in pull request #5774: URL: https://github.com/apache/incubator-pinot/pull/5774#discussion_r465834951
########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/recommender/rules/impl/PinotTablePartitionRule.java ########## @@ -0,0 +1,228 @@ +/** + * 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.controller.recommender.rules.impl; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.pinot.common.request.BrokerRequest; +import org.apache.pinot.core.query.request.context.ExpressionContext; +import org.apache.pinot.core.query.request.context.FilterContext; +import org.apache.pinot.core.query.request.context.QueryContext; +import org.apache.pinot.core.query.request.context.predicate.InPredicate; +import org.apache.pinot.core.query.request.context.predicate.Predicate; +import org.apache.pinot.core.query.request.context.utils.BrokerRequestToQueryContextConverter; +import org.apache.pinot.core.requesthandler.BrokerRequestOptimizer; +import org.apache.pinot.core.requesthandler.PinotQueryParserFactory; +import org.apache.pinot.parsers.AbstractCompiler; +import org.apache.pinot.sql.parsers.SqlCompilationException; +import org.apache.pinot.controller.recommender.io.ConfigManager; +import org.apache.pinot.controller.recommender.io.InputManager; +import org.apache.pinot.controller.recommender.rules.AbstractRule; +import org.apache.pinot.controller.recommender.rules.io.params.PartitionRuleParams; +import org.apache.pinot.controller.recommender.rules.utils.FixedLenBitset; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.apache.pinot.controller.recommender.rules.io.params.RecommenderConstants.*; + + +public class PinotTablePartitionRule extends AbstractRule { + private final Logger LOGGER = LoggerFactory.getLogger(PinotTablePartitionRule.class); + PartitionRuleParams _params; + + protected final BrokerRequestOptimizer _brokerRequestOptimizer = new BrokerRequestOptimizer(); + + public PinotTablePartitionRule(InputManager inputManager, ConfigManager outputManager) { + super(inputManager, outputManager); + this._params = inputManager.getPartitionRuleParams(); + } + + @Override + public void run() { + //**********Calculate size per record***************/ + _inputManager.estimateSizePerRecord(); + //**************************************************/ + + LOGGER.info("Recommending partition configurations"); + + if (_inputManager.getQps() + < _params.THRESHOLD_MIN_QPS_PARTITION) { //For a table whose QPS < Q (say 200 or 300) NO partitioning is needed. + LOGGER.info("*Input QPS {} < threshold {}, no partition needed", _inputManager.getQps(), + _params.THRESHOLD_MIN_QPS_PARTITION); + return; + } + if (_inputManager.getLatencySLA() + > _params.THRESHOLD_MAX_SLA_PARTITION) { //For a table whose latency SLA > L (say 1000ms) NO partitioning is needed. + LOGGER.info("*Input SLA {} > threshold {}, no partition needed", _inputManager.getLatencySLA(), + _params.THRESHOLD_MAX_SLA_PARTITION); + return; + } + + LOGGER.info("*Recommending partition number"); + if (_inputManager.getTableType().equalsIgnoreCase( + REALTIME)) { //real time partition num should be the same value as the number of kafka partitions + _outputManager.getPartitionConfig() + .setNumPartitionsRealtime(_outputManager.getPartitionConfig().getNumKafkaPartitions()); + } else if (_inputManager.getTableType().equalsIgnoreCase(OFFLINE)) { Review comment: It will also be very useful for reference to quote the study and analysis we had done for use case at Li. Please don't quote the table names. However, we should include the following general comments: - For realtime/hybrid, the number of partitions on realtime Pinot table side is same as number of kafka partitions. This is generally the case unless there is a reason for them to be different. We saw one outlier - For offline, the number of partitions on offline Pinot table side is dependent on the amount of data. For hybrid table, we have seen cases where this value = number of kafka partitions = number of realtime table partitions. For hybrid table, we have also seen cases, where the value for offline is lower than realtime since the data generated on a given day is low volume and using a high count of number of partitions would lead to too many small sized segments since we typically have data from one partition in a segment. ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org