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/06/05 05:26:19 UTC

[GitHub] [arrow-rs] viirya commented on a diff in pull request #1791: feat:Implement page filtering with Row Alignment

viirya commented on code in PR #1791:
URL: https://github.com/apache/arrow-rs/pull/1791#discussion_r889650972


##########
parquet/src/file/page_index/range.rs:
##########
@@ -0,0 +1,474 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+use crate::errors::ParquetError;
+use parquet_format::PageLocation;
+use std::cmp::Ordering;
+use std::collections::VecDeque;
+
+/// A row range
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub struct Range {
+    /// Its start
+    pub from: usize,
+    /// Its end
+    pub to: usize,
+}
+
+impl Range {
+    // Creates a range of [from, to] (from and to are both inclusive)
+    pub fn new(from: usize, to: usize) -> Self {
+        assert!(from <= to);
+        Self { from, to }
+    }
+
+    pub fn count(&self) -> usize {
+        self.to - self.from + 1
+    }
+
+    pub fn is_before(&self, other: &Range) -> bool {
+        self.to < other.from
+    }
+
+    pub fn is_after(&self, other: &Range) -> bool {
+        self.from > other.to
+    }
+
+    /// Return the union of the two ranges,
+    /// Return `None` if there are hole between them.
+    pub fn union(left: &Range, right: &Range) -> Option<Range> {
+        if left.from <= right.from {
+            if left.to + 1 >= right.from {
+                return Some(Range {
+                    from: left.from,
+                    to: std::cmp::max(left.to, right.to),
+                });
+            }
+        } else if right.to + 1 >= left.from {
+            return Some(Range {
+                from: right.from,
+                to: std::cmp::max(left.to, right.to),
+            });
+        }
+        None
+    }
+
+    /// Returns the intersection of the two ranges,
+    /// return null if they are not overlapped.
+    pub fn intersection(left: &Range, right: &Range) -> Option<Range> {
+        if left.from <= right.from {
+            if left.to >= right.from {
+                return Some(Range {
+                    from: right.from,
+                    to: std::cmp::min(left.to, right.to),
+                });
+            }
+        } else if right.to >= left.from {
+            return Some(Range {
+                from: left.from,
+                to: std::cmp::min(left.to, right.to),
+            });
+        }
+        None
+    }
+}
+
+///Struct representing row ranges in a row-group. These row ranges are calculated as a result of using
+///the column index on the filtering.

Review Comment:
   ```suggestion
   /// Struct representing row ranges in a row-group. These row ranges are calculated as a result of using
   /// the column index on the filtering.
   ```
   
   There are some style issues like that.



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