jtao15 commented on a change in pull request #6932: URL: https://github.com/apache/incubator-pinot/pull/6932#discussion_r640997717
########## File path: pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/merge_rollup/MergeRollupTaskUtils.java ########## @@ -0,0 +1,119 @@ +/** + * 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.plugin.minion.tasks.merge_rollup; + +import com.google.common.base.Preconditions; +import java.util.HashMap; +import java.util.Map; +import org.apache.commons.lang3.StringUtils; +import org.apache.pinot.common.minion.MergeRollupTaskMetadata; +import org.apache.pinot.core.common.MinionConstants; +import org.apache.pinot.core.segment.processing.collector.ValueAggregatorFactory; +import org.apache.pinot.pql.parsers.utils.Pair; +import org.apache.pinot.spi.utils.TimeUtils; + + +public class MergeRollupTaskUtils { + + public static class MergeProperties { + private final long _bufferMs; + private final long _maxNumRecordsPerSegment; + private final long _maxNumRecordsPerTask; + + public MergeProperties(long bufferMs, long maxNumRecordsPerSegment, long maxNumRecordsPerTask) { + _bufferMs = bufferMs; + _maxNumRecordsPerSegment = maxNumRecordsPerSegment; + _maxNumRecordsPerTask = maxNumRecordsPerTask; + } + + public long getBufferMs() { + return _bufferMs; + } + + public long getMaxNumRecordsPerSegment() { + return _maxNumRecordsPerSegment; + } + + public long getMaxNumRecordsPerTask() { + return _maxNumRecordsPerTask; + } + } + + private static final String[] validMergeProperties = { + MinionConstants.MergeRollupTask.BUFFER_TIME, + MinionConstants.MergeRollupTask.MAX_NUM_RECORDS_PER_SEGMENT, + MinionConstants.MergeRollupTask.MAX_NUM_RECORDS_PER_TASK + }; + + public static Map<String, ValueAggregatorFactory.ValueAggregatorType> getRollupAggregationTypeMap(Map<String, String> mergeRollupConfig) { + Map<String, ValueAggregatorFactory.ValueAggregatorType> rollupAggregationTypeMap = new HashMap<>(); + for (Map.Entry<String, String> entry : mergeRollupConfig.entrySet()) { + if (entry.getKey().startsWith(MinionConstants.MergeRollupTask.AGGREGATE_KEY_PREFIX)) { + rollupAggregationTypeMap.put(getAggregateColumn(entry.getKey()), + ValueAggregatorFactory.ValueAggregatorType.valueOf(entry.getValue().toUpperCase())); + } + } + return rollupAggregationTypeMap; + } + + public static Map<MergeRollupTaskMetadata.Granularity, MergeProperties> getAllMergeProperties(Map<String, String> mergeRollupConfig) { + Map<MergeRollupTaskMetadata.Granularity, Map<String, String>> mergePropertiesMap = new HashMap<>(); + for (Map.Entry<String, String> entry : mergeRollupConfig.entrySet()) { + if (entry.getKey().startsWith(MinionConstants.MergeRollupTask.MERGE_KEY_PREFIX)) { + Pair<MergeRollupTaskMetadata.Granularity, String> pair = getGranularityAndPropertyPair(entry.getKey()); + MergeRollupTaskMetadata.Granularity granularity = pair.getFirst(); + String mergeProperty = pair.getSecond(); + mergePropertiesMap.putIfAbsent(granularity, new HashMap<>()); + mergePropertiesMap.get(granularity).put(mergeProperty, entry.getValue()); + } + } + + Map<MergeRollupTaskMetadata.Granularity, MergeProperties> allMergeProperties = new HashMap<>(); + for (Map.Entry<MergeRollupTaskMetadata.Granularity, Map<String, String>> entry : mergePropertiesMap.entrySet()) { + Map<String, String> properties = entry.getValue(); + MergeProperties mergeProperties = new MergeProperties( + TimeUtils.convertPeriodToMillis(properties.get(MinionConstants.MergeRollupTask.BUFFER_TIME)), Review comment: Added -- 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