qzyu999 opened a new pull request, #841:
URL: https://github.com/apache/arrow-go/pull/841

   ### Rationale for this change
   
   The `ObjectValue.ValueByKey` function implements a custom binary search on 
the `v.value` array of field IDs to look up fields by key. It initializes its 
boundaries using an exclusive upper bound (`i, j := 0, n`).
   However, when the target key is smaller than the key at the `mid` index, it 
updates the upper bound with:
   `j = mid - 1`
   
   Since `j` is exclusive, setting it to `mid - 1` excludes the index `mid - 1` 
from the search space entirely. If the target key is located at `mid - 1`, the 
lookup will fail and return `arrow.ErrNotFound`. This results in missing fields 
or lookups failing on objects containing >= 32 fields.
   
   ### What changes are included in this PR?
   
   - Correct the exclusive upper bound update in `ObjectValue.ValueByKey` from 
`j = mid - 1` to `j = mid`.
   
   ### Are these changes tested?
   
   - Added `TestObjectBinarySearch` in `parquet/variant/variant_test.go` which 
constructs a 32-field object and verifies that all 32 lookups using 
`ValueByKey` succeed.
   
   ### Are there any user-facing changes?
   
   - No API changes. This is a correctness bug fix.
   


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