tibrewalpratik17 commented on code in PR #14477:
URL: https://github.com/apache/pinot/pull/14477#discussion_r1881381828


##########
pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/upsertcompactmerge/UpsertCompactMergeTaskGenerator.java:
##########
@@ -0,0 +1,424 @@
+/**
+ * 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.upsertcompactmerge;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.BiMap;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.helix.task.TaskState;
+import org.apache.pinot.common.exception.InvalidConfigException;
+import org.apache.pinot.common.metadata.segment.SegmentZKMetadata;
+import org.apache.pinot.common.restlet.resources.ValidDocIdsMetadataInfo;
+import org.apache.pinot.common.restlet.resources.ValidDocIdsType;
+import org.apache.pinot.common.utils.SegmentUtils;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import 
org.apache.pinot.controller.helix.core.minion.generator.BaseTaskGenerator;
+import 
org.apache.pinot.controller.helix.core.minion.generator.TaskGeneratorUtils;
+import org.apache.pinot.controller.util.ServerSegmentMetadataReader;
+import org.apache.pinot.core.common.MinionConstants;
+import org.apache.pinot.core.minion.PinotTaskConfig;
+import org.apache.pinot.spi.annotations.minion.TaskGenerator;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.config.table.UpsertConfig;
+import org.apache.pinot.spi.utils.TimeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+@TaskGenerator
+public class UpsertCompactMergeTaskGenerator extends BaseTaskGenerator {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(UpsertCompactMergeTaskGenerator.class);
+  private static final String DEFAULT_BUFFER_PERIOD = "2d";
+  private static final int DEFAULT_NUM_SEGMENTS_BATCH_PER_SERVER_REQUEST = 500;
+
+  public static class SegmentMergerMetadata {
+    private final SegmentZKMetadata _segmentZKMetadata;
+    private final long _validDocIds;
+    private final long _invalidDocIds;
+
+    SegmentMergerMetadata(SegmentZKMetadata segmentZKMetadata, long 
validDocIds, long invalidDocIds) {
+      _segmentZKMetadata = segmentZKMetadata;
+      _validDocIds = validDocIds;
+      _invalidDocIds = invalidDocIds;
+    }
+
+    public SegmentZKMetadata getSegmentZKMetadata() {
+      return _segmentZKMetadata;
+    }
+
+    public long getValidDocIds() {
+      return _validDocIds;
+    }
+
+    public long getInvalidDocIds() {
+      return _invalidDocIds;
+    }
+  }
+
+  public static class SegmentSelectionResult {
+
+    private final Map<Integer, List<List<SegmentMergerMetadata>>> 
_segmentsForCompactMergeByPartition;
+
+    private final List<String> _segmentsForDeletion;
+
+    SegmentSelectionResult(Map<Integer, List<List<SegmentMergerMetadata>>> 
segmentsForCompactMergeByPartition,
+        List<String> segmentsForDeletion) {
+      _segmentsForCompactMergeByPartition = segmentsForCompactMergeByPartition;
+      _segmentsForDeletion = segmentsForDeletion;
+    }
+
+    public Map<Integer, List<List<SegmentMergerMetadata>>> 
getSegmentsForCompactMergeByPartition() {
+      return _segmentsForCompactMergeByPartition;
+    }
+
+    public List<String> getSegmentsForDeletion() {
+      return _segmentsForDeletion;
+    }
+  }
+
+  @Override
+  public String getTaskType() {
+    return MinionConstants.UpsertCompactMergeTask.TASK_TYPE;
+  }
+
+  @Override
+  public List<PinotTaskConfig> generateTasks(List<TableConfig> tableConfigs) {
+    String taskType = MinionConstants.UpsertCompactMergeTask.TASK_TYPE;
+    List<PinotTaskConfig> pinotTaskConfigs = new ArrayList<>();
+    for (TableConfig tableConfig : tableConfigs) {
+

Review Comment:
   yes agreed! let me do this in a follow-up.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to