sherman commented on issue #3139:
URL: https://github.com/apache/parquet-java/issues/3139#issuecomment-2622247352

   Hi, @gszadovszky !
   
   Yes, you're absolutely right. The situation is a bit more complex, but I see 
a potential workaround.
   
   Inside the JDK, there's a class called *ArraysSupport*, which provides the 
*vectorizedHashCode* method that we need. This method also supports additional 
arguments, such as *offset* and *len*, allowing it to work with array slices.
   
   ### The Problem
   The ArraysSupport class is located in a module that is not exported by 
default. However, we can still access it by adding an extra export directive to 
the compiler:
   ```
   --add-exports=java.base/jdk.internal.util=ALL-UNNAMED
   ```
   Alternatively, a reference to the class can be obtained via a method handle.
   
   The final implementation might look something like this:
   ```java
   public static int hashCode(byte[] array, int offset, int length) throws 
Throwable {
       var len = Math.max(0, length - offset);
   
       return switch (len) {
           case 0 -> 1;
           case 1 -> 31 + (int) array[0];
           default -> ArraysSupport.vectorizedHashCode(array, 0, array.length, 
1, ArraysSupport.T_BYTE);
       };
   }
   ```


-- 
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: issues-unsubscr...@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@parquet.apache.org
For additional commands, e-mail: issues-h...@parquet.apache.org

Reply via email to