emkornfield commented on code in PR #38867:
URL: https://github.com/apache/arrow/pull/38867#discussion_r1405601389


##########
cpp/src/parquet/column_reader.h:
##########
@@ -302,8 +303,274 @@ class TypedColumnReader : public ColumnReader {
                                           int32_t* dict_len) = 0;
 };
 
+struct Range {
+  static Range unionRange(const Range& left, const Range& right) {
+    if (left.from <= right.from) {
+      if (left.to + 1 >= right.from) {
+        return {left.from, std::max(left.to, right.to)};
+      }
+    } else if (right.to + 1 >= left.from) {
+      return {right.from, std::max(left.to, right.to)};
+    }
+    return {-1, -1};
+  }
+
+  static Range intersection(const Range& left, const Range& right) {
+    if (left.from <= right.from) {
+      if (left.to >= right.from) {
+        return {right.from, std::min(left.to, right.to)};
+      }
+    } else if (right.to >= left.from) {
+      return {left.from, std::min(left.to, right.to)};
+    }
+    return {-1, -1};  // Return a default Range object if no intersection 
range found
+  }
+
+  int64_t from;
+  int64_t to;
+
+  Range(const int64_t from_, const int64_t to_) : from(from_), to(to_) {
+    assert(from <= to);
+  }
+
+  size_t count() const { return to - from + 1; }
+
+  bool isBefore(const Range& other) const { return to < other.from; }
+
+  bool isAfter(const Range& other) const { return from > other.to; }
+
+  bool isOverlap(const Range& other) const { return !isBefore(other) && 
!isAfter(other); }
+
+  std::string toString() const {
+    return "[" + std::to_string(from) + ", " + std::to_string(to) + "]";
+  }
+};
+
+class RowRanges {

Review Comment:
   This seems like a relatively heavy-weight represenation if most ranges 
aren't runs.  did you consider other alternatives?
   
   CC @fatemehp 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to