stevenzwu commented on code in PR #18147:
URL: https://github.com/apache/iceberg/pull/18147#discussion_r4031422996


##########
api/src/main/java/org/apache/iceberg/io/CloseableIterable.java:
##########
@@ -132,6 +133,38 @@ protected boolean shouldKeep(E item) {
         iterable);
   }
 
+  /**
+   * Filters the given {@link CloseableIterable} and passes each skipped item 
to a {@link Consumer}.
+   *
+   * @param skipCallback A consumer used to handle skipped items
+   * @param iterable The underlying {@link CloseableIterable} to filter
+   * @param <E> The underlying type to be iterated
+   * @return A filtered {@link CloseableIterable} that skips items the 
predicate does not match
+   */
+  static <E> CloseableIterable<E> filter(
+      Consumer<E> skipCallback, CloseableIterable<E> iterable, Predicate<E> 
pred) {
+    Preconditions.checkArgument(null != iterable, "Invalid iterable: null");
+    Preconditions.checkArgument(null != pred, "Invalid predicate: null");
+
+    if (skipCallback != null) {

Review Comment:
   I'd require a non-null `skipCallback` like the `Counter` overload, and drop 
the null branch. The 2-arg `filter` already covers "no callback", and 
`filter(null, iterable, pred)` is ambiguous between `Counter` and `Consumer`.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to