peter-toth commented on code in PR #3597:
URL: https://github.com/apache/parquet-java/pull/3597#discussion_r3498799825
##########
parquet-column/src/main/java/org/apache/parquet/internal/filter2/columnindex/RowRanges.java:
##########
@@ -316,4 +316,72 @@ public List<Range> getRanges() {
public String toString() {
return ranges.toString();
}
+
+ /**
+ * @return a new {@link Builder} for constructing a {@link RowRanges} from a
sequence of
+ * selected row indices.
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Constructs a {@link RowRanges} by appending selected row indices in
strictly increasing
+ * order. Consecutive indices are coalesced into a single {@link Range};
gaps close the
+ * current run and start a new one.
+ *
+ * <p>Usage:
+ * <pre>{@code
+ * RowRanges.Builder builder = RowRanges.builder();
+ * for (long row : selectedRowsInOrder) {
+ * builder.addSelected(row);
+ * }
+ * RowRanges ranges = builder.build();
+ * }</pre>
+ */
+ public static class Builder {
+ private final List<Range> ranges = new ArrayList<>();
+ private long runStart = -1; // -1 = no active run
+ private long runEnd = -1; // valid iff runStart >= 0
+
+ /**
+ * Marks {@code blockRow} as selected. Must be called in strictly
increasing order; calling
+ * with a value less than or equal to the previous call's value throws
+ * {@link IllegalArgumentException}.
+ *
+ * @param blockRow the row index to mark selected (must be {@code >} the
last value passed)
+ * @return this builder for chaining
+ */
+ public Builder addSelected(long blockRow) {
Review Comment:
Renamed in
https://github.com/apache/parquet-java/pull/3597/commits/17cce6912afcc3836d96f703fae0462b67b5dff2.
--
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]