jiwen624 commented on code in PR #18997:
URL: https://github.com/apache/iceberg/pull/18997#discussion_r4593891000
##########
core/src/main/java/org/apache/iceberg/ManifestReader.java:
##########
@@ -364,6 +373,38 @@ 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) {
+ boolean dropStats = dropStats(columns);
+ CloseableIterable<ManifestEntry<F>> matching =
+ CloseableIterable.filter(entries(), entry -> entry != null &&
entry.status() == status);
Review Comment:
`entries()` is called once here so each traversal of the returned iterable
shares the same
[idAssigner](https://github.com/apache/iceberg/blob/6164440663e3f7b1bae92a1a710ca5233755cd7d/core/src/main/java/org/apache/iceberg/ManifestReader.java#L351)
which is stateful. It can be problematic since each returns a different
[firstRowId](https://github.com/apache/iceberg/blob/27d344e1015a14efd32c0f7c490c28cc1f1aaa68/core/src/main/java/org/apache/iceberg/ManifestReader.java#L482-L490)
values and may silently corrupt the row lineage.
--
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]