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/03/08 12:05:39 UTC

[GitHub] [arrow-rs] HaoYang670 opened a new issue #1408: Remove duplicate bound check in function `shift`

HaoYang670 opened a new issue #1408:
URL: https://github.com/apache/arrow-rs/issues/1408


   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   https://github.com/apache/arrow-rs/blob/master/arrow%2Fsrc%2Fcompute%2Fkernels%2Fwindow.rs#L61-L66
   ```rust
       if offset == 0 {
           Ok(make_array(array.data_ref().clone()))
       } else if offset == i64::MIN || abs(offset) >= value_len {
           Ok(new_null_array(array.data_type(), array.len()))
       } else {
           let slice_offset = clamp(-offset, 0, value_len) as usize;
           ...
   ```
   When calculate `slice_offset`, we don't need to compare `-offset` with `value_len`, because we have checked `abs(offset) >= value_len` before.
   
   **Describe the solution you'd like**
   `slice_offset` should be `0` when `offset > 0` (shift left) and `-offset` when `offset < 0` (shift right).  Maybe we can use `clamp_min`
   
   **Describe alternatives you've considered**
   A clear and concise description of any alternative solutions or features you've considered.
   
   **Additional context**
   Add any other context or screenshots about the feature request here.
   


-- 
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] sunchao closed issue #1408: Remove duplicate bound check in function `shift`

Posted by GitBox <gi...@apache.org>.
sunchao closed issue #1408:
URL: https://github.com/apache/arrow-rs/issues/1408


   


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