gaborkaszab commented on code in PR #17545:
URL: https://github.com/apache/iceberg/pull/17545#discussion_r3740515698
##########
api/src/main/java/org/apache/iceberg/ManifestListFile.java:
##########
@@ -18,17 +18,10 @@
*/
package org.apache.iceberg;
-import java.nio.ByteBuffer;
-import org.apache.iceberg.encryption.EncryptionManager;
-
-public interface ManifestListFile {
-
- /** Location of manifest list file. */
- String location();
-
- /** The manifest list key metadata can be encrypted. Returns ID of
encryption key */
- String encryptionKeyID();
-
- /** Decrypt and return the manifest list key metadata */
- ByteBuffer decryptKeyMetadata(EncryptionManager em);
-}
+/**
+ * A manifest list file that may be encrypted.
+ *
+ * @deprecated will be removed in 2.0.0; use {@link EncryptableFile} instead.
Review Comment:
I added for now, but I personally don't feel it's useful to the reader.
##########
api/src/main/java/org/apache/iceberg/EncryptedFile.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+import java.nio.ByteBuffer;
+import org.apache.iceberg.encryption.EncryptionManager;
+
+/**
+ * A file that may be encrypted. If it is encrypted, its encrypted key
metadata is tracked in the
+ * table metadata encryption keys and is referenced by a key ID.
+ */
+public interface EncryptableFile {
+
+ /** Location of the file. */
+ String location();
+
+ /**
+ * The file key metadata can be encrypted. Returns ID of encryption key or
null if it's not
+ * encrypted.
+ */
+ String encryptionKeyID();
Review Comment:
Thanks for the comment suggestion! Applied.
About the function name: I'm not sure we can change the function name,
because that would break the API for `ManifestListFile` that is derived from
this interface.
Alternatively, we can avoid deriving `ManifestListFile` from the new
interface, but then we won't be able to cast it to the new interface and
delegate to the new function signature like in `FileIO` or in `EncryptionUtil`:
`newInputFile((EncryptableFile) manifestList)`
##########
api/src/main/java/org/apache/iceberg/EncryptableFile.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+import java.nio.ByteBuffer;
+import org.apache.iceberg.encryption.EncryptionManager;
+
+/**
+ * A file that may be encrypted. If it is encrypted, its encrypted key
metadata is tracked in the
+ * table metadata encryption keys and is referenced by a key ID.
+ */
+public interface EncryptableFile {
Review Comment:
Changed to `EncryptedFile`, however, I'm still not comfortable with the vile
name. The name suggests the file is encrypted, but it's may or may not. Maybe
`FileWithEncryptedKey` ?
##########
core/src/main/java/org/apache/iceberg/encryption/EncryptionUtil.java:
##########
@@ -140,19 +141,33 @@ public static ByteBuffer setFileLength(ByteBuffer
keyMetadata, long fileLength)
* @param manifestList a ManifestListFile
* @param em the table's EncryptionManager
* @return a decrypted key metadata buffer
+ * @deprecated will be removed in 1.13.0; use {@link
#decryptKeyMetadata(EncryptableFile,
+ * EncryptionManager)} instead.
*/
+ @Deprecated
public static ByteBuffer decryptManifestListKeyMetadata(
ManifestListFile manifestList, EncryptionManager em) {
+ return decryptKeyMetadata(manifestList, em);
+ }
+
+ /**
+ * Decrypt the key metadata of an encryptable file.
+ *
+ * @param file an EncryptableFile
+ * @param em the table's EncryptionManager
+ * @return a decrypted key metadata buffer
+ */
+ public static ByteBuffer decryptKeyMetadata(EncryptableFile file,
EncryptionManager em) {
Preconditions.checkState(
em instanceof StandardEncryptionManager,
"Snapshot key metadata encryption requires a
StandardEncryptionManager");
StandardEncryptionManager sem = (StandardEncryptionManager) em;
- String manifestListKeyId = manifestList.encryptionKeyID();
+ String fileKeyId = file.encryptionKeyID();
Review Comment:
Renamed them
--
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]