vikramahuja1001 commented on a change in pull request #4072:
URL: https://github.com/apache/carbondata/pull/4072#discussion_r576568152



##########
File path: 
core/src/main/java/org/apache/carbondata/core/metadata/SegmentFileStore.java
##########
@@ -1126,25 +1130,36 @@ public static void deleteSegmentFile(String tablePath, 
Segment segment) throws E
    * @param partitionSpecs
    * @throws IOException
    */
-  public static void deleteSegment(String tablePath, Segment segment,
+  public static long deleteSegment(String tablePath, Segment segment,
       List<PartitionSpec> partitionSpecs,
       SegmentUpdateStatusManager updateStatusManager) throws Exception {
     SegmentFileStore fileStore = new SegmentFileStore(tablePath, 
segment.getSegmentFileName());
     List<String> indexOrMergeFiles = 
fileStore.readIndexFiles(SegmentStatus.SUCCESS, true,
         FileFactory.getConfiguration());
+    long sizeFreed = 0;
     Map<String, List<String>> indexFilesMap = fileStore.getIndexFilesMap();
     for (Map.Entry<String, List<String>> entry : indexFilesMap.entrySet()) {
-      FileFactory.deleteFile(entry.getKey());
+      CarbonFile entryCarbonFile = FileFactory.getCarbonFile(entry.getKey());
+      sizeFreed += entryCarbonFile.getSize();

Review comment:
       done

##########
File path: 
core/src/main/java/org/apache/carbondata/core/metadata/SegmentFileStore.java
##########
@@ -1126,25 +1130,36 @@ public static void deleteSegmentFile(String tablePath, 
Segment segment) throws E
    * @param partitionSpecs
    * @throws IOException
    */
-  public static void deleteSegment(String tablePath, Segment segment,
+  public static long deleteSegment(String tablePath, Segment segment,
       List<PartitionSpec> partitionSpecs,
       SegmentUpdateStatusManager updateStatusManager) throws Exception {
     SegmentFileStore fileStore = new SegmentFileStore(tablePath, 
segment.getSegmentFileName());
     List<String> indexOrMergeFiles = 
fileStore.readIndexFiles(SegmentStatus.SUCCESS, true,
         FileFactory.getConfiguration());
+    long sizeFreed = 0;
     Map<String, List<String>> indexFilesMap = fileStore.getIndexFilesMap();
     for (Map.Entry<String, List<String>> entry : indexFilesMap.entrySet()) {
-      FileFactory.deleteFile(entry.getKey());
+      CarbonFile entryCarbonFile = FileFactory.getCarbonFile(entry.getKey());
+      sizeFreed += entryCarbonFile.getSize();
+      FileFactory.deleteFile(entryCarbonFile);
+      LOGGER.info("File deleted after clean files operation: " + 
entry.getKey());
       for (String file : entry.getValue()) {
         String[] deltaFilePaths =
             updateStatusManager.getDeleteDeltaFilePath(file, 
segment.getSegmentNo());
         for (String deltaFilePath : deltaFilePaths) {
-          FileFactory.deleteFile(deltaFilePath);
+          CarbonFile deltaCarbonFile = 
FileFactory.getCarbonFile(deltaFilePath);
+          sizeFreed += deltaCarbonFile.getSize();
+          FileFactory.deleteFile(deltaCarbonFile);
+          LOGGER.info("File deleted after clean files operation: " + 
deltaFilePath);
         }
-        FileFactory.deleteFile(file);
+        CarbonFile deleteCarbonFile = FileFactory.getCarbonFile(file);
+        sizeFreed += deleteCarbonFile.getSize();
+        FileFactory.deleteFile(deleteCarbonFile);

Review comment:
       yes, good idea. Changed it




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


Reply via email to