jiwen624 commented on code in PR #18997:
URL: https://github.com/apache/iceberg/pull/18997#discussion_r4590012549
##########
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);
+ return CloseableIterable.combine(
Review Comment:
`combine(..., this)` closes the whole `ManifestReader` when the returned
iterable is closed, which can invalidate other open iterables from the same
reader. For example, calling `addedFiles()` and `deletedFiles()` on one reader,
then closing the first, makes the second fail with an exception. This seems
unexpected from the caller's perspective, and closing an iterator returned by
ManifestReader.iterator() doesn’t affect sibling iterators this way.
--
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]