alamb commented on code in PR #3659:
URL: https://github.com/apache/arrow-rs/pull/3659#discussion_r1096582141
##########
arrow-array/src/builder/generic_bytes_builder.rs:
##########
@@ -235,6 +236,13 @@ impl<T: ByteArrayType, V: AsRef<T::Native>>
Extend<Option<V>> for GenericByteBui
/// Array builder for [`GenericStringArray`][crate::GenericStringArray]
pub type GenericStringBuilder<O> = GenericByteBuilder<GenericStringType<O>>;
+impl<O: OffsetSizeTrait> Write for GenericStringBuilder<O> {
Review Comment:
```suggestion
/// Implement `Write` to support things like `write!(builder, ...`))
///
/// Note each individual call to `write_str` will result in a new row in the
builder
impl<O: OffsetSizeTrait> Write for GenericStringBuilder<O> {
```
##########
arrow-array/src/builder/generic_bytes_builder.rs:
##########
@@ -443,4 +451,19 @@ mod tests {
assert_eq!(array.value_offsets(), &[0, 1, 2, 3, 3, 4, 5, 6, 7, 15,
20]);
assert_eq!(array.value_data(), b"abcabcdcupcakeshello");
}
+
+ #[test]
+ fn test_write() {
+ let mut builder = GenericStringBuilder::<i32>::new();
+ write!(builder, "foo").unwrap();
+ builder.append_value("");
+ writeln!(builder, "bar").unwrap();
+ builder.append_value("");
Review Comment:
This is quite neat 👍
--
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]