henrib commented on code in PR #4820:
URL: https://github.com/apache/hive/pull/4820#discussion_r1371643012


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/events/AlterPartitionsEvent.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.hadoop.hive.metastore.events;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.hive.metastore.IHMSHandler;
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.Table;
+
+import static java.util.Objects.requireNonNull;
+
[email protected]
[email protected]
+public class AlterPartitionsEvent extends ListenerEvent {
+
+  private final List<Partition> old_parts;
+  private final List<Partition> new_parts;
+  private final Table table;
+  private final boolean isTruncateOp;
+
+  public AlterPartitionsEvent(List<Partition> old_parts, List<Partition> 
new_parts, Table table,
+      boolean isTruncateOp, boolean status, IHMSHandler handler) {
+    super(status, handler);
+    this.old_parts = requireNonNull(old_parts, "old_parts is null");
+    this.new_parts = requireNonNull(new_parts, "new_parts is null");
+    this.table = requireNonNull(table, "table is null");
+    this.isTruncateOp = isTruncateOp;
+  }
+
+  /**
+   * @return The table.
+   */
+  public Table getTable() {
+    return table;
+  }
+
+  /**
+   * @return Iterator for new partitions.
+   */
+  public Iterator<List<Partition>> getNewPartsIterator(int batchSize) {
+    return iteratePartitions(new_parts, batchSize);
+  }
+
+  private Iterator<List<Partition>> iteratePartitions(List<Partition> 
partitions,
+      final int batchSize) {
+    Map<Long, List<Partition>> writeIdToParts = new HashMap<>();
+    partitions.forEach(partition -> {

Review Comment:
   Following lines could be simplified with:
   writeIdToParts.computeIfAbsent(writeId, k -> new 
ArrayList<>()).add(partition);



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