xushiyan commented on a change in pull request #2621:
URL: https://github.com/apache/hudi/pull/2621#discussion_r586120570



##########
File path: 
hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/helpers/DatePartitionPathSelector.java
##########
@@ -130,20 +140,19 @@ public DatePartitionPathSelector(TypedProperties props, 
Configuration hadoopConf
           FileSystem fs = new Path(path).getFileSystem(serializedConf.get());
           return listEligibleFiles(fs, new Path(path), 
lastCheckpointTime).stream();
         }, partitionsListParallelism);
-    // sort them by modification time.
-    
eligibleFiles.sort(Comparator.comparingLong(FileStatus::getModificationTime));
+    // sort them by modification time ascending.
+    List<FileStatus> sortedEligibleFiles = eligibleFiles.stream()
+        
.sorted(Comparator.comparingLong(FileStatus::getModificationTime)).collect(Collectors.toList());

Review comment:
       the in-place sorting actually causes problem to immutable list, throwing 
unsupported operation exception. hence sort it to another list.

##########
File path: 
hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/helpers/DatePartitionPathSelector.java
##########
@@ -157,7 +166,8 @@ public DatePartitionPathSelector(TypedProperties props, 
Configuration hadoopConf
     // read the files out.
     String pathStr = filteredFiles.stream().map(f -> 
f.getPath().toString()).collect(Collectors.joining(","));
 
-    return new ImmutablePair<>(Option.ofNullable(pathStr), 
String.valueOf(maxModificationTime));
+    return new ImmutablePair<>(Option.ofNullable(pathStr),
+        String.valueOf(filteredFiles.get(filteredFiles.size() - 
1).getModificationTime()));

Review comment:
       as the list was sorted, getting the last item's mod time is clearer this 
way




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to