You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tustvold (via GitHub)" <gi...@apache.org> on 2023/02/04 10:49:47 UTC

[GitHub] [arrow-rs] tustvold opened a new pull request, #3659: Implement std::fmt::Write for StringBuilder (#3638)

tustvold opened a new pull request, #3659:
URL: https://github.com/apache/arrow-rs/pull/3659

   # 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.
   -->
   
   Part of #3638 
   
   # Rationale for this change
    
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   I want to use this in the cast kernels in #3647 but split out into a separate PR to highlight, as the interface is perhaps a little strange.
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking change` label.
   -->
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold commented on a diff in pull request #3659: Implement std::fmt::Write for StringBuilder (#3638)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #3659:
URL: https://github.com/apache/arrow-rs/pull/3659#discussion_r1096668787


##########
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:
   Each individual call won't result in a new row, you need to explicitly append an empty string to delimit the record



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] ursabot commented on pull request #3659: Implement std::fmt::Write for StringBuilder (#3638)

Posted by "ursabot (via GitHub)" <gi...@apache.org>.
ursabot commented on PR #3659:
URL: https://github.com/apache/arrow-rs/pull/3659#issuecomment-1418970063

   Benchmark runs are scheduled for baseline = fb1179201293cccb57263e1175e58f54133116ac and contender = 04500e7dd77a49d925657732e42924e46a82489f. 04500e7dd77a49d925657732e42924e46a82489f is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/ef01a336e8ce49a289e651bad0b7e3fe...8b5745a8914b4f5aa464c10aea44b848/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/adb73b430379480080d4d4eab3453cd5...07fd85a88ca146b78d5a04dac5a01d19/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/4404922db84440b6828c38249ac48d25...01205264f84d4713b1dfd05b63ac9d26/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/95516f553cff47eeb0d00951931511a7...247d5bbd8aa44d05992e9a4c658f0657/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold merged pull request #3659: Implement std::fmt::Write for StringBuilder (#3638)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold merged PR #3659:
URL: https://github.com/apache/arrow-rs/pull/3659


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] alamb commented on pull request #3659: Implement std::fmt::Write for StringBuilder (#3638)

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #3659:
URL: https://github.com/apache/arrow-rs/pull/3659#issuecomment-1416842270

   This is pretty 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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] alamb commented on a diff in pull request #3659: Implement std::fmt::Write for StringBuilder (#3638)

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #3659:
URL: https://github.com/apache/arrow-rs/pull/3659#discussion_r1096739428


##########
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:
   Excellent thing to document I think



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] alamb commented on a diff in pull request #3659: Implement std::fmt::Write for StringBuilder (#3638)

Posted by "alamb (via GitHub)" <gi...@apache.org>.
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] alamb commented on a diff in pull request #3659: Implement std::fmt::Write for StringBuilder (#3638)

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #3659:
URL: https://github.com/apache/arrow-rs/pull/3659#discussion_r1096582268


##########
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:
   It might be weird if someone puts a `BufWriter` in front of the builder, but with some comments it should be ok



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org