DieterDP-ng commented on code in PR #7662:
URL: https://github.com/apache/hbase/pull/7662#discussion_r2816972993
##########
hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java:
##########
@@ -571,26 +580,15 @@ private static List<BackupInfo> getHistory(Configuration
conf, Path backupRootPa
}
}
// Sort
- Collections.sort(infos, new Comparator<BackupInfo>() {
- @Override
- public int compare(BackupInfo o1, BackupInfo o2) {
- long ts1 = getTimestamp(o1.getBackupId());
- long ts2 = getTimestamp(o2.getBackupId());
-
- if (ts1 == ts2) {
- return 0;
- }
-
- return ts1 < ts2 ? 1 : -1;
- }
-
- private long getTimestamp(String backupId) {
- return
Long.parseLong(Iterators.get(Splitter.on('_').split(backupId).iterator(), 1));
- }
- });
+ infos.sort(Comparator.comparing(BackupInfo::getBackupId).reversed());
Review Comment:
Not sure why I choose string sorting here. Possibly because it matches the
sorting done in the HBASE scan, or simply because I hadn't noticed `BackupInfo`
is `Comparable` out of the box.
Saw no disadvantage to using BackupInfo's sorting, so changed.
--
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]