stevenzwu commented on code in PR #17545:
URL: https://github.com/apache/iceberg/pull/17545#discussion_r3737534355
##########
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:
nit: do we need to provide since? `@deprecated since 1.12.0. Will be removed
in 2.0.0`?
##########
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:
Naming: "Encryptable" describes a capability every file has, not the
specific concept represented here. I would suggest `EncryptedFile` and let the
Javadoc cover the "may or may not carry a keyId" case.
##########
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 {
+
+ /** 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:
- `encryptionKeyID()` → `keyId()` for consistency with `Snapshot.keyId()`
and `EncryptedKey.keyId()` (`ID` caps is out of style — even the local
variables in `EncryptionUtil` are `manifestListKeyId`).
- Javadoc suggestion: `/** Returns the encryption key ID for this file, or
null if the file is not encrypted. */` — the interface-level javadoc already
covers the mapping to `TableMetadata.encryptionKeys()`, so the method sentence
can stay short.
##########
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:
nit: `encryptionKeyId` might be more clear. similarly, maybe also `fileKey
-> encryptionKey` below.
--
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]