Indhumathi27 commented on code in PR #4276:
URL: https://github.com/apache/carbondata/pull/4276#discussion_r914672717


##########
core/src/main/java/org/apache/carbondata/core/util/TrashUtil.java:
##########
@@ -268,4 +268,44 @@ public static String getCompleteTrashFolderPath(String 
tablePath, long timeStamp
       timeStampSubFolder + CarbonCommonConstants.FILE_SEPARATOR + 
CarbonTablePath
       .SEGMENT_PREFIX + segmentNumber;
   }
+
+  /**
+   * This will give the complete path of the trash folder with the timestamp 
and the partition name
+   *
+   * @param tablePath          absolute table path
+   * @param timeStampSubFolder the timestamp for the clean files operation
+   * @param partitionName      partition name for which files are moved to the 
trash folder
+   */
+  public static String getCompleteTrashFolderPathForPartition(String tablePath,
+      long timeStampSubFolder, String partitionName) {
+    return CarbonTablePath.getTrashFolderPath(tablePath) + 
CarbonCommonConstants.FILE_SEPARATOR
+        + timeStampSubFolder + CarbonCommonConstants.FILE_SEPARATOR
+        + CarbonTablePath.DATA_PART_PREFIX + partitionName;

Review Comment:
   CarbonTablePath.DATA_PART_PREFIX is not needed to make partition path



##########
core/src/main/java/org/apache/carbondata/core/util/TrashUtil.java:
##########
@@ -268,4 +268,44 @@ public static String getCompleteTrashFolderPath(String 
tablePath, long timeStamp
       timeStampSubFolder + CarbonCommonConstants.FILE_SEPARATOR + 
CarbonTablePath
       .SEGMENT_PREFIX + segmentNumber;
   }
+
+  /**
+   * This will give the complete path of the trash folder with the timestamp 
and the partition name
+   *
+   * @param tablePath          absolute table path
+   * @param timeStampSubFolder the timestamp for the clean files operation
+   * @param partitionName      partition name for which files are moved to the 
trash folder
+   */
+  public static String getCompleteTrashFolderPathForPartition(String tablePath,
+      long timeStampSubFolder, String partitionName) {
+    return CarbonTablePath.getTrashFolderPath(tablePath) + 
CarbonCommonConstants.FILE_SEPARATOR
+        + timeStampSubFolder + CarbonCommonConstants.FILE_SEPARATOR
+        + CarbonTablePath.DATA_PART_PREFIX + partitionName;
+  }
+
+  /**
+   * The below method copies dropped partition files to the trash folder.
+   *
+   * @param filesToCopy              absolute path of the files to copy to the 
trash folder
+   * @param trashFolderWithTimestamp trashfolderpath with complete timestamp 
and segment number
+   */
+  public static void copyFilesToTrash(String filesToCopy, String 
trashFolderWithTimestamp)
+      throws IOException, InterruptedException {

Review Comment:
   invalid method exception definition. Please remove



##########
core/src/main/java/org/apache/carbondata/core/util/TrashUtil.java:
##########
@@ -268,4 +268,44 @@ public static String getCompleteTrashFolderPath(String 
tablePath, long timeStamp
       timeStampSubFolder + CarbonCommonConstants.FILE_SEPARATOR + 
CarbonTablePath
       .SEGMENT_PREFIX + segmentNumber;
   }
+
+  /**
+   * This will give the complete path of the trash folder with the timestamp 
and the partition name
+   *
+   * @param tablePath          absolute table path
+   * @param timeStampSubFolder the timestamp for the clean files operation
+   * @param partitionName      partition name for which files are moved to the 
trash folder
+   */
+  public static String getCompleteTrashFolderPathForPartition(String tablePath,
+      long timeStampSubFolder, String partitionName) {
+    return CarbonTablePath.getTrashFolderPath(tablePath) + 
CarbonCommonConstants.FILE_SEPARATOR
+        + timeStampSubFolder + CarbonCommonConstants.FILE_SEPARATOR
+        + CarbonTablePath.DATA_PART_PREFIX + partitionName;
+  }
+
+  /**
+   * The below method copies dropped partition files to the trash folder.
+   *
+   * @param filesToCopy              absolute path of the files to copy to the 
trash folder
+   * @param trashFolderWithTimestamp trashfolderpath with complete timestamp 
and segment number
+   */
+  public static void copyFilesToTrash(String filesToCopy, String 
trashFolderWithTimestamp)
+      throws IOException, InterruptedException {
+    try {
+      if (!FileFactory.isFileExist(trashFolderWithTimestamp)) {
+        FileFactory.mkdirs(trashFolderWithTimestamp);
+      }
+      // check if file exists before copying
+      if (FileFactory.isFileExist(filesToCopy)) {
+        CarbonFile folder = FileFactory.getCarbonFile(filesToCopy);
+        CarbonFile[] dataFiles = folder.listFiles();
+        for (CarbonFile carbonFile : dataFiles) {
+          copyFileToTrashFolder(carbonFile.getAbsolutePath(), 
trashFolderWithTimestamp);
+        }
+      }

Review Comment:
   can log the warning message if the statement `if 
(FileFactory.isFileExist(filesToCopy)) {` is false



-- 
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: dev-unsubscr...@carbondata.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to