adriangb opened a new pull request, #11568:
URL: https://github.com/apache/arrow-rs/pull/11568

   > [!IMPORTANT]
   > This PR is stacked on https://github.com/apache/arrow-rs/pull/11459. Do 
not merge it first. To see only the changes of this PR, use this diff: 
https://github.com/pydantic/arrow-rs/compare/claude/push-buffers-release-binary-search...claude/push-buffers-max-len-tracker
   
   # Which issue does this PR close?
   
   - Follow-up to https://github.com/apache/arrow-rs/pull/11459, as @alamb 
suggested in 
https://github.com/apache/arrow-rs/pull/11459#pullrequestreview-5523546294
   
   # Rationale for this change
   
   In `PushBuffers`, the fields `max_len` and `max_len_count` must agree. 
Before this change, four places in the code changed the two fields by hand, and 
the compare logic was in two places. If a future change updates one field but 
not the other, lookups can become slow or the invariant check fails.
   
   # What changes are included in this PR?
   
   - A new private type `MaxLen { len, count }` replaces the two fields. Only 
its methods change the values:
     - `add(len)` records a pushed range.
     - `remove(len)` records a removed range.
     - `rescan_if_stale(lens)` does the full pass only when no range of the 
longest length remains (as before).
     - `get()` gives the length for lookups.
   - The function `update_max_len` is removed. Its logic is now in 
`MaxLen::rescan_if_stale`.
   - All methods are small and `#[inline]`. The behaviour does not change.
   
   # Are these changes tested?
   
   Yes, by the existing `push_buffers` and `push_decoder` tests. 
`assert_invariants` still checks that `len` and `count` agree with the buffered 
ranges.
   
   # Are there any user-facing changes?
   
   No. The type is private.
   
   🤖 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: [email protected]

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

Reply via email to