rdblue commented on a change in pull request #1514:
URL: https://github.com/apache/iceberg/pull/1514#discussion_r496251006
##########
File path:
spark/src/main/java/org/apache/iceberg/spark/source/BaseDataReader.java
##########
@@ -58,9 +60,12 @@
BaseDataReader(CombinedScanTask task, FileIO io, EncryptionManager
encryptionManager) {
this.tasks = task.files().iterator();
- Stream<EncryptedInputFile> encrypted = task.files().stream()
- .flatMap(fileScanTask -> Stream.concat(Stream.of(fileScanTask.file()),
fileScanTask.deletes().stream()))
- .map(file ->
EncryptedFiles.encryptedInput(io.newInputFile(file.path().toString()),
file.keyMetadata()));
+ Map<CharSequence, DeleteFile> uniqueDeleteFileMap = Maps.newHashMap();
Review comment:
There is no `equals` and `hashCode` implementation for `CharSequence`,
so it can't be used reliably as a map key to deduplicate.
Also, the only thing you need from the file instance is the key metadata, so
you could keep a map of string path to key metadata, like this:
```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()));
```
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]