You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "JackieTien97 (via GitHub)" <gi...@apache.org> on 2023/02/09 03:14:57 UTC

[GitHub] [iotdb] JackieTien97 commented on a diff in pull request #9024: [IOTDB-5504] Fix illegal argument exception occurs when scheduling compaction

JackieTien97 commented on code in PR #9024:
URL: https://github.com/apache/iotdb/pull/9024#discussion_r1100937122


##########
server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java:
##########
@@ -2120,11 +2120,21 @@ private void closeUnsealedTsFileProcessorCallBack(TsFileProcessor tsFileProcesso
     logger.info("signal closing database condition in {}", databaseName + "-" + dataRegionId);
   }
 
-  private void executeCompaction() {
+  protected void executeCompaction() {
     try {
       List<Long> timePartitions = new ArrayList<>(tsFileManager.getTimePartitions());
       // sort the time partition from largest to smallest
-      timePartitions.sort((o1, o2) -> (int) (o2 - o1));
+      timePartitions.sort(
+          (o1, o2) -> {
+            long diff = o1 - o2;
+            if (diff > 0) {
+              return 1;
+            } else if (diff < 0) {
+              return -1;
+            } else {
+              return 0;
+            }
+          });

Review Comment:
   ```suggestion
         timePartitions.sort(Comparator.reverseOrder());
   ```



-- 
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: reviews-unsubscribe@iotdb.apache.org

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