regadas commented on code in PR #18997:
URL: https://github.com/apache/iceberg/pull/18997#discussion_r4697908240
##########
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:
Thanks, good catch as well! Moved `entries()` into `iterator()` (matching
`ManifestReader.iterator()`) so each pass gets a fresh `idAssigner`, and added
a v3+ test for repeated iteration.
##########
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:
Sorry for the delayed response, and good catch. Updated `filesByStatus` to
only close the `entries()` streams opened by that iterable instead of closing
the whole `ManifestReader`, and added a test for concurrent `addedFiles()` and
`deletedFiles()` on the same reader.
--
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]