[CELEBORN-348][FOLLOWUP] Refine comparator to support nanoseconds whi… (#1305)

This commit is contained in:
Keyong Zhou 2023-03-03 17:55:59 +08:00 committed by GitHub
parent 88976d9fd9
commit 9608a11819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -262,12 +262,12 @@ public class SlotsAllocator {
double fetchTimeWeight) {
List<List<DiskInfo>> diskGroups = new ArrayList<>();
usableDisks.sort(
(o1, o2) ->
Math.toIntExact(
(long)
((o1.avgFlushTime() * flushTimeWeight + o1.avgFetchTime() * fetchTimeWeight)
- (o2.avgFlushTime() * flushTimeWeight
+ o2.avgFetchTime() * fetchTimeWeight))));
(o1, o2) -> {
double delta =
(o1.avgFlushTime() * flushTimeWeight + o1.avgFetchTime() * fetchTimeWeight)
- (o2.avgFlushTime() * flushTimeWeight + o2.avgFetchTime() * fetchTimeWeight);
return delta < 0 ? -1 : (delta > 0 ? 1 : 0);
});
int diskCount = usableDisks.size();
int startIndex = 0;
int groupSizeSize = (int) Math.ceil(usableDisks.size() / (double) diskGroupCount);