wchevreuil commented on code in PR #7124:
URL: https://github.com/apache/hbase/pull/7124#discussion_r2194686303


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/DateTieredCompactionPolicy.java:
##########
@@ -178,9 +160,55 @@ public boolean 
shouldPerformMajorCompaction(Collection<HStoreFile> filesToCompac
         + " (min " + comConf.getMinLocalityToForceCompact() + ")");
       return true;
     }
+    return false;
+  }
 
-    LOG.debug(
-      "Skipping major compaction of " + this + ", because the files are 
already major compacted");
+  @Override
+  public boolean shouldPerformMajorCompaction(Collection<HStoreFile> 
filesToCompact)
+    throws IOException {
+    long lowTimestamp = StoreUtils.getLowestTimestamp(filesToCompact);
+    long now = EnvironmentEdgeManager.currentTime();
+    if (isMajorCompactionTime(filesToCompact, now, lowTimestamp)) {
+      long cfTTL = this.storeConfigInfo.getStoreFileTtl();
+      HDFSBlocksDistribution hdfsBlocksDistribution = new 
HDFSBlocksDistribution();
+      List<Long> boundaries = getCompactBoundariesForMajor(filesToCompact, 
now);
+      boolean[] filesInWindow = new boolean[boundaries.size()];
+      for (HStoreFile file : filesToCompact) {
+        OptionalLong minTimestamp = file.getMinimumTimestamp();
+        if (checkForTtl(cfTTL, file)) {
+          return true;
+        }
+        if (isMajorOrBulkloadResult(file, now - lowTimestamp)) {
+          return true;
+        }
+        int lowerWindowIndex =
+          Collections.binarySearch(boundaries, 
minTimestamp.orElse(Long.MAX_VALUE));
+        int upperWindowIndex =
+          Collections.binarySearch(boundaries, 
file.getMaximumTimestamp().orElse(Long.MAX_VALUE));
+        // Handle boundary conditions and negative values of binarySearch
+        lowerWindowIndex =
+          (lowerWindowIndex < 0) ? Math.abs(lowerWindowIndex + 2) : 
lowerWindowIndex;
+        upperWindowIndex =
+          (upperWindowIndex < 0) ? Math.abs(upperWindowIndex + 2) : 
upperWindowIndex;
+        if (lowerWindowIndex != upperWindowIndex) {

Review Comment:
   This specific logic was not introduced within this commit, it was already 
like that since HBASE-15400, it just appears in this PR because we split 
`shouldPerformMajorCompaction` into some extra granular methods for code reuse 
(i.e `isMajorCompactionTime`, `checkForTtl`, `isMajorOrBulkloadResult` and 
`checkBlockLocality`), as we may leverage those in overrides for 
`shouldPerformMajorCompaction` (as we do in `CustomDateTieredCompactionPolicy`).



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