Class RowRanges.Builder

java.lang.Object
org.apache.parquet.filter2.columnindex.RowRanges.Builder
Enclosing class:
RowRanges

public static final class RowRanges.Builder extends Object
Constructs a RowRanges by appending selected row indices in strictly increasing order. Consecutive indices are coalesced into a single RowRanges.Range; gaps close the current run and start a new one.

Usage:


 RowRanges.Builder builder = RowRanges.builder();
 for (long row : selectedRowsInOrder) {
   builder.addSelectedRow(row);
 }
 RowRanges ranges = builder.build();
 
  • Method Details

    • addSelectedRow

      public RowRanges.Builder addSelectedRow(long rowIndex)
      Marks rowIndex as selected. The value is a 0-based row index within the current row group. Must be called in strictly increasing order; calling with a value less than or equal to the previous call's value throws IllegalArgumentException.
      Parameters:
      rowIndex - the 0-based row index to mark selected (must be > the last value passed and non-negative)
      Returns:
      this builder for chaining
    • addSelectedRange

      public RowRanges.Builder addSelectedRange(long from, long to)
      Marks the inclusive range [from, to] of 0-based row indices as selected. Ranges must be appended in strictly increasing order: from must be greater than the last selected row index. A range directly adjacent to the current run (where from is exactly one past the previous to) is coalesced into a single RowRanges.Range; a gap closes the current run and starts a new one.
      Parameters:
      from - the first 0-based row index of the range (inclusive; must be > the last selected row index and non-negative)
      to - the last 0-based row index of the range (inclusive; must be >= from)
      Returns:
      this builder for chaining
    • build

      public RowRanges build()
      Returns a snapshot of the rows selected so far. The returned RowRanges is independent of this builder, so the builder may continue to be used afterwards without affecting it.
      Returns:
      the constructed RowRanges, or RowRanges.EMPTY when no rows were selected.