You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "XiangpengHao (via GitHub)" <gi...@apache.org> on 2024/07/12 15:17:47 UTC
[PR] Minor API adjustments [arrow-rs]
XiangpengHao opened a new pull request, #6047:
URL: https://github.com/apache/arrow-rs/pull/6047
# 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.
-->
Closes #.
# Rationale for this change
Current string view builder won't allow users to know what has already being inserted to the builder.
However, in many real use cases, like DataFusion's ArrowByteViewMap, or user want to deduplicate the string view, they want to know what's already in the builder.
We have this implementation ready, but not visible to user. This pr make the function visible.
Another change is that, previous gc will call deduplicate string, I think we should get rid of that.
<!--
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.
-->
# 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
Re: [PR] Minor API adjustments for StringViewBuilder [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #6047:
URL: https://github.com/apache/arrow-rs/pull/6047
--
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] Minor API adjustments for StringViewBuilder [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6047:
URL: https://github.com/apache/arrow-rs/pull/6047#discussion_r1676816056
##########
arrow-array/src/array/byte_view_array.rs:
##########
@@ -325,8 +325,7 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {
/// Use with caution as this can be an expensive operation, only use it when you are sure that the view
/// array is significantly smaller than when it is originally created, e.g., after filtering or slicing.
pub fn gc(&self) -> Self {
- let mut builder =
- GenericByteViewBuilder::<T>::with_capacity(self.len()).with_deduplicate_strings();
Review Comment:
Could we also can add a note in the documentation that mentions that gc does not deduplicate strings ? Something like
```rust
/// Note: this function does not attempt to canonicalize / deduplicate values. For this
/// feature see [`GenericByteViewBuilder::with_deduplicate_strings`].
```
##########
arrow-array/src/builder/generic_bytes_view_builder.rs:
##########
@@ -337,6 +338,19 @@ impl<T: ByteViewType + ?Sized> GenericByteViewBuilder<T> {
pub fn validity_slice(&self) -> Option<&[u8]> {
self.null_buffer_builder.as_slice()
}
+
+ /// Return the allocated size of this builder, useful for memory accounting.
Review Comment:
```suggestion
/// Return the allocated size of this builder in bytes, useful for memory accounting.
```
##########
arrow-buffer/src/builder/null.rs:
##########
@@ -161,6 +161,14 @@ impl NullBufferBuilder {
pub fn as_slice_mut(&mut self) -> Option<&mut [u8]> {
self.bitmap_builder.as_mut().map(|b| b.as_slice_mut())
}
+
+ /// Return the allocated size of this builder, useful for memory accounting.
Review Comment:
```suggestion
/// Return the allocated size of this builder, in bytes, useful for memory accounting.
```
##########
arrow-array/src/builder/generic_bytes_view_builder.rs:
##########
@@ -337,6 +338,19 @@ impl<T: ByteViewType + ?Sized> GenericByteViewBuilder<T> {
pub fn validity_slice(&self) -> Option<&[u8]> {
self.null_buffer_builder.as_slice()
}
+
+ /// Return the allocated size of this builder, useful for memory accounting.
+ pub fn allocated_size(&self) -> usize {
+ let buffer_size = self.completed.iter().map(|b| b.capacity()).sum::<usize>();
Review Comment:
As a stylistic thing (or maybe selfishly to make it easier to review), I recommend computing the sizes in the same order as they are defined in the struct
So like ` views_builder`, `null_buffer_builder`, `completed`, and `in_progress`
```rust
pub struct GenericByteViewBuilder<T: ByteViewType + ?Sized> {
views_builder: BufferBuilder<u128>,
null_buffer_builder: NullBufferBuilder,
completed: Vec<Buffer>,
in_progress: Vec<u8>,
block_size: u32,
```
--
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] Minor API adjustments for StringViewBuilder [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #6047:
URL: https://github.com/apache/arrow-rs/pull/6047#issuecomment-2228111789
Thanks @XiangpengHao
--
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