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