API, Core: Introduce a generic EncryptedFile abstraction to replace ManifestListFile - #17545
API, Core: Introduce a generic EncryptedFile abstraction to replace ManifestListFile#17545gaborkaszab wants to merge 1 commit into
Conversation
| * @deprecated will be removed in 2.0.0; use {@link #newInputFile(EncryptableFile)} instead. | ||
| */ | ||
| @Deprecated | ||
| default InputFile newInputFile(ManifestListFile manifestList) { |
There was a problem hiding this comment.
I dropped BaseManifestListFile because that was package private. Now, there is no implementation in the library that can call this function, still I don't think we can drop this, because it'd break API for users that happen to implement their own ManifestListFile. Not likely, but technically feasible.
| * 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 { |
There was a problem hiding this comment.
Naming: "Encryptable" describes a capability every file has, not the specific concept/state represented here. I would suggest EncryptedFile and let the Javadoc cover the "may or may not carry a keyId" case.
There was a problem hiding this 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 ?
| * The file key metadata can be encrypted. Returns ID of encryption key or null if it's not | ||
| * encrypted. | ||
| */ | ||
| String encryptionKeyID(); |
There was a problem hiding this comment.
encryptionKeyID()→keyId()for consistency withSnapshot.keyId()andEncryptedKey.keyId()(IDcaps is out of style — even the local variables inEncryptionUtilaremanifestListKeyId).- 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 toTableMetadata.encryptionKeys(), so the method sentence can stay short.
There was a problem hiding this 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)
| /** | ||
| * A manifest list file that may be encrypted. | ||
| * | ||
| * @deprecated will be removed in 2.0.0; use {@link EncryptableFile} instead. |
There was a problem hiding this comment.
nit: do we need to provide since? @deprecated since 1.12.0. Will be removed in 2.0.0?
There was a problem hiding this comment.
I added for now, but I personally don't feel it's useful to the reader.
| "Snapshot key metadata encryption requires a StandardEncryptionManager"); | ||
| StandardEncryptionManager sem = (StandardEncryptionManager) em; | ||
| String manifestListKeyId = manifestList.encryptionKeyID(); | ||
| String fileKeyId = file.encryptionKeyID(); |
There was a problem hiding this comment.
nit: encryptionKeyId might be more clear. similarly, maybe also fileKey -> encryptionKey below.
…ManifestListFile ManifestListFile and its implementation contains nothing that is specific to manifest lists. It is more generally related to files that use TableMetadata.encryptionKeys to store encrypted encryption key metadata that are referred to by a key ID. This PR introduces a more general interface that can be used accross multiple file types like manifest lists, V4 root manifests, table statistics and partition statistics. The less general functionality specific to manifest lists is deprecated or removed where possible.
0a3b903 to
c08b3fd
Compare
gaborkaszab
left a comment
There was a problem hiding this comment.
Thanks for taking a look, @stevenzwu !
| * 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 { |
There was a problem hiding this 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 ?
| * The file key metadata can be encrypted. Returns ID of encryption key or null if it's not | ||
| * encrypted. | ||
| */ | ||
| String encryptionKeyID(); |
There was a problem hiding this 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)
| /** | ||
| * A manifest list file that may be encrypted. | ||
| * | ||
| * @deprecated will be removed in 2.0.0; use {@link EncryptableFile} instead. |
There was a problem hiding this comment.
I added for now, but I personally don't feel it's useful to the reader.
| "Snapshot key metadata encryption requires a StandardEncryptionManager"); | ||
| StandardEncryptionManager sem = (StandardEncryptionManager) em; | ||
| String manifestListKeyId = manifestList.encryptionKeyID(); | ||
| String fileKeyId = file.encryptionKeyID(); |
ManifestListFile and its implementation contains nothing that is specific to manifest lists. It is more generally related to files that use TableMetadata.encryptionKeys to store encrypted encryption key metadata that are referred to by a key ID.
This PR introduces a more general interface that can be used accross multiple file types like manifest lists, V4 root manifests, table statistics and partition statistics. The less general functionality specific to manifest lists is deprecated or removed where possible.