1fanwang opened a new pull request, #3972:
URL: https://github.com/apache/avro/pull/3972

   ## What is the purpose of the change
   
   Java users who sort generic Avro records containing bytes can get a 
different order before and after serialization. Before this change, `0x7f` 
sorted after `0xff` in memory but before it in encoded data. After this change, 
both paths use Avro's unsigned byte order.
   
   `GenericData.compare` now compares byte buffers over their remaining ranges 
with unsigned values and absolute reads. This preserves buffer positions and 
works with heap, sliced, read-only, and direct buffers. Converted logical types 
keep the existing `Comparable` behavior.
   
   Fixes https://issues.apache.org/jira/browse/AVRO-4267
   
   ## Verifying this change
   
   This change adds coverage for unsigned values, prefixes, nonzero positions, 
sliced buffers, read-only buffers, direct buffers, position preservation, and 
converted logical types.
   
   <details>
   <summary>Raw logs</summary>
   
   Before, on `a9b88f538c74d2347444fac60d7289abcf231a50` with only the 
regression test applied:
   
   ```console
   $ JAVA_HOME=$(/usr/libexec/java_home -v 21) /opt/homebrew/bin/mvn -pl 
lang/java/avro 
-Dtest=TestCompare#genericBytesCompareMatchesBinaryUnsignedByteOrder test 
-DskipITs -DskipTests=false
   [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
   [ERROR] TestCompare.genericBytesCompareMatchesBinaryUnsignedByteOrder:75 
expected: <true> but was: <false>
   [INFO] BUILD FAILURE
   ```
   
   After:
   
   ```console
   $ JAVA_HOME=$(/usr/libexec/java_home -v 21) /opt/homebrew/bin/mvn 
-Dmaven.build.cache.enabled=false -pl lang/java/avro clean test -DskipITs
   [INFO] Spotless.Java is keeping 315 files clean - 0 needs changes to be 
clean, 315 were already clean, 0 were skipped because caching determined they 
were already clean
   [INFO] Tests run: 3463, Failures: 0, Errors: 0, Skipped: 2
   [INFO] You have 0 Checkstyle violations.
   [INFO] Tests run: 3463, Failures: 0, Errors: 0, Skipped: 2
   [INFO] Tests run: 3463, Failures: 0, Errors: 0, Skipped: 2
   [INFO] BUILD SUCCESS
   ```
   
   </details>
   
   ## Documentation
   
   - Does this pull request introduce a new feature? no
   - If yes, how is the feature documented? not applicable
   


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