yihua commented on code in PR #13007:
URL: https://github.com/apache/hudi/pull/13007#discussion_r2017625871


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/rollback/BaseRollbackHelperTableVersionSix.java:
##########
@@ -0,0 +1,332 @@
+/*
+ * 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.hudi.table.action.rollback;
+
+import org.apache.hudi.avro.model.HoodieRollbackRequest;
+import org.apache.hudi.common.HoodieRollbackStat;
+import org.apache.hudi.common.data.HoodiePairData;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.engine.TaskContextSupplier;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.function.SerializableFunction;
+import org.apache.hudi.common.function.SerializablePairFunction;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.model.IOType;
+import org.apache.hudi.common.table.HoodieTableVersion;
+import org.apache.hudi.common.table.log.HoodieLogFormat;
+import org.apache.hudi.common.table.log.LogFileCreationCallback;
+import org.apache.hudi.common.table.log.block.HoodieCommandBlock;
+import org.apache.hudi.common.table.log.block.HoodieLogBlock;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.StringUtils;
+import org.apache.hudi.common.util.collection.Pair;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieIOException;
+import org.apache.hudi.exception.HoodieRollbackException;
+import org.apache.hudi.storage.HoodieStorage;
+import org.apache.hudi.storage.HoodieStorageUtils;
+import org.apache.hudi.storage.StorageConfiguration;
+import org.apache.hudi.storage.StoragePath;
+import org.apache.hudi.storage.StoragePathInfo;
+import org.apache.hudi.table.HoodieTable;
+import org.apache.hudi.table.marker.WriteMarkers;
+import org.apache.hudi.table.marker.WriteMarkersFactory;
+import org.apache.hudi.util.CommonClientUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static 
org.apache.hudi.table.action.rollback.RollbackUtils.groupSerializableRollbackRequestsBasedOnFileGroup;
+
+/**
+ * Contains common methods to be used across engines for rollback operation.
+ * This class is meant to be used only for table version 6. Any table version 
8 and above will be using {@link BaseRollbackHelper}.
+ */
+public class BaseRollbackHelperTableVersionSix extends BaseRollbackHelper {

Review Comment:
   Could you show a line-by-line comparison with `BaseRollbackHelper` and point 
out the differences?  Could those be abstracted out with marker handler?



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/rollback/ListingBasedRollbackStrategy.java:
##########
@@ -162,9 +162,16 @@ public List<HoodieRollbackRequest> 
getRollbackRequests(HoodieInstant instantToRo
                     
listBaseFilesToBeDeleted(instantToRollback.requestedTime(), baseFileExtension, 
partitionPath, metaClient.getStorage())));
               } else {
                 // if this is part of a restore operation, we should 
rollback/delete entire file slice.
-                
hoodieRollbackRequests.addAll(getHoodieRollbackRequests(partitionPath,
-                    listAllFilesSinceCommit(instantToRollback.requestedTime(), 
baseFileExtension, partitionPath,
-                        metaClient)));
+                if 
(metaClient.getTableConfig().getTableVersion().lesserThan(HoodieTableVersion.EIGHT))
 {
+                  // For table version 6, the files can be directly fetched 
from the instant to rollback
+                  
hoodieRollbackRequests.addAll(getHoodieRollbackRequests(partitionPath, 
filesToDelete.get()));
+                } else {
+                  // For table version 8, the files are computed based on 
completion time. All files completed after
+                  // the requested time of instant to rollback are included
+                  
hoodieRollbackRequests.addAll(getHoodieRollbackRequests(partitionPath,
+                      
listAllFilesSinceCommit(instantToRollback.requestedTime(), baseFileExtension, 
partitionPath,
+                          metaClient)));
+                }

Review Comment:
   ```suggestion
                     
hoodieRollbackRequests.addAll(getHoodieRollbackRequests(partitionPath, 
(<condition>)? .. : ..));
                   }
   ```



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

Reply via email to