Skip to content

Commit

Permalink
NO-SNOW Sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mbobowski committed Dec 10, 2024
1 parent b354f54 commit 30bc9f2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,11 @@ static OffsetContinuityRanges searchForMissingOffsets(List<String> filenames) {
Pair.of(
FileNameUtils.fileNameToStartOffset(file),
FileNameUtils.fileNameToEndOffset(file)))
.sorted()
.collect(Collectors.toList());

for (int i = 0; i < continuousOffsets.size(); i++) {
for (int i = 1; i < continuousOffsets.size(); i++) {
Pair<Long, Long> current = continuousOffsets.get(i);

// The first range is skipped
if (i == 0) {
continue;
}

Pair<Long, Long> previous = continuousOffsets.get(i - 1);

if (previous.getRight() + 1 != current.getLeft()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public OffsetContinuityRanges(
}

public String getContinuousOffsets() {
return parseList(continuousOffsets);
return serializeList(continuousOffsets);
}

public String getMissingOffsets() {
return parseList(missingOffsets);
return serializeList(missingOffsets);
}

private static String parseList(List<Pair<Long, Long>> list) {
private static String serializeList(List<Pair<Long, Long>> list) {
return list.stream()
.map(range -> "[" + range.getLeft() + "," + range.getRight() + "]")
.collect(Collectors.joining("", "[", "]"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@ public static Stream<Arguments> testData() {
fileName(filePrefix, 1996, 2000),
fileName(filePrefix, 2001, 2024)),
"[[0,10][11,20][21,100][101,1991][1996,2000][2001,2024]]",
"[[1992,1995]]"),
Arguments.of(
Arrays.asList(
fileName(filePrefix, 1996, 2000),
fileName(filePrefix, 11, 20),
fileName(filePrefix, 21, 100),
fileName(filePrefix, 2001, 2024),
fileName(filePrefix, 101, 1991),
fileName(filePrefix, 0, 10)),
"[[0,10][11,20][21,100][101,1991][1996,2000][2001,2024]]",
"[[1992,1995]]"));
}
}

0 comments on commit 30bc9f2

Please sign in to comment.