You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "ClSlaid (via GitHub)" <gi...@apache.org> on 2025/12/13 18:59:57 UTC
[PR] feat: implement append_array for FixedSizeBinaryBuilder [arrow-rs]
ClSlaid opened a new pull request, #8989:
URL: https://github.com/apache/arrow-rs/pull/8989
- Implemented append_array for the builder
- appends values and nulls one by one
- tested with unit test
- To #8750
# 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.
- Closes #8750.
# Rationale for this change
Added `append_array` fn for the builder
# 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 these changes tested?
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
# 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 call them out.
--
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
Re: [PR] feat: implement append_array for FixedSizeBinaryBuilder [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #8989:
URL: https://github.com/apache/arrow-rs/pull/8989
--
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
Re: [PR] feat: implement append_array for FixedSizeBinaryBuilder [arrow-rs]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #8989:
URL: https://github.com/apache/arrow-rs/pull/8989#discussion_r2617128617
##########
arrow-array/src/builder/fixed_size_binary_builder.rs:
##########
@@ -101,6 +102,19 @@ impl FixedSizeBinaryBuilder {
self.null_buffer_builder.append_n_nulls(n);
}
+ /// Appends all elements in array into the builder.
+ pub fn append_array(&mut self, array: &FixedSizeBinaryArray) -> Result<(), ArrowError> {
Review Comment:
I'm afraid this is not efficient enough. Why not copying value and the null buffer?
--
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
Re: [PR] feat: implement append_array for FixedSizeBinaryBuilder [arrow-rs]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #8989:
URL: https://github.com/apache/arrow-rs/pull/8989#discussion_r2621692623
##########
arrow-array/src/builder/fixed_size_binary_builder.rs:
##########
@@ -270,4 +288,43 @@ mod tests {
fn test_fixed_size_binary_builder_invalid_value_length() {
let _ = FixedSizeBinaryBuilder::with_capacity(15, -1);
}
+
+ #[test]
+ fn test_fixed_size_binary_builder_append_array() {
+ let mut other_builder = FixedSizeBinaryBuilder::with_capacity(3, 5);
+ other_builder.append_value(b"hello").unwrap();
+ other_builder.append_null();
+ other_builder.append_value(b"arrow").unwrap();
+ let other_array = other_builder.finish();
+
+ let mut builder = FixedSizeBinaryBuilder::with_capacity(3, 5);
+ builder.append_array(&other_array).unwrap();
+ // Append again to test if breaks when appending multiple times
+ builder.append_array(&other_array).unwrap();
+ let array = builder.finish();
+
+ assert_eq!(array.value_length(), other_array.value_length());
+ assert_eq!(&DataType::FixedSizeBinary(5), array.data_type());
+ assert_eq!(6, array.len());
+ assert_eq!(2, array.null_count());
+ for i in 0..6 {
+ assert_eq!(i * 5, array.value_offset(i as usize));
+ }
+
+ assert_eq!(b"hello", array.value(0));
Review Comment:
```suggestion
assert_eq!(b"hello", array.value(0));
assert_eq!(b"arrow", array.value(2));
```
--
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
Re: [PR] feat: implement append_array for FixedSizeBinaryBuilder [arrow-rs]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #8989:
URL: https://github.com/apache/arrow-rs/pull/8989#discussion_r2621694441
##########
arrow-array/src/builder/fixed_size_binary_builder.rs:
##########
@@ -270,4 +288,43 @@ mod tests {
fn test_fixed_size_binary_builder_invalid_value_length() {
let _ = FixedSizeBinaryBuilder::with_capacity(15, -1);
}
+
+ #[test]
+ fn test_fixed_size_binary_builder_append_array() {
+ let mut other_builder = FixedSizeBinaryBuilder::with_capacity(3, 5);
+ other_builder.append_value(b"hello").unwrap();
+ other_builder.append_null();
+ other_builder.append_value(b"arrow").unwrap();
+ let other_array = other_builder.finish();
+
+ let mut builder = FixedSizeBinaryBuilder::with_capacity(3, 5);
Review Comment:
nit: wrong capacity?
--
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
Re: [PR] feat: implement append_array for FixedSizeBinaryBuilder [arrow-rs]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #8989:
URL: https://github.com/apache/arrow-rs/pull/8989#discussion_r2617174155
##########
arrow-array/src/builder/fixed_size_binary_builder.rs:
##########
@@ -101,6 +102,19 @@ impl FixedSizeBinaryBuilder {
self.null_buffer_builder.append_n_nulls(n);
}
+ /// Appends all elements in array into the builder.
+ pub fn append_array(&mut self, array: &FixedSizeBinaryArray) -> Result<(), ArrowError> {
+ let buffer = array.value_data();
+ self.values_builder.extend_from_slice(buffer);
+ if let Some(validity) = array.nulls() {
+ self.null_buffer_builder.append_buffer(validity);
+ } else {
+ self.null_buffer_builder.append_n_non_nulls(array.len());
+ }
+ self.value_length = array.value_length();
Review Comment:
?
--
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
Re: [PR] feat: implement append_array for FixedSizeBinaryBuilder [arrow-rs]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #8989:
URL: https://github.com/apache/arrow-rs/pull/8989#discussion_r2617197871
##########
arrow-array/src/builder/fixed_size_binary_builder.rs:
##########
@@ -270,4 +288,40 @@ mod tests {
fn test_fixed_size_binary_builder_invalid_value_length() {
let _ = FixedSizeBinaryBuilder::with_capacity(15, -1);
}
+
+ #[test]
+ fn test_fixed_size_binary_builder_append_array() {
+ let mut other_builder = FixedSizeBinaryBuilder::with_capacity(3, 5);
+ other_builder.append_value(b"hello").unwrap();
+ other_builder.append_null();
+ other_builder.append_value(b"arrow").unwrap();
+ let other_array = other_builder.finish();
+
+ let mut builder = FixedSizeBinaryBuilder::with_capacity(3, 5);
+ builder.append_array(&other_array).unwrap();
+ let array = builder.finish();
+
+ assert_eq!(array.value_length(), other_array.value_length());
Review Comment:
I'm thinking about that would it better for append multiple times to make sure the impl not breaks previous data?
--
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
Re: [PR] feat: implement append_array for FixedSizeBinaryBuilder [arrow-rs]
Posted by "ClSlaid (via GitHub)" <gi...@apache.org>.
ClSlaid commented on PR #8989:
URL: https://github.com/apache/arrow-rs/pull/8989#issuecomment-3651066140
/cc @lewiszlw PTAL
--
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
Re: [PR] feat: implement append_array for FixedSizeBinaryBuilder [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8989:
URL: https://github.com/apache/arrow-rs/pull/8989#issuecomment-3667023593
Thank you @ClSlaid and @mapleFU
--
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