fallintoplace opened a new pull request, #2145:
URL: https://github.com/apache/iceberg-go/pull/2145

   **What**
   - Speed up int32 and int64 truncate transforms.
   - Fix int32 truncation with large widths: `2147483646` at width `2147483647` 
should return `0`, but currently returns `-2147483647`.
   
   **Why**
   - The current expression uses two modulo operations. Adding width to a 
positive remainder can overflow int32.
   
   **Implementation**
   - Compute the remainder once. Add width only when the remainder is negative.
   - Add MaxInt32 regression coverage and a focused benchmark.
   
   **Benchmark**
   Apple M1 Pro, darwin/arm64, Go 1.26.3. Median of 5 runs, 300ms each, 
`-cpu=1`. Calls the public transformer with mixed positive and negative inputs.
   
   | Case | Before ns/op | After ns/op | B/op before → after | Allocs/op before 
→ after |
   | --- | ---: | ---: | ---: | ---: |
   | int32/mixed | 9.817 | 17.83 | 2 → 2 | 0 → 0 |
   | int64/mixed | 13.49 | 13.2 | 5 → 5 | 0 → 0 |
   | int32/width-max | 11.52 | 9.017 | 2 → 1 | 0 → 0 |
   
   ```sh
   go test . -run '^$' -bench '^BenchmarkTruncateTransformInteger$' -benchmem 
-benchtime=300ms -count=5 -cpu=1
   ```
   


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

Reply via email to