You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "Jackie-Jiang (via GitHub)" <gi...@apache.org> on 2026/04/01 19:29:33 UTC

[PR] Simplify PinotSegmentColumnReaderImpl _nextDocId handling [pinot]

Jackie-Jiang opened a new pull request, #18075:
URL: https://github.com/apache/pinot/pull/18075

   ## Summary
   - Rename `_currentIndex` to `_nextDocId` for clarity
   - Remove unused `_reuseValue` field and associated null-check logic
   - Collapse two-line read-then-increment patterns into single inline post-increment expressions across all `next*` methods
   
   ## Test plan
   - [ ] Existing unit tests for `PinotSegmentColumnReaderImpl` pass
   - [ ] No behavioral change — purely mechanical simplification
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Simplify PinotSegmentColumnReaderImpl handling [pinot]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #18075:
URL: https://github.com/apache/pinot/pull/18075#issuecomment-4172723982

   ## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/18075?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `0%` with `20 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 56.22%. Comparing base ([`f81a91b`](https://app.codecov.io/gh/apache/pinot/commit/f81a91bdc90edbb3c1fbae893580e2a3b0923927?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`1e922b4`](https://app.codecov.io/gh/apache/pinot/commit/1e922b4fab1d22a199c1847688d556d7a1d50893?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/pinot/pull/18075?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [.../segment/readers/PinotSegmentColumnReaderImpl.java](https://app.codecov.io/gh/apache/pinot/pull/18075?src=pr&el=tree&filepath=pinot-segment-local%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fsegment%2Flocal%2Fsegment%2Freaders%2FPinotSegmentColumnReaderImpl.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3Qtc2VnbWVudC1sb2NhbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3Qvc2VnbWVudC9sb2NhbC9zZWdtZW50L3JlYWRlcnMvUGlub3RTZWdtZW50Q29sdW1uUmVhZGVySW1wbC5qYXZh) | 0.00% | [20 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/18075?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (f81a91b) and HEAD (1e922b4). Click for more details.
   > 
   > <details><summary>HEAD has 36 uploads less than BASE</summary>
   >
   >| Flag | BASE (f81a91b) | HEAD (1e922b4) |
   >|------|------|------|
   >|java-21|5|1|
   >|unittests1|2|1|
   >|unittests|4|1|
   >|temurin|10|1|
   >|java-11|5|0|
   >|unittests2|2|0|
   >|integration|6|0|
   >|integration2|2|0|
   >|integration1|2|0|
   >|custom-integration1|2|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #18075      +/-   ##
   ============================================
   - Coverage     63.75%   56.22%   -7.54%     
   + Complexity     1538      743     -795     
   ============================================
     Files          3160     2462     -698     
     Lines        190784   139681   -51103     
     Branches      29282    22328    -6954     
   ============================================
   - Hits         121628    78529   -43099     
   + Misses        59606    54484    -5122     
   + Partials       9550     6668    -2882     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/pinot/pull/18075/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [custom-integration1](https://app.codecov.io/gh/apache/pinot/pull/18075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration](https://app.codecov.io/gh/apache/pinot/pull/18075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration1](https://app.codecov.io/gh/apache/pinot/pull/18075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration2](https://app.codecov.io/gh/apache/pinot/pull/18075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [java-11](https://app.codecov.io/gh/apache/pinot/pull/18075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [java-21](https://app.codecov.io/gh/apache/pinot/pull/18075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.22% <0.00%> (-7.49%)` | :arrow_down: |
   | [temurin](https://app.codecov.io/gh/apache/pinot/pull/18075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.22% <0.00%> (-7.54%)` | :arrow_down: |
   | [unittests](https://app.codecov.io/gh/apache/pinot/pull/18075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.22% <0.00%> (-7.53%)` | :arrow_down: |
   | [unittests1](https://app.codecov.io/gh/apache/pinot/pull/18075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.22% <0.00%> (-0.02%)` | :arrow_down: |
   | [unittests2](https://app.codecov.io/gh/apache/pinot/pull/18075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/pinot/pull/18075?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Simplify PinotSegmentColumnReaderImpl handling [pinot]

Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang merged PR #18075:
URL: https://github.com/apache/pinot/pull/18075


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Simplify PinotSegmentColumnReaderImpl handling [pinot]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #18075:
URL: https://github.com/apache/pinot/pull/18075#discussion_r3024217538


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/readers/PinotSegmentColumnReaderImpl.java:
##########
@@ -111,35 +107,28 @@ public Object next()
     }
 
     // Return null if the value is null and skipDefaultNullValues is true
-    if (_skipDefaultNullValues && _segmentColumnReader.isNull(_currentIndex)) {
-      _currentIndex++;
-      return null;
-    }
-    _reuseValue = _segmentColumnReader.getValue(_currentIndex);
-    _currentIndex++;
-
-    // Return null if the value is null
-    if (_reuseValue == null) {
+    if (_skipDefaultNullValues && _segmentColumnReader.isNull(_nextDocId)) {
+      _nextDocId++;
       return null;
     }
 
-    return _reuseValue;
+    return _segmentColumnReader.getValue(_nextDocId++);

Review Comment:
   Using `_nextDocId++` inside the `getValue(...)` call increments `_nextDocId` during argument evaluation, before `getValue` executes. If `getValue` throws (e.g., segment corruption or misuse), the reader cursor will still advance, which differs from the previous behavior where the cursor only advanced after a successful read. To preserve iterator semantics, increment `_nextDocId` only after the read succeeds (e.g., keep the read-then-increment pattern or increment in a separate statement after the call).
   ```suggestion
       Object value = _segmentColumnReader.getValue(_nextDocId);
       _nextDocId++;
       return value;
   ```



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/readers/PinotSegmentColumnReaderImpl.java:
##########
@@ -260,66 +235,53 @@ public MultiValueResult<int[]> nextIntMV() {
     if (!hasNext()) {
       throw new IllegalStateException("No more values available");
     }
-    int[] value = _segmentColumnReader.getIntMV(_currentIndex);
-    _currentIndex++;
-    return MultiValueResult.of(value, null);
+    return MultiValueResult.of(_segmentColumnReader.getIntMV(_nextDocId++), null);
   }

Review Comment:
   Same cursor-advance-on-exception issue: `_nextDocId++` is incremented before `getIntMV(...)` executes, so failures still advance the reader state. If preserving the previous semantics matters, increment `_nextDocId` only after successfully retrieving the MV value.



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/readers/PinotSegmentColumnReaderImpl.java:
##########
@@ -187,69 +176,55 @@ public int nextInt() {
     if (!hasNext()) {
       throw new IllegalStateException("No more values available");
     }
-    int value = _segmentColumnReader.getInt(_currentIndex);
-    _currentIndex++;
-    return value;
+    return _segmentColumnReader.getInt(_nextDocId++);
   }

Review Comment:
   Same cursor-advance-on-exception issue as `next()`: `_nextDocId++` is evaluated (and increments the cursor) before `getInt(...)` is invoked. If `getInt` throws, the cursor has still advanced, unlike the previous implementation. Consider restoring the two-statement read-then-increment pattern to keep cursor movement conditional on a successful read.



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/readers/PinotSegmentColumnReaderImpl.java:
##########
@@ -93,13 +90,12 @@ public PinotSegmentColumnReaderImpl(PinotSegmentColumnReader segmentColumnReader
     _columnName = columnName;
     _numDocs = numDocs;
     _dataType = dataType;
-    _currentIndex = 0;
     _skipDefaultNullValues = skipDefaultNullValues;
   }

Review Comment:
   `_nextDocId` is no longer explicitly initialized in the constructor (it will default to 0). For consistency with other ColumnReader implementations in this package (e.g., DefaultValueColumnReader) and to make the cursor initialization obvious, consider setting `_nextDocId = 0;` in the constructor (or at declaration).



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org