aokolnychyi commented on code in PR #5105:
URL: https://github.com/apache/iceberg/pull/5105#discussion_r902818128
##########
core/src/main/java/org/apache/iceberg/BaseSnapshot.java:
##########
@@ -235,55 +239,101 @@ public List<ManifestFile> deleteManifests() {
}
@Override
- public List<DataFile> addedFiles(FileIO fileIO) {
- if (cachedAdds == null) {
- cacheChanges(fileIO);
+ public List<DataFile> addedDataFiles(FileIO fileIO) {
+ if (addedDataFiles == null) {
+ cacheDataFileChanges(fileIO);
}
- return cachedAdds;
+ return addedDataFiles;
}
/**
- * @deprecated since 0.14.0, will be removed in 1.0.0; Use {@link
Snapshot#addedFiles(FileIO)} instead.
+ * @deprecated since 0.14.0, will be removed in 1.0.0; Use {@link
Snapshot#addedDataFiles(FileIO)} instead.
*/
@Override
@Deprecated
public List<DataFile> addedFiles() {
- if (cachedAdds == null) {
- cacheChanges(io);
+ if (addedDataFiles == null) {
+ cacheDataFileChanges(io);
}
- return cachedAdds;
+ return addedDataFiles;
}
@Override
- public List<DataFile> deletedFiles(FileIO fileIO) {
- if (cachedDeletes == null) {
- cacheChanges(fileIO);
+ public List<DataFile> deletedDataFiles(FileIO fileIO) {
+ if (deletedDataFiles == null) {
+ cacheDataFileChanges(fileIO);
}
- return cachedDeletes;
+ return deletedDataFiles;
}
/**
- * @deprecated since 0.14.0, will be removed in 1.0.0; Use {@link
Snapshot#deletedFiles(FileIO)} instead.
+ * @deprecated since 0.14.0, will be removed in 1.0.0; Use {@link
Snapshot#deletedDataFiles(FileIO)} instead.
*/
@Override
@Deprecated
- public List<DataFile> deletedFiles() {
- if (cachedDeletes == null) {
- cacheChanges(io);
+ public List<DataFile> deletedDataFiles() {
+ if (deletedDataFiles == null) {
+ cacheDataFileChanges(io);
}
- return cachedDeletes;
+ return deletedDataFiles;
+ }
+
+ @Override
+ public Iterable<DeleteFile> addedDeleteFiles(FileIO fileIO) {
+ if (addedDeleteFiles == null) {
+ cacheDeleteFileChanges(fileIO);
+ }
+ return addedDeleteFiles;
+ }
+
+ @Override
+ public Iterable<DeleteFile> deletedDeleteFiles(FileIO fileIO) {
+ if (deletedDeleteFiles == null) {
+ cacheDeleteFileChanges(fileIO);
+ }
+ return deletedDeleteFiles;
}
@Override
public String manifestListLocation() {
return manifestListLocation;
}
- private void cacheChanges(FileIO fileIO) {
- if (fileIO == null) {
- throw new IllegalArgumentException("Cannot cache changes: FileIO is
null");
+ private void cacheDeleteFileChanges(FileIO fileIO) {
+ Preconditions.checkArgument(fileIO != null, "Cannot cache delete file
changes: FileIO is null");
+
+ ImmutableList.Builder<DeleteFile> adds = ImmutableList.builder();
+ ImmutableList.Builder<DeleteFile> deletes = ImmutableList.builder();
+
+ Iterable<ManifestFile> changedManifests =
Iterables.filter(deleteManifests(fileIO),
+ manifest -> Objects.equal(manifest.snapshotId(), snapshotId));
+
+ for (ManifestFile manifest : changedManifests) {
+ try (ManifestReader<DeleteFile> reader =
ManifestFiles.readDeleteManifest(manifest, fileIO, null)) {
Review Comment:
If I remember correctly, `ManifestReader` will use the Avro header metadata
to parse the schema and spec. While it is generally not reliable as the schema
may be old, I think it should be fine as long as we don't do any binding or
filtering (like in this case).
--
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]