tihom88 commented on code in PR #1135: URL: https://github.com/apache/jackrabbit-oak/pull/1135#discussion_r1347035822
########## 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: I will add another comment here but adding it here can lead to creation of many empty files. > We are setting filterPredicate as null as we already filtered the results based on filterPredicate and there is no need to again filter in sortAndSave method. Another reason to do it here is to avoid creating empty files in sortAndSave method as filtering remove all entries in tmplist. This is the reason I added this null check. Refer https://github.com/apache/jackrabbit-oak/blob/f3c434e4206db5a35335d809eb6e8f51757f67cd/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/sort/ExternalSort.java#L436 -- 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: dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org