[ 
https://issues.apache.org/jira/browse/HIVE-25977?focusedWorklogId=737441&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-737441
 ]

ASF GitHub Bot logged work on HIVE-25977:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Mar/22 09:57
            Start Date: 07/Mar/22 09:57
    Worklog Time Spent: 10m 
      Work Description: kgyrtkirk commented on a change in pull request #2971:
URL: https://github.com/apache/hive/pull/2971#discussion_r820544902



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Cleaner.java
##########
@@ -439,29 +440,40 @@ private boolean removeFiles(String location, 
ValidWriteIdList writeIdList, Compa
     return success;
   }
 
-  private boolean hasDataBelowWatermark(FileSystem fs, Path path, long 
highWatermark) throws IOException {
-    FileStatus[] children = fs.listStatus(path);
+  private boolean hasDataBelowWatermark(AcidDirectory acidDir, FileSystem fs, 
Path path, long highWatermark,
+      long minOpenTxn)
+      throws IOException {
+    Set<Path> acidPaths = new HashSet<>();
+    for (ParsedDelta delta : acidDir.getCurrentDirectories()) {
+      acidPaths.add(delta.getPath());
+    }
+    if (acidDir.getBaseDirectory() != null) {
+      acidPaths.add(acidDir.getBaseDirectory());
+    }
+    FileStatus[] children = fs.listStatus(path, p -> {
+      return !acidPaths.contains(p);
+    });
     for (FileStatus child : children) {
-      if (isFileBelowWatermark(child, highWatermark)) {
+      if (isFileBelowWatermark(child, highWatermark, minOpenTxn)) {
         return true;
       }
     }
     return false;
   }
 
-  private boolean isFileBelowWatermark(FileStatus child, long highWatermark) {
+  private boolean isFileBelowWatermark(FileStatus child, long highWatermark, 
long minOpenTxn) {
     Path p = child.getPath();
     String fn = p.getName();
     if (!child.isDirectory()) {
-      return false;
+      return true;
     }
     if (fn.startsWith(AcidUtils.BASE_PREFIX)) {
       ParsedBaseLight b = ParsedBaseLight.parseBase(p);
-      return b.getWriteId() < highWatermark;
+      return b.getWriteId() <= highWatermark && b.getVisibilityTxnId() <= 
minOpenTxn;

Review comment:
       yes - this seemed fishy; this was changed during that zoom call; I 
changed this back to `b.getWriteId() < highWatermark` because I think thats the 
right conditional for this.




-- 
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: gitbox-unsubscr...@hive.apache.org

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 737441)
    Time Spent: 50m  (was: 40m)

> Enhance Compaction Cleaner to skip when there is nothing to do #2
> -----------------------------------------------------------------
>
>                 Key: HIVE-25977
>                 URL: https://issues.apache.org/jira/browse/HIVE-25977
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Zoltan Haindrich
>            Assignee: Zoltan Haindrich
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> initially this was just an addendum to the original patch ; but got delayed 
> and altered - so it should have its own ticket



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to