You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/24 07:17:03 UTC

[GitHub] [arrow-rs] viirya opened a new pull request, #2915: Add `freeze_with_dictionary` API to `MutableArrayData`

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

   # 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 #2914.
   
   # 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.
   -->
   
   # 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] viirya commented on pull request #2915: Add `freeze_with_dictionary` API to `MutableArrayData`

Posted by GitBox <gi...@apache.org>.
viirya commented on PR #2915:
URL: https://github.com/apache/arrow-rs/pull/2915#issuecomment-1289538243

   > I would also draw your attention to #2832 and #2798
   
   Just tried it. I can use `DictionaryArray::with_values` for our case. Still copying dictionary value array with another `MutableArrayData`, then I changed to invoke `with_values` on the dictionary array obtained from freezing the first `MutableArrayData`.
   
   Just feeling that this way it is somehow not efficient as it needs to freeze and make an array, then takes the value array and copy and attach it back.
   
   For multiple dictionaries, one more issue is there as internally `MutableArrayData` will extend from sources' values. For single dictionary, it has different behavior as no extending.
   
   
   
   
   


-- 
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] viirya commented on a diff in pull request #2915: Add `freeze_with_dictionary` API to `MutableArrayData`

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2915:
URL: https://github.com/apache/arrow-rs/pull/2915#discussion_r1003637937


##########
arrow-data/src/transform/mod.rs:
##########
@@ -637,6 +637,18 @@ impl<'a> MutableArrayData<'a> {
         unsafe { self.data.freeze(self.dictionary).build_unchecked() }
     }
 
+    /// Creates a [ArrayData] from the pushed regions up to this point, consuming `self`,
+    /// with the provided dictionary values `ArrayData`, without any validation
+    ///
+    /// # Safety
+    ///
+    /// As this doesn't validate the provided dictionary `ArrayData` values, the input

Review Comment:
   This is for the values of dictionaries. What MutableArrayData does is simply concatenates the value arrays with another MutableArrayData. The caller must ensure it provides correct concatenated dictionary value array.
   
   



-- 
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] viirya commented on a diff in pull request #2915: Add `freeze_with_dictionary` API to `MutableArrayData`

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2915:
URL: https://github.com/apache/arrow-rs/pull/2915#discussion_r1003680322


##########
arrow-data/src/transform/mod.rs:
##########
@@ -637,6 +637,18 @@ impl<'a> MutableArrayData<'a> {
         unsafe { self.data.freeze(self.dictionary).build_unchecked() }
     }
 
+    /// Creates a [ArrayData] from the pushed regions up to this point, consuming `self`,
+    /// with the provided dictionary values `ArrayData`, without any validation
+    ///
+    /// # Safety
+    ///
+    /// As this doesn't validate the provided dictionary `ArrayData` values, the input

Review Comment:
   Hm? That is also where I looked at. For dictionaries, it uses another `MutableArrayData` to extend from their value arrays. Isn't it?



-- 
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 #2915: Add `freeze_with_dictionary` API to `MutableArrayData`

Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2915:
URL: https://github.com/apache/arrow-rs/pull/2915#discussion_r1003656116


##########
arrow-data/src/transform/mod.rs:
##########
@@ -637,6 +637,18 @@ impl<'a> MutableArrayData<'a> {
         unsafe { self.data.freeze(self.dictionary).build_unchecked() }
     }
 
+    /// Creates a [ArrayData] from the pushed regions up to this point, consuming `self`,
+    /// with the provided dictionary values `ArrayData`, without any validation
+    ///
+    /// # Safety
+    ///
+    /// As this doesn't validate the provided dictionary `ArrayData` values, the input

Review Comment:
   I'm not sure that is correct - https://github.com/apache/arrow-rs/blob/master/arrow-data/src/transform/mod.rs#L499



-- 
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] viirya commented on pull request #2915: Add `freeze_with_dictionary` API to `MutableArrayData`

Posted by GitBox <gi...@apache.org>.
viirya commented on PR #2915:
URL: https://github.com/apache/arrow-rs/pull/2915#issuecomment-1289538888

   I'm closing this as `DictionaryArray::with_values` can fit our usecase for now. No need to add a new API.


-- 
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] viirya closed pull request #2915: Add `freeze_with_dictionary` API to `MutableArrayData`

Posted by GitBox <gi...@apache.org>.
viirya closed pull request #2915: Add `freeze_with_dictionary` API to `MutableArrayData`
URL: https://github.com/apache/arrow-rs/pull/2915


-- 
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 #2915: Add `freeze_with_dictionary` API to `MutableArrayData`

Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2915:
URL: https://github.com/apache/arrow-rs/pull/2915#discussion_r1003624245


##########
arrow-data/src/transform/mod.rs:
##########
@@ -637,6 +637,18 @@ impl<'a> MutableArrayData<'a> {
         unsafe { self.data.freeze(self.dictionary).build_unchecked() }
     }
 
+    /// Creates a [ArrayData] from the pushed regions up to this point, consuming `self`,
+    /// with the provided dictionary values `ArrayData`, without any validation
+    ///
+    /// # Safety
+    ///
+    /// As this doesn't validate the provided dictionary `ArrayData` values, the input

Review Comment:
   I'm not entirely sure this will work as expected, MutableArrayData has some pretty hard assumptions when it comes to dictionaries - it concatenates the dictionary arrays, and computes new keys based on this assumption



-- 
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] viirya commented on pull request #2915: Add `freeze_with_dictionary` API to `MutableArrayData`

Posted by GitBox <gi...@apache.org>.
viirya commented on PR #2915:
URL: https://github.com/apache/arrow-rs/pull/2915#issuecomment-1289417212

   cc @sunchao 


-- 
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 pull request #2915: Add `freeze_with_dictionary` API to `MutableArrayData`

Posted by GitBox <gi...@apache.org>.
tustvold commented on PR #2915:
URL: https://github.com/apache/arrow-rs/pull/2915#issuecomment-1289576126

   > Just feeling that this way it is somehow not efficient as it needs to freeze and make an array, then takes the value array and copy and attach it back.
   
   I think I am missing something. I don't think there is a way to avoid copying and attaching back - this is what MutableArrayData does also? I did create https://github.com/apache/arrow-rs/issues/1981 a while back to track allowing mutation of arrays, but currently there isn't any support for this?


-- 
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] viirya commented on pull request #2915: Add `freeze_with_dictionary` API to `MutableArrayData`

Posted by GitBox <gi...@apache.org>.
viirya commented on PR #2915:
URL: https://github.com/apache/arrow-rs/pull/2915#issuecomment-1289598531

   > I think I am missing something. I don't think there is a way to avoid copying and attaching back - this is what MutableArrayData does also? I did create #1981 a while back to track allowing mutation of arrays, but currently there isn't any support for this?
   
   Oh, no, copying is unavoidable. I meant that I need to create an array first and take value value from it. I feel that it is not smooth in usage as letting MutableArrayData to handle it as the proposed API. Just my preference.
   
   > > Still copying dictionary value array with another MutableArrayData
   > 
   > This is the step I don't understand, what is this operation you are implementing here? Why are you using MutableArrayData for this at all?
   
   We reuse array allocation generally. But for certain operations, we need to hold on and wait for all arrays before we can do the operation. So we need to copy arrays there otherwise they will be overwritten. But while MutableArrayData extends DictionaryArray, it doesn't copy the value array (if only one DictionaryArray there).
   
   


-- 
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