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 2021/05/10 12:48:08 UTC

[GitHub] [arrow-rs] Jimexist opened a new pull request #275: add nullity function and some unit tests

Jimexist opened a new pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275


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

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



[GitHub] [arrow-rs] nevi-me commented on pull request #275: Add nullary function and some unit tests

Posted by GitBox <gi...@apache.org>.
nevi-me commented on pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275#issuecomment-840497263


   @jorgecarleitao @alamb have time to cast second pair of eyes?


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

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



[GitHub] [arrow-rs] Dandandan commented on a change in pull request #275: add nullity function and some unit tests

Posted by GitBox <gi...@apache.org>.
Dandandan commented on a change in pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275#discussion_r629334885



##########
File path: arrow/src/compute/kernels/arity.rs
##########
@@ -72,3 +72,40 @@ where
     let data = into_primitive_array_data::<_, O>(array, buffer);
     PrimitiveArray::<O>::from(data)
 }
+
+/// Applies a nullary and infalible function to generate a primitive array.
+/// You should use this instead of the vectorized version when each generated value is different.
+pub fn nullary<F, O>(size: usize, op: F) -> PrimitiveArray<O>
+where
+    O: ArrowPrimitiveType,
+    F: Fn() -> O::Native,
+{
+    let values = (0..size).map(|_| op());

Review comment:
       This can use `std::iter::repeat_with`




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

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



[GitHub] [arrow-rs] alamb commented on a change in pull request #275: Add nullary function and some unit tests

Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275#discussion_r632068820



##########
File path: arrow/src/compute/kernels/arity.rs
##########
@@ -72,3 +73,37 @@ where
     let data = into_primitive_array_data::<_, O>(array, buffer);
     PrimitiveArray::<O>::from(data)
 }
+
+/// Applies a nullary and infalible function to generate a primitive array.
+/// You should use this instead of the vectorized version when each generated value is different.
+pub fn nullary<F, O>(size: usize, op: F) -> PrimitiveArray<O>

Review comment:
       I don't really understand this need for this function either -- `unary` applies a function to an existing array to make a new array.
   
   Given the implementation now, it seems like writing 
   ```
   let arr = Int32Array::from_iter_values(iter::repeat_with(op).take(size)
   ```
   
   would be just as clear.  
   
   Maybe I am confused about its name. A more specific name might be 'make_constant_array`
   
   I think it takes time to get used to / discover creating `Array`s from iterators -- maybe we can work on adding some more examples to our documentation to help




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

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



[GitHub] [arrow-rs] jorgecarleitao commented on pull request #275: Add nullary function and some unit tests

Posted by GitBox <gi...@apache.org>.
jorgecarleitao commented on pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275#issuecomment-840500695


   The code itself looks great.
   
   I am not sure this is not shadowing `PrimitiveArray<T>::from_iter_values`, which IMO covers this exact case.


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

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



[GitHub] [arrow-rs] Jimexist commented on a change in pull request #275: Add nullary function and some unit tests

Posted by GitBox <gi...@apache.org>.
Jimexist commented on a change in pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275#discussion_r632228845



##########
File path: arrow/src/compute/kernels/arity.rs
##########
@@ -72,3 +73,37 @@ where
     let data = into_primitive_array_data::<_, O>(array, buffer);
     PrimitiveArray::<O>::from(data)
 }
+
+/// Applies a nullary and infalible function to generate a primitive array.
+/// You should use this instead of the vectorized version when each generated value is different.
+pub fn nullary<F, O>(size: usize, op: F) -> PrimitiveArray<O>

Review comment:
       happy to close this PR if not needed.




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

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



[GitHub] [arrow-rs] codecov-commenter commented on pull request #275: add nullity function and some unit tests

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275#issuecomment-836673316


   # [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/275?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#275](https://codecov.io/gh/apache/arrow-rs/pull/275?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (93b7535) into [master](https://codecov.io/gh/apache/arrow-rs/commit/b76e8c9fa3c6373dd839d2547a5c010f4a31ecae?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b76e8c9) will **increase** coverage by `0.00%`.
   > The diff coverage is `100.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/arrow-rs/pull/275/graphs/tree.svg?width=650&height=150&src=pr&token=pq9V9qWZ1N&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/arrow-rs/pull/275?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master     #275   +/-   ##
   =======================================
     Coverage   82.53%   82.54%           
   =======================================
     Files         162      162           
     Lines       43786    43812   +26     
   =======================================
   + Hits        36140    36165   +25     
   - Misses       7646     7647    +1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/arrow-rs/pull/275?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [arrow/src/compute/kernels/arity.rs](https://codecov.io/gh/apache/arrow-rs/pull/275/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2NvbXB1dGUva2VybmVscy9hcml0eS5ycw==) | `96.42% <100.00%> (+4.76%)` | :arrow_up: |
   | [arrow/src/array/transform/fixed\_binary.rs](https://codecov.io/gh/apache/arrow-rs/pull/275/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L3RyYW5zZm9ybS9maXhlZF9iaW5hcnkucnM=) | `78.94% <0.00%> (-5.27%)` | :arrow_down: |
   | [arrow/src/compute/kernels/regexp.rs](https://codecov.io/gh/apache/arrow-rs/pull/275/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2NvbXB1dGUva2VybmVscy9yZWdleHAucnM=) | `97.56% <0.00%> (-0.03%)` | :arrow_down: |
   | [parquet/src/arrow/schema.rs](https://codecov.io/gh/apache/arrow-rs/pull/275/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvYXJyb3cvc2NoZW1hLnJz) | `88.93% <0.00%> (-0.02%)` | :arrow_down: |
   | [arrow/src/json/reader.rs](https://codecov.io/gh/apache/arrow-rs/pull/275/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2pzb24vcmVhZGVyLnJz) | `83.43% <0.00%> (-0.02%)` | :arrow_down: |
   | [arrow/src/array/data.rs](https://codecov.io/gh/apache/arrow-rs/pull/275/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2RhdGEucnM=) | `72.07% <0.00%> (ø)` | |
   | [parquet/src/schema/parser.rs](https://codecov.io/gh/apache/arrow-rs/pull/275/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvc2NoZW1hL3BhcnNlci5ycw==) | `86.27% <0.00%> (ø)` | |
   | [parquet/src/arrow/array\_reader.rs](https://codecov.io/gh/apache/arrow-rs/pull/275/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvYXJyb3cvYXJyYXlfcmVhZGVyLnJz) | `77.14% <0.00%> (ø)` | |
   | [arrow/src/datatypes/schema.rs](https://codecov.io/gh/apache/arrow-rs/pull/275/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2RhdGF0eXBlcy9zY2hlbWEucnM=) | `67.21% <0.00%> (+3.91%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/arrow-rs/pull/275?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/275?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b76e8c9...93b7535](https://codecov.io/gh/apache/arrow-rs/pull/275?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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

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



[GitHub] [arrow-rs] Jimexist commented on pull request #275: Add nullary function and some unit tests

Posted by GitBox <gi...@apache.org>.
Jimexist commented on pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275#issuecomment-840549650


   > The code itself looks great.
   > 
   > I am not sure this is not shadowing `PrimitiveArray<T>::from_iter_values`, which IMO covers this exact case.
   
   fair point. i've updated the implementation. if this deems unnecessary i'm happy to remove all of the code except for the unit test addition.


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

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



[GitHub] [arrow-rs] Jimexist closed pull request #275: Add nullary function and some unit tests

Posted by GitBox <gi...@apache.org>.
Jimexist closed pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275


   


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

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



[GitHub] [arrow-rs] Dandandan commented on a change in pull request #275: add nullity function and some unit tests

Posted by GitBox <gi...@apache.org>.
Dandandan commented on a change in pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275#discussion_r629333194



##########
File path: arrow/src/compute/kernels/arity.rs
##########
@@ -72,3 +72,40 @@ where
     let data = into_primitive_array_data::<_, O>(array, buffer);
     PrimitiveArray::<O>::from(data)
 }
+
+/// Applies a nullary and infalible function to generate a primitive array.
+/// You should use this instead of the vectorized version when each generated value is different.
+pub fn nullary<F, O>(size: usize, op: F) -> PrimitiveArray<O>
+where
+    O: ArrowPrimitiveType,
+    F: Fn() -> O::Native,
+{
+    let values = (0..size).map(|_| op());

Review comment:
       This could use `std::iter::repeat`




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

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



[GitHub] [arrow-rs] Jimexist commented on pull request #275: Add nullary function and some unit tests

Posted by GitBox <gi...@apache.org>.
Jimexist commented on pull request #275:
URL: https://github.com/apache/arrow-rs/pull/275#issuecomment-837570205


   > @Jimexist will this work well for `random`? I'm assuming that this is the use-case you're targetting with it
   
   yes it would. but either way [i am taking another approach][1].
   
   [1]: https://github.com/apache/arrow-datafusion/pull/303/files#diff-4f1f0d4c03f4bbbca1380fee5e8ebfa97f5cfcf3ee917176839d17d80e5113b0R118


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

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