anoopj commented on code in PR #17932:
URL: https://github.com/apache/iceberg/pull/17932#discussion_r3936666689
##########
core/src/main/java/org/apache/iceberg/TrackedFileAdapters.java:
##########
@@ -410,6 +414,122 @@ public DeleteFile copyWithStats(Set<Integer>
requestedColumnIds) {
}
}
+ /** Adapts a TrackedFile to {@link ManifestFile}. */
+ private static class TrackedManifestFile implements ManifestFile {
+ private final TrackedFile file;
+
+ private TrackedManifestFile(TrackedFile file) {
+ Tracking tracking = file.tracking();
+ Preconditions.checkArgument(
+ tracking.dataSequenceNumber() != null, "Invalid data sequence
number: null");
+ Preconditions.checkArgument(
+ tracking.dataSequenceNumber().equals(tracking.fileSequenceNumber()),
+ "Manifest data and file sequence numbers must be equal, got %s and
%s",
+ tracking.dataSequenceNumber(),
+ tracking.fileSequenceNumber());
+ this.file = file;
+ }
+
+ @Override
+ public String path() {
+ return file.location();
+ }
+
+ @Override
+ public long length() {
+ return file.fileSizeInBytes();
+ }
+
+ @Override
+ public int partitionSpecId() {
+ throw new UnsupportedOperationException(
+ "v4 manifests are not bound to a single partition spec");
+ }
+
+ @Override
+ public ManifestContent content() {
+ switch (file.contentType()) {
+ case DATA_MANIFEST:
+ return ManifestContent.DATA;
+ case DELETE_MANIFEST:
+ return ManifestContent.DELETES;
+ default:
+ throw new IllegalStateException(
+ "Unsupported content type for manifests: " + file.contentType());
+ }
+ }
+
+ @Override
+ public long sequenceNumber() {
+ return file.tracking().dataSequenceNumber();
+ }
+
+ @Override
+ public long minSequenceNumber() {
+ return file.manifestInfo().minSequenceNumber();
Review Comment:
> file.tracking() != null ? file.tracking().dataSequenceNumber() : null
This works for boxed accessors, but won't compile because we need to return
a primitive `long`. `ManifestFile.sequenceNumber()` and `minSequenceNumber()`
both return `long`. So should we just return a sentinel value? Perhaps `-1`?
> public abstract class ManifestWriter<F extends ContentFile<F>> implements
FileAppender<F> {
> // stand-in for the current sequence number that will be assigned when
the commit is successful
> // this is replaced when writing a manifest list by the ManifestFile
wrapper
> static final long UNASSIGNED_SEQ = -1L;
Also I assume we need to handle this in `sequenceNumber()` also.
--
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]