gaborkaszab commented on code in PR #18486:
URL: https://github.com/apache/iceberg/pull/18486#discussion_r4482586587


##########
api/src/main/java/org/apache/iceberg/HasReferencedFiles.java:
##########
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg;
+
+/** A {@link ScanTask} that can list the content files it reads. */

Review Comment:
   Added a more generic comment.



##########
core/src/main/java/org/apache/iceberg/PositionDeletesScanTask.java:
##########
@@ -18,5 +18,12 @@
  */
 package org.apache.iceberg;
 
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+
 /** A {@link ScanTask} for position delete files */
-public interface PositionDeletesScanTask extends ContentScanTask<DeleteFile> {}
+public interface PositionDeletesScanTask extends ContentScanTask<DeleteFile>, 
HasReferencedFiles {
+  @Override
+  default Iterable<ContentFile<?>> referencedFiles() {

Review Comment:
   @anuragmantri asked the same 
[here](https://github.com/apache/iceberg/pull/18486/changes#paneldiscussion_r4474416934).
   In a nutshell, I considered that too, but I thought that was too error 
prone: a default implementation in `ContentScanTask` returning `file()` could 
cause wrong results in a child class that forgets to override 
`referencedFiles()` but introduces other files too.
   The `HasReferencedFiles` interface seems more self explanatory, and we'd get 
a clear error if we try to use a `ScanTask` implementation that doesn't 
implement the interface.



##########
core/src/main/java/org/apache/iceberg/encryption/InputFilesDecryptor.java:
##########
@@ -71,13 +78,15 @@ private Map<String, InputFile> inputFiles() {
     return lazyInputFiles;
   }
 
-  private static Collection<ContentFile<?>> 
referencedFiles(Iterable<FileScanTask> tasks) {
+  private static Collection<ContentFile<?>> referencedFiles(Iterable<? extends 
ScanTask> tasks) {
     Map<String, ContentFile<?>> files = Maps.newHashMap();
-    for (FileScanTask task : tasks) {
-      files.put(task.file().location(), task.file());
-      for (DeleteFile delete : task.deletes()) {
-        files.put(delete.location(), delete);
+    for (ScanTask task : tasks) {
+      if (!(task instanceof HasReferencedFiles referencing)) {

Review Comment:
   Done. However, I think the original version was more readable because the 
instance check and the cast was merged into the same line.



##########
api/src/main/java/org/apache/iceberg/HasReferencedFiles.java:
##########
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg;
+
+/** A {@link ScanTask} that can list the content files it reads. */
+public interface HasReferencedFiles {
+  /**
+   * Returns all content files that must be read to process this task

Review Comment:
   You're right. Made this more generic.



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