[GitHub] [carbondata] ravipesala commented on a change in pull request #3355: [HOTFIX] Improve select query after Update/Delete operation.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ravipesala commented on a change in pull request #3355: [HOTFIX] Improve select query after Update/Delete operation.

GitBox
ravipesala commented on a change in pull request #3355: [HOTFIX] Improve select query after Update/Delete operation.
URL: https://github.com/apache/carbondata/pull/3355#discussion_r312968720
 
 

 ##########
 File path: core/src/main/java/org/apache/carbondata/core/statusmanager/SegmentUpdateStatusManager.java
 ##########
 @@ -358,40 +333,40 @@ public boolean isBlockValid(String segName, String blockName) {
     return deleteFileList;
   }
 
-  private List<String> getFilePaths(CarbonFile blockDir, final String blockNameFromTuple,
+  private List<String> getFilePaths(String blockDir, final String blockNameFromTuple,
       final String extension, List<String> deleteFileList, final long deltaStartTimestamp,
       final long deltaEndTimeStamp) throws IOException {
-    if (null != blockDir.getParentFile()) {
-      CarbonFile[] files = blockDir.getParentFile().listFiles(new CarbonFileFilter() {
-
-        @Override
-        public boolean accept(CarbonFile pathName) {
+    List<String> deltaList = segmentDeleteDeltaListMap.get(blockDir);
+    if (deltaList == null) {
+      CarbonFile[] files = FileFactory.getCarbonFile(blockDir).listFiles(new CarbonFileFilter() {
+        @Override public boolean accept(CarbonFile pathName) {
           String fileName = pathName.getName();
           if (fileName.endsWith(extension) && pathName.getSize() > 0) {
-            String firstPart = fileName.substring(0, fileName.lastIndexOf('.'));
-            String blockName =
-                firstPart.substring(0, firstPart.lastIndexOf(CarbonCommonConstants.HYPHEN));
-            long timestamp = Long.parseLong(firstPart
-                .substring(firstPart.lastIndexOf(CarbonCommonConstants.HYPHEN) + 1,
-                    firstPart.length()));
-            if (blockNameFromTuple.equals(blockName) && (
-                (Long.compare(timestamp, deltaEndTimeStamp) <= 0) && (
-                    Long.compare(timestamp, deltaStartTimestamp) >= 0))) {
-              return true;
-            }
+            return true;
           }
           return false;
         }
       });
-
+      deltaList = new ArrayList<>(files.length);
       for (CarbonFile cfile : files) {
+        deltaList.add(cfile.getCanonicalPath());
+      }
+      segmentDeleteDeltaListMap.put(blockDir, deltaList);
+    }
+    for (String deltaFile : deltaList) {
+      String deltaFilePathName = new Path(deltaFile).getName();
+      String firstPart = deltaFilePathName.substring(0, deltaFilePathName.lastIndexOf('.'));
+      String blockName =
+          firstPart.substring(0, firstPart.lastIndexOf(CarbonCommonConstants.HYPHEN));
+      long timestamp = Long.parseLong(firstPart
+          .substring(firstPart.lastIndexOf(CarbonCommonConstants.HYPHEN) + 1, firstPart.length()));
+      if (blockNameFromTuple.equals(blockName) && ((Long.compare(timestamp, deltaEndTimeStamp) <= 0)
+          && (Long.compare(timestamp, deltaStartTimestamp) >= 0))) {
 
 Review comment:
   No, it is not redundant, both compare different timestamps.

----------------------------------------------------------------
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:
[hidden email]


With regards,
Apache Git Services