siddharthteotia commented on a change in pull request #5774: URL: https://github.com/apache/incubator-pinot/pull/5774#discussion_r465794901
########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/recommender/rules/impl/NoDictionaryOnHeapDictionaryJointRule.java ########## @@ -0,0 +1,245 @@ +/** + * 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 com.google.common.util.concurrent.AtomicDouble; +import java.util.HashSet; +import java.util.Set; +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.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.NoDictionaryOnHeapDictionaryJointRuleParams; +import org.apache.pinot.controller.recommender.rules.utils.FixedLenBitset; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static java.lang.Math.max; +import static java.lang.Math.min; +import static org.apache.pinot.controller.recommender.rules.io.params.RecommenderConstants.NoDictionaryOnHeapDictionaryJointRule.*; +import static org.apache.pinot.controller.recommender.rules.io.params.RecommenderConstants.REALTIME; + + +public class NoDictionaryOnHeapDictionaryJointRule extends AbstractRule { Review comment: Please add javadoc and brief explanation of the algorithm (please do this for all rules) ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/recommender/rules/impl/NoDictionaryOnHeapDictionaryJointRule.java ########## @@ -0,0 +1,245 @@ +/** + * 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 com.google.common.util.concurrent.AtomicDouble; +import java.util.HashSet; +import java.util.Set; +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.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.NoDictionaryOnHeapDictionaryJointRuleParams; +import org.apache.pinot.controller.recommender.rules.utils.FixedLenBitset; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static java.lang.Math.max; +import static java.lang.Math.min; +import static org.apache.pinot.controller.recommender.rules.io.params.RecommenderConstants.NoDictionaryOnHeapDictionaryJointRule.*; +import static org.apache.pinot.controller.recommender.rules.io.params.RecommenderConstants.REALTIME; + + +public class NoDictionaryOnHeapDictionaryJointRule extends AbstractRule { + private final Logger LOGGER = LoggerFactory.getLogger(NoDictionaryOnHeapDictionaryJointRule.class); + private final BrokerRequestOptimizer _brokerRequestOptimizer = new BrokerRequestOptimizer(); + private final NoDictionaryOnHeapDictionaryJointRuleParams _params; + + public NoDictionaryOnHeapDictionaryJointRule(InputManager inputManager, ConfigManager outputManager) { + super(inputManager, outputManager); + _params = inputManager.getNoDictionaryOnHeapDictionaryJointRuleParams(); + } + + @Override + public void run() { + LOGGER.info("Recommending no dictionary and on-heap dictionaries"); + + int numCols = _inputManager.getNumCols(); + double[] filterGroupByWeights = new double[numCols]; + double[] selectionWeights = new double[numCols]; + AtomicDouble totalWeight = new AtomicDouble(0); + + //**********No dictionary recommendation*******/ + Set<String> noDictCols = new HashSet<>(_inputManager.getColNameToIntMap().keySet()); + + //Exclude cols with index + noDictCols.removeAll(_outputManager.getIndexConfig().getInvertedIndexColumns()); + noDictCols.removeAll(_outputManager.getIndexConfig().getSortedColumn()); + // TODO: Remove this after range index is implemented for no-dictionary + noDictCols.removeAll(_outputManager.getIndexConfig().getRangeIndexColumns()); + LOGGER.debug("noDictCols {}", noDictCols); + //Find out columns used in filter&groupby and selection and corresponding frequencies + _inputManager.getQueryWeightMap().forEach((query, weight) -> { + parseQuery(query, weight, filterGroupByWeights, selectionWeights); + totalWeight.addAndGet(weight); + }); + + //Add dictionary on columns used in filter&groupby , with frequency > threshold + for (int i = 0; i < numCols; i++) { Review comment: Not sure if I follow this. If the column is in filter and group by, why do we have to consider the frequency? ---------------------------------------------------------------- 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