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/11/01 10:19:16 UTC

[GitHub] [arrow-rs] Ted-Jiang opened a new pull request, #2994: Support merge RowSelectors when creating RowSelection

Ted-Jiang opened a new pull request, #2994:
URL: https://github.com/apache/arrow-rs/pull/2994

   # 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 #2858 .
   
   # 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] alamb commented on a diff in pull request #2994: Support merge RowSelectors when creating RowSelection

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


##########
parquet/src/arrow/arrow_reader/selection.rs:
##########
@@ -117,6 +117,39 @@ impl RowSelection {
         Self { selectors }
     }
 
+    /// Creates a [`RowSelection`] from a slice of uncombined `RowSelector`:
+    /// Like [skip(5),skip(5),read(10)].
+    /// After combine will return [skip(10),read(10)]
+    /// # Note
+    /// If directly use uncombined `RowSelection` with offset_index in parquet
+    /// will panic.
+    fn from_selectors_and_combine(selectors: &[RowSelector]) -> Self {
+        if selectors.len() < 2 {
+            return Self {
+                selectors: Vec::from(selectors),
+            };
+        }
+        let first = selectors.first().unwrap();
+        let mut sum_rows = first.row_count;
+        let mut selected = first.skip;

Review Comment:
   ```suggestion
           let mut skip = first.skip;
   ```
   
   Maybe it would be easier to read this code if the name of the variable is the same as the name of the field that uses it 🤔 



##########
parquet/src/arrow/arrow_reader/selection.rs:
##########
@@ -117,6 +117,39 @@ impl RowSelection {
         Self { selectors }
     }
 
+    /// Creates a [`RowSelection`] from a slice of uncombined `RowSelector`:
+    /// Like [skip(5),skip(5),read(10)].
+    /// After combine will return [skip(10),read(10)]
+    /// # Note
+    /// If directly use uncombined `RowSelection` with offset_index in parquet
+    /// will panic.

Review Comment:
   ```suggestion
       /// # Note
       ///  [`RowSelection`] must be combined prior to use within offset_index or else the code will panic.
   ```



##########
parquet/src/arrow/arrow_reader/selection.rs:
##########
@@ -117,6 +117,39 @@ impl RowSelection {
         Self { selectors }
     }
 
+    /// Creates a [`RowSelection`] from a slice of uncombined `RowSelector`:

Review Comment:
   👍  thank you for the comments



##########
parquet/src/arrow/arrow_reader/selection.rs:
##########
@@ -470,6 +512,56 @@ mod tests {
         );
     }
 
+    #[test]
+    fn test_combine() {
+        let a = vec![
+            RowSelector::skip(3),
+            RowSelector::skip(3),
+            RowSelector::select(10),
+            RowSelector::skip(4),
+        ];
+
+        let b = vec![
+            RowSelector::skip(3),
+            RowSelector::skip(3),
+            RowSelector::select(10),
+            RowSelector::skip(4),
+            RowSelector::skip(0),
+        ];
+
+        let c = vec![
+            RowSelector::skip(2),
+            RowSelector::skip(4),
+            RowSelector::select(3),
+            RowSelector::select(3),
+            RowSelector::select(4),
+            RowSelector::skip(3),
+            RowSelector::skip(1),
+            RowSelector::skip(0),
+        ];
+
+        let expected = RowSelection::from(vec![
+            RowSelector::skip(6),
+            RowSelector::select(10),
+            RowSelector::skip(4),
+        ]);
+
+        assert_eq!(RowSelection::from_selectors_and_combine(&a), expected);
+        assert_eq!(RowSelection::from_selectors_and_combine(&b), expected);
+        assert_eq!(RowSelection::from_selectors_and_combine(&c), expected);
+    }
+
+    #[test]
+    fn test_from_one_and_empty() {
+        let a = vec![RowSelector::select(10)];
+        let selection1 = RowSelection::from(a.clone());
+        assert_eq!(selection1.selectors, a);

Review Comment:
   I also recommend tests for 2 selectors (only) to cover all edge cases:
   
   ```rust
   vec![
     RowSelector::select(10), 
     RowSelector::select(5)
   ];
   ```
   
   ```rust
   vec![
     RowSelector::select(10), 
     RowSelector::skip(5)
   ];
   ```
   
   ```rust
   vec![
     RowSelector::skip(10), 
     RowSelector::select(5)
   ];
   ```
   
   ```rust
   vec![
     RowSelector::skip(10), 
     RowSelector::skip(5)
   ];
   ```



-- 
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] alamb merged pull request #2994: Add `RowSelection::from_selectors_and_combine` to merge RowSelectors

Posted by GitBox <gi...@apache.org>.
alamb merged PR #2994:
URL: https://github.com/apache/arrow-rs/pull/2994


-- 
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] Ted-Jiang commented on a diff in pull request #2994: Support merge RowSelectors when creating RowSelection

Posted by GitBox <gi...@apache.org>.
Ted-Jiang commented on code in PR #2994:
URL: https://github.com/apache/arrow-rs/pull/2994#discussion_r1011248753


##########
parquet/src/arrow/arrow_reader/selection.rs:
##########
@@ -117,6 +117,39 @@ impl RowSelection {
         Self { selectors }
     }
 
+    /// Creates a [`RowSelection`] from a slice of uncombined `RowSelector`:
+    /// Like [skip(5),skip(5),read(10)].
+    /// After combine will return [skip(10),read(10)]
+    /// # Note
+    /// If directly use uncombined `RowSelection` with offset_index in parquet
+    /// will panic.
+    fn from_selectors_and_combine(selectors: &[RowSelector]) -> Self {
+        if selectors.len() < 2 {
+            return Self {
+                selectors: Vec::from(selectors),
+            };
+        }
+        let first = selectors.first().unwrap();
+        let mut sum_rows = first.row_count;
+        let mut selected = first.skip;

Review Comment:
   Yes 😂



-- 
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] ursabot commented on pull request #2994: Add `RowSelection::from_selectors_and_combine` to merge RowSelectors

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

   Benchmark runs are scheduled for baseline = 62e878e12229c7bc911e3096390fd72a8e20bda2 and contender = f11372cb8ff4d6fecbe1bd7b5ef3d66cba719c83. f11372cb8ff4d6fecbe1bd7b5ef3d66cba719c83 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/b9514d4d6de34b18994dd3b1d4967be5...4115858f6eca478abd9cbfeb046797b3/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/c54eb96dfd26486cb0dd4f56b6d3054d...fab5e0e0295b46d0907556ec6c8e4867/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/75f6a5985a2041ecad5a18d15faf6610...810e2b98d07c4caaa4d8e52533e97999/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/df0282903998459d8a36c2d555e88932...ac11b202fd124c2b8d28adcb6d879b78/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


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