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


##########
core/src/test/java/org/apache/iceberg/TestTrackedFileAdapters.java:
##########
@@ -289,6 +291,263 @@ void testDVDeleteFileAdapterRejectsNullDeletionVector() {
         .hasMessage("Cannot create DV delete file: no deletion vector");
   }
 
+  @Test
+  void testManifestFileAdapterDelegation() {
+    Tracking tracking = createTracking();
+    ManifestInfo manifestInfo = createManifestInfo();
+    TrackedFileStruct file =
+        new TrackedFileStruct(
+            tracking,
+            FileContent.DATA_MANIFEST,
+            WRITER_FORMAT_VERSION,
+            MANIFEST_FILE_LOCATION,
+            FileFormat.PARQUET,
+            NO_PARTITION,
+            8L,
+            2048L);
+    file.set(MANIFEST_INFO_ORDINAL, manifestInfo);

Review Comment:
   we can use the builder from @gaborkaszab 's PR: 
https://github.com/apache/iceberg/pull/16769



##########
core/src/main/java/org/apache/iceberg/TrackedFileAdapters.java:
##########
@@ -405,6 +418,137 @@ public DeleteFile copyWithStats(Set<Integer> 
requestedColumnIds) {
     }
   }
 
+  /**
+   * Adapts a TrackedFile DATA_MANIFEST or DELETE_MANIFEST entry to the {@link 
ManifestFile}
+   * interface.
+   */
+  private static class TrackedManifestFile implements ManifestFile {
+    private final TrackedFile file;
+
+    private TrackedManifestFile(TrackedFile file) {

Review Comment:
   since this can't adapt from a leaf manifest entry with MDV set, we should 
add a validation to fail explicitly



##########
core/src/main/java/org/apache/iceberg/TrackedFileAdapters.java:
##########
@@ -405,6 +418,137 @@ public DeleteFile copyWithStats(Set<Integer> 
requestedColumnIds) {
     }
   }
 
+  /**
+   * Adapts a TrackedFile DATA_MANIFEST or DELETE_MANIFEST entry to the {@link 
ManifestFile}
+   * interface.
+   */
+  private static class TrackedManifestFile implements ManifestFile {
+    private final TrackedFile file;
+
+    private TrackedManifestFile(TrackedFile file) {
+      Preconditions.checkArgument(
+          file.tracking() != null, "Cannot create manifest file: no tracking");
+      Preconditions.checkArgument(
+          file.tracking().dataSequenceNumber() != null,
+          "Cannot create manifest file: no data sequence number");
+      Preconditions.checkArgument(
+          file.tracking().snapshotId() != null, "Cannot create manifest file: 
no snapshot ID");
+      Preconditions.checkArgument(
+          file.manifestInfo() != null, "Cannot create manifest file: no 
manifest info");
+      Preconditions.checkArgument(
+          file.contentType() != FileContent.DELETE_MANIFEST || 
file.tracking().firstRowId() == null,
+          "Delete manifest must not have a first row ID: %s",
+          file.tracking().firstRowId());
+      this.file = file;
+    }
+
+    @Override
+    public String path() {
+      return file.location();
+    }
+
+    @Override
+    public long length() {
+      return file.fileSizeInBytes();
+    }
+
+    @Override
+    public int partitionSpecId() {
+      throw new UnsupportedOperationException(
+          "Tracked manifests are not bound to a single partition spec");
+    }
+
+    @Override
+    public ManifestContent content() {
+      return file.contentType() == FileContent.DATA_MANIFEST
+          ? ManifestContent.DATA
+          : ManifestContent.DELETES;
+    }
+
+    @Override
+    public long sequenceNumber() {
+      return file.tracking().dataSequenceNumber();
+    }
+
+    @Override
+    public long minSequenceNumber() {
+      return file.manifestInfo().minSequenceNumber();
+    }
+
+    @Override
+    public Long snapshotId() {
+      return file.tracking().snapshotId();
+    }
+
+    @Override
+    public Integer addedFilesCount() {
+      return file.manifestInfo().addedFilesCount();
+    }
+
+    @Override
+    public Long addedRowsCount() {
+      return file.manifestInfo().addedRowsCount();
+    }
+
+    @Override
+    public Integer existingFilesCount() {
+      return file.manifestInfo().existingFilesCount();
+    }
+
+    @Override
+    public Long existingRowsCount() {
+      return file.manifestInfo().existingRowsCount();
+    }
+
+    @Override
+    public Integer deletedFilesCount() {
+      return file.manifestInfo().deletedFilesCount();
+    }
+
+    @Override
+    public Long deletedRowsCount() {
+      return file.manifestInfo().deletedRowsCount();
+    }
+
+    @Override
+    // v4 does not store partition summaries on manifests, so return null.
+    public List<PartitionFieldSummary> partitions() {

Review Comment:
   Nit: the comment sits between `@Override` and the method signature. Hoist it 
above `@Override` (or promote to a one-line Javadoc) — that's the convention 
used elsewhere in this file (e.g. the `// From the spec: position deletes...` 
comment above `sortOrderId()` in `TrackedDVDeleteFile`).



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