Copilot commented on code in PR #3599:
URL: https://github.com/apache/parquet-java/pull/3599#discussion_r3378311287


##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileReader.java:
##########
@@ -1489,9 +1489,23 @@ public ColumnIndexStore getColumnIndexStore(int 
blockIndex) {
     return ciStore;
   }
 
-  private RowRanges getRowRanges(int blockIndex) {
-    assert FilterCompat.isFilteringRequired(options.getRecordFilter())
-        : "Should not be invoked if filter is null or NOOP";
+  /**
+   * Computes the {@link RowRanges} within the given row group that may pass 
the configured filter
+   * (set via {@link ParquetReadOptions} or {@link 
ParquetInputFormat#setFilterPredicate}). If no
+   * filter is configured, returns a {@link RowRanges} covering all rows in 
the row group.
+   *
+   * <p>This computation is metadata-only: it consults each filter-referenced 
column's column
+   * index from the file footer; no column data is read from disk. The result 
can be passed to
+   * {@link #readFilteredRowGroup(int, RowRanges)} (intersected with any 
caller-supplied row
+   * ranges if desired) to read only the matching pages.
+   *
+   * @param blockIndex the row group (block) index
+   * @return row ranges within the block that may pass the configured filter
+   */
+  public RowRanges getRowRanges(int blockIndex) {
+    if (!FilterCompat.isFilteringRequired(options.getRecordFilter())) {
+      return RowRanges.createSingle(blocks.get(blockIndex).getRowCount());
+    }
     RowRanges rowRanges = blockRowRanges.get(blockIndex);
     if (rowRanges == null) {

Review Comment:
   `getRowRanges` is now public, but it doesn’t validate `blockIndex` (unlike 
other public block-indexed APIs in this class) and it can construct an invalid 
`RowRanges` when the block has 0 rows: `RowRanges.createSingle(0)` creates a 
range `[0, -1]` and trips assertions / yields undefined behavior. Consider 
validating `blockIndex` and returning `RowRanges.EMPTY` for empty blocks before 
calling `RowRanges.createSingle(...)`.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to