jasperjiaguo commented on a change in pull request #4474: An auto recommendation for inverted index URL: https://github.com/apache/incubator-pinot/pull/4474#discussion_r309351529
########## File path: pinot-tools/src/main/java/org/apache/pinot/tools/tuner/meta/manager/collector/ColStatsAccumulatorObj.java ########## @@ -0,0 +1,142 @@ +/** + * 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.tools.tuner.meta.manager.collector; + +import java.math.BigInteger; +import java.util.HashMap; +import java.util.Map; +import org.apache.pinot.tools.tuner.meta.manager.MetaManager; +import org.apache.pinot.tools.tuner.strategy.AbstractAccumulator; + + +/** + * Accumulator for relevant fields in metadata.properties and index_map + */ +public class ColStatsAccumulatorObj extends AbstractAccumulator { + + Map<String, BigInteger> accumulatedStats = new HashMap<>(); + Map<String, Map<String, String>> segmentStats = new HashMap<>(); + + private static final String CARDINALITY = "cardinality"; + private static final String TOTAL_DOCS = "totalDocs"; + private static final String TOTAL_NUMBER_OF_ENTRIES = "totalNumberOfEntries"; + private static final String IS_SORTED = "isSorted"; + private static final String INVERTED_INDEX_SIZE = "invertedIndexSize"; + + @Override + public String toString() { + return "ColStatsAccumulatorObj{" + "accumulatedStats=" + accumulatedStats + ", segmentStats=" + segmentStats + '}'; + } + + private String _segmentName; + private String _cardinality; + private String _totalDocs; + private String _totalNumberOfEntries; + private String _isSorted; + private String _invertedIndexSize; + + public Map<String, BigInteger> getAccumulatedStats() { + return accumulatedStats; + } + + public Map<String, Map<String, String>> getSegmentStats() { + return segmentStats; + } + + public ColStatsAccumulatorObj addInvertedIndexSize(String invertedIndexSize) { + _invertedIndexSize = invertedIndexSize; + return this; + } + + public ColStatsAccumulatorObj addSegmentName(String segmentName) { + _segmentName = segmentName; + return this; + } + + public ColStatsAccumulatorObj addCardinality(String cardinality) { + _cardinality = cardinality; + return this; + } + + public ColStatsAccumulatorObj addTotalDocs(String totalDocs) { + _totalDocs = totalDocs; + return this; + } + + public ColStatsAccumulatorObj addTotalNumberOfEntries(String totalNumberOfEntries) { + _totalNumberOfEntries = totalNumberOfEntries; + return this; + } + + public ColStatsAccumulatorObj addIsSorted(String isSorted) { + _isSorted = isSorted; + return this; + } + + public void merge() { Review comment: I wrote it this way so that when merging the code is like following, which I think is more readable than a function with a long parameter list .addInvertedIndexSize(invertedIndexSize) .addIsSorted(isSorted) .addSegmentName(pathWrapper.getFile().getName()) .addTotalDocs(totalDocs) .addTotalNumberOfEntries(totalNumberOfEntries) .merge(); ---------------------------------------------------------------- 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]
