Repository navigation
chore(refactor) refactor ManifestWriterBuilder to take Box<dyn FileWrite> and location - #2568
Conversation
b83e6bb to
d69e4c5
Compare
| /// Create a new builder. | ||
| pub fn new( | ||
| output: OutputFile, | ||
| writer: Box<dyn FileWrite>, |
There was a problem hiding this comment.
We don't need to this breaking api change, instead, we could add a new method to accept encrypted output file, and these two methods share same function which accepts FileWriter.
There was a problem hiding this comment.
Not sure I quite follow sorry, is that to say we keep this constructor and store something like:
writer: Pin<Box<dyn Future<Output = Result<Box<dyn FileWrite>>> + Send>>
in the struct and have a new constructor:
pub fn new_from_encrypted(
encrypted_output: EncryptedOutputFile,
snapshot_id: Option<i64>,
key_metadata: Option<Vec<u8>>,
schema: SchemaRef,
partition_spec: PartitionSpec,
) -> Self {
let location = encrypted_output.location().to_owned();
Self {
writer_future: Box::pin(async move { encrypted_output.writer().await }),
location,
snapshot_id,
key_metadata,
schema,
partition_spec,
}
}
?
There was a problem hiding this comment.
I tried it with the pinned future and added a new constructor, let me know what you think
f766298 to
774eda6
Compare
| pub(crate) fn new( | ||
| output: OutputFile, | ||
| writer_future: WriterFuture, | ||
| location: String, |
There was a problem hiding this comment.
This is pub(crate) so I think it's okay to change?
774eda6 to
26b04a6
Compare
| /// with the actual snapshot ID before it is committed. | ||
| const UNASSIGNED_SNAPSHOT_ID: i64 = -1; | ||
|
|
||
| type WriterFuture = Pin<Box<dyn Future<Output = Result<Box<dyn FileWrite>>> + Send>>; |
There was a problem hiding this comment.
In fact I prefer to change to new method to async, but I think it's fine for now, let's see in future if we could eliminate it.
blackmwk
left a comment
There was a problem hiding this comment.
Thanks @xanderbailey for this pr!
…ile` in `ManifestWriterBuilder` (#2628) ## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> In #2568 we introduced `new_from_encrypted` but the api isn't very ergonomic because `EncryptedOutputFile` has `StandardKeyMetadata` on it already so we don't need to pass in `key_metadata` also. working towards #2034 ## What changes are included in this PR? <!-- Provide a summary of the modifications in this PR. List the main changes such as new features, bug fixes, refactoring, or any other updates. --> ## Are these changes tested? <!-- Specify what test covers (unit test, integration test, etc.). If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? -->
## Which issue does this PR close? * Working towards #2034 ## What changes are included in this PR? Today it is possible to read encrypted manifest files but not write them. #2568 adds the foundations of what's needed to be able to do these writes but it wasn't wired into the actual write path. <!-- Provide a summary of the modifications in this PR. List the main changes such as new features, bug fixes, refactoring, or any other updates. --> ## Are these changes tested? Yes - added round-trip write path test. <!-- Specify what test covers (unit test, integration test, etc.). If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? -->
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Working towards #2034 ## What changes are included in this PR? Puffin files aren't yet used in the repo but we should support encryption nevertheless, similar to #2568, we add a `new_from_encrypted` constructor for the reader and writer. <!-- Provide a summary of the modifications in this PR. List the main changes such as new features, bug fixes, refactoring, or any other updates. --> ## Are these changes tested? Yes - roundtrip test <!-- Specify what test covers (unit test, integration test, etc.). If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? -->
Which issue does this PR close?
Working towards: #2034
What changes are included in this PR?
Similar reasons to #2564. For the current encryption work we will construct a FileWrite to do transparent encryption on write, this means we need to change the constructor of the
ManifestWriterBuilderto now take both aBox<dyn FileWrite>and alocation.Are these changes tested?