-
Notifications
You must be signed in to change notification settings - Fork 359
refactor(writer): Make writer builders non-consuming in build #1889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
CTTY
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @leonzchang , thanks for the contribution! LGTM in general
There are also some clone() usages in writers under partitioning module like this.
Could you help remove them as well in this PR?
| F: FileNameGenerator, | ||
| B: FileWriterBuilder + Sync, | ||
| L: LocationGenerator + Sync, | ||
| F: FileNameGenerator + Sync, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just add supertrait Sync to these traits to enforce it across different implementations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we should remove the Clone in trait implementation in builders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback, updated in 967c155.
| F: FileNameGenerator, | ||
| B: FileWriterBuilder + Sync, | ||
| L: LocationGenerator + Sync, | ||
| F: FileNameGenerator + Sync, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
crates/iceberg/src/writer/mod.rs
Outdated
| //! | ||
| //! #[async_trait::async_trait] | ||
| //! impl<B: IcebergWriterBuilder> IcebergWriterBuilder for LatencyRecordWriterBuilder<B> { | ||
| //! impl<B: IcebergWriterBuilder + Sync> IcebergWriterBuilder for LatencyRecordWriterBuilder<B> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason why we don't add Sync as supertrait here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CTTY This was the missing part. Thank you!
|
|
||
| /// File writer builder trait. | ||
| pub trait FileWriterBuilder<O = DefaultOutput>: Send + Clone + 'static { | ||
| pub trait FileWriterBuilder<O = DefaultOutput>: Clone + Send + Sync + 'static { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need to keep this Clone?
|
|
||
| /// `FileNameGeneratorTrait` used to generate file name for data file. The file name can be passed to `LocationGenerator` to generate the location of the file. | ||
| pub trait FileNameGenerator: Clone + Send + 'static { | ||
| pub trait FileNameGenerator: Clone + Send + Sync + 'static { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
|
|
||
| /// `LocationGenerator` used to generate the location of data file. | ||
| pub trait LocationGenerator: Clone + Send + 'static { | ||
| pub trait LocationGenerator: Clone + Send + Sync + 'static { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
Which issue does this PR close?
What changes are included in this PR?
This change allows users to reuse builder instances without cloning when creating multiple writers with the same configuration.
Modification non-consuming self in build function:
IcebergWriterBuilderRollingFileWriterBuilderFileWriterBuilderAre these changes tested?