You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/10/10 21:24:41 UTC

[GitHub] [iceberg] rdblue commented on a change in pull request #1517: Flink: apply row-level delete when reading

rdblue commented on a change in pull request #1517:
URL: https://github.com/apache/iceberg/pull/1517#discussion_r502833791



##########
File path: flink/src/main/java/org/apache/iceberg/flink/source/DataIterator.java
##########
@@ -50,23 +54,36 @@
 abstract class DataIterator<T> implements CloseableIterator<T> {
 
   private Iterator<FileScanTask> tasks;
-  private final FileIO io;
-  private final EncryptionManager encryption;
+  private final Map<String, InputFile> inputFiles;
 
   private CloseableIterator<T> currentIterator;
 
   DataIterator(CombinedScanTask task, FileIO io, EncryptionManager encryption) {
     this.tasks = task.files().iterator();
-    this.io = io;
-    this.encryption = encryption;
+
+    Stream<EncryptedInputFile> encrypted = task.files().stream()
+        .flatMap(fileScanTask -> Stream.concat(Stream.of(fileScanTask.file()), fileScanTask.deletes().stream()))
+        .distinct()

Review comment:
       `distinct` compares files using `equals`, which is not overridden for data or delete files. This should instead use the approach that Spark uses:
   
   ```java
       Map<String, ByteBuffer> keyMetadata = Maps.newHashMap();
       task.files().stream()
           .flatMap(fileScanTask -> Stream.concat(Stream.of(fileScanTask.file()), fileScanTask.deletes().stream()))
           .forEach(file -> keyMetadata.put(file.path().toString(), file.keyMetadata()));
       Stream<EncryptedInputFile> encrypted = keyMetadata.entrySet().stream()
           .map(entry -> EncryptedFiles.encryptedInput(io.newInputFile(entry.getKey()), entry.getValue()));
   
       // decrypt with the batch call to avoid multiple RPCs to a key server, if possible
       Iterable<InputFile> decryptedFiles = encryptionManager.decrypt(encrypted::iterator);
   ```




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org