ggershinsky commented on code in PR #7770:
URL: https://github.com/apache/iceberg/pull/7770#discussion_r1762461922


##########
core/src/main/java/org/apache/iceberg/ManifestListWriter.java:
##########
@@ -19,26 +19,63 @@
 package org.apache.iceberg;
 
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.util.Iterator;
 import java.util.Map;
 import org.apache.iceberg.avro.Avro;
+import org.apache.iceberg.encryption.EncryptionManager;
+import org.apache.iceberg.encryption.EncryptionUtil;
+import org.apache.iceberg.encryption.NativeEncryptionKeyMetadata;
+import org.apache.iceberg.encryption.NativeEncryptionOutputFile;
+import org.apache.iceberg.encryption.StandardEncryptionManager;
 import org.apache.iceberg.exceptions.RuntimeIOException;
 import org.apache.iceberg.io.FileAppender;
 import org.apache.iceberg.io.OutputFile;
 import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
 import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
 
 abstract class ManifestListWriter implements FileAppender<ManifestFile> {
+  private final long snapshotId;
+  private final StandardEncryptionManager em;
+  private final NativeEncryptionKeyMetadata keyMetadata;
   private final FileAppender<ManifestFile> writer;
+  private final OutputFile file;
+
+  private ManifestListWriter(
+      OutputFile file, EncryptionManager em, long snapshotId, Map<String, 
String> meta) {
+    if (em instanceof StandardEncryptionManager) {
+      // only encrypt the manifest list if standard table encryption is used 
because the ability to
+      // encrypt the manifest list key was introduced for standard encryption.
+      this.em = (StandardEncryptionManager) em;
+      NativeEncryptionOutputFile encryptedFile = this.em.encrypt(file);
+      this.file = encryptedFile.encryptingOutputFile();
+      this.keyMetadata = encryptedFile.keyMetadata();
+    } else {
+      this.em = null;
+      this.file = file;
+      this.keyMetadata = null;
+    }
 
-  private ManifestListWriter(OutputFile file, Map<String, String> meta) {
-    this.writer = newAppender(file, meta);
+    this.snapshotId = snapshotId;
+    this.writer = newAppender(this.file, meta);
   }
 
   protected abstract ManifestFile prepare(ManifestFile manifest);
 
   protected abstract FileAppender<ManifestFile> newAppender(
-      OutputFile file, Map<String, String> meta);
+      OutputFile outputFile, Map<String, String> meta);

Review Comment:
   reverting it triggers the following build message:
   ```
   > Task :iceberg-core:checkstyleMain
   [ant:checkstyle] [ERROR] 
/<path>/iceberg/core/src/main/java/org/apache/iceberg/ManifestListWriter.java:66:18:
 
   'file' hides a field. [HiddenField]
   
   > Task :iceberg-core:checkstyleMain FAILED
   
   FAILURE: Build failed with an exception.
   ```



-- 
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: issues-unsubscr...@iceberg.apache.org

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


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

Reply via email to