timothyw553 commented on code in PR #18997:
URL: https://github.com/apache/iceberg/pull/18997#discussion_r4726869244


##########
core/src/main/java/org/apache/iceberg/ManifestReader.java:
##########
@@ -364,6 +373,55 @@ private boolean isLiveEntry(ManifestEntry<F> entry) {
     return entry != null && entry.status() != ManifestEntry.Status.DELETED;
   }
 
+  /**
+   * Returns a closeable iterable of files added in this manifest.
+   *
+   * <p>The returned iterable holds open resources and must be closed by the 
caller. Returned files
+   * are defensive copies.
+   *
+   * @return a closeable iterable of added files matching this reader's filters
+   */
+  public CloseableIterable<F> addedFiles() {
+    return filesByStatus(ManifestEntry.Status.ADDED);
+  }
+
+  /**
+   * Returns a closeable iterable of files deleted in this manifest.
+   *
+   * <p>The returned iterable holds open resources and must be closed by the 
caller. Returned files
+   * are defensive copies.
+   *
+   * @return a closeable iterable of deleted files matching this reader's 
filters
+   */
+  public CloseableIterable<F> deletedFiles() {
+    return filesByStatus(ManifestEntry.Status.DELETED);
+  }
+
+  private CloseableIterable<F> filesByStatus(ManifestEntry.Status status) {
+    return new StatusFilterIterable(status);
+  }
+
+  private class StatusFilterIterable extends CloseableGroup implements 
CloseableIterable<F> {
+    private final ManifestEntry.Status status;
+
+    private StatusFilterIterable(ManifestEntry.Status status) {
+      this.status = status;
+    }
+
+    @Override
+    public CloseableIterator<F> iterator() {
+      boolean dropStats = dropStats(columns);
+      CloseableIterable<ManifestEntry<F>> entries = entries();
+      addCloseable(entries);
+      CloseableIterable<ManifestEntry<F>> matching =
+          CloseableIterable.filter(entries, entry -> entry != null && 
entry.status() == status);
+      CloseableIterator<F> iter =
+          CloseableIterable.transform(matching, entry -> 
entry.file().copy(!dropStats)).iterator();

Review Comment:
   right now the tests still pass if we flip `!dropStats` to `true`, `false`, 
or `dropStats` here. could we cover this for both `addedFiles()` and 
`deletedFiles()` using files with nonempty stats? specifically no `select`, 
selecting `column_sizes`, and selecting only `file_path` with a row filter that 
loads stats internally.



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