amit-jain commented on code in PR #1135:
URL: https://github.com/apache/jackrabbit-oak/pull/1135#discussion_r1346769155


##########
oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/sort/ExternalSort.java:
##########
@@ -460,11 +602,21 @@ public static <T> File sortAndSave(List<T> tmplist,
      * @param typeToString
      *        function to map string to custom type. User for coverting line 
to custom type for the
      *        purpose of sorting
+     * @param filterPredicate
+     *            predicate to filter out data which need to be sorted
      */
     public static <T> File sortAndSave(List<T> tmplist,
                                        Comparator<T> cmp, Charset cs, File 
tmpdirectory,
-                                       boolean distinct, Compression 
algorithm, Function<T, String> typeToString) throws IOException {
-        Collections.sort(tmplist, cmp);
+                                       boolean distinct, Compression algorithm,
+                                       Function<T, String> typeToString,
+                                       @Nullable Predicate<T> filterPredicate
+    ) throws IOException {
+        if ( filterPredicate == null){

Review Comment:
   Isn't this at odds with how the predicate is intended to be used? All other 
places predicate t -> true is added to retain all elements (Line 423) but here 
it is removing. 
   
   Should be changed as below (lambda in removeIf is unneccasary) 
   
   `if (filterPredicate != null) {
       tmplist.removeIf(filterPredicate.negate());
   }
   Collections.sort(tmplist, cmp);`



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

Reply via email to