-
Notifications
You must be signed in to change notification settings - Fork 869
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
feat: add write_bytes for GenericBinaryBuilder #6652
feat: add write_bytes for GenericBinaryBuilder #6652
Conversation
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Try impl |
Signed-off-by: tison <wander4096@gmail.com>
1f5c637
to
30449a9
Compare
Co-authored-by: Andy Lok <andylokandy@hotmail.com>
@andylokandy Thanks for your review! Addressed. |
From the API level: this looks kind of misleading to me. The proposed How about considering something like |
I'm the member of databend, which heavily adopts arrow-rs and I'm sure it is a very common pattern to construct an item in a For example, once this PR is accepted, to add a space padding before each item of for x in array.iter() {
write!(&mut builder, b" ").unwrap();
write!(&mut builder, x).unwrap();
builder.append_value("");
} Moreover, |
Thanks for your insight, this case makes sense to me 🙌 BTW, do you think it's necessary to encapsulate this pattern |
I'll suggest |
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.
This makes sense to me and is inline with what we support for StringBuilder already. I do think we shouldn't make the change to MutableBuffer though
* feat: add write_bytes for GenericBinaryBuilder Signed-off-by: tison <wander4096@gmail.com> * one more improve Signed-off-by: tison <wander4096@gmail.com> * try io::Write trait Signed-off-by: tison <wander4096@gmail.com> * tests Signed-off-by: tison <wander4096@gmail.com> * fmt Signed-off-by: tison <wander4096@gmail.com> * Apply suggestions from code review Co-authored-by: Andy Lok <andylokandy@hotmail.com> * Update mutable.rs --------- Signed-off-by: tison <wander4096@gmail.com> Co-authored-by: Andy Lok <andylokandy@hotmail.com>
Similar to
impl Write for GenericStringBuilder
.We found this helps in reducing one allocation when append bytes in many calls (compared with gather those bytes into a Vec first).
Not sure if there is some trait suitable for this method but just add it first.
cc @alamb @waynexia
The doc tests cover the basic usage.