fabriziofortino commented on code in PR #1791:
URL: https://github.com/apache/jackrabbit-oak/pull/1791#discussion_r1799718054


##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/util/ElasticIndexUtils.java:
##########
@@ -52,6 +53,31 @@ public static String idFromPath(@NotNull String path) {
         return path;
     }
 
+    /**
+     * Generates a consistent short value based on a given string using the 
SHA-256 algorithm.
+     * The generated value  is a 16-bit integer ranging from -32,768 to 32,767.
+     *
+     * @param input the input string to be hashed
+     * @return a short value from the input string
+     * @throws IllegalStateException if the SHA-256 algorithm is not available
+     */
+    public static short getRandomShortFromString(String input) {
+        try {
+            // Get a SHA-256 MessageDigest instance
+            MessageDigest md = MessageDigest.getInstance("SHA-256");

Review Comment:
   Thanks for the hint @thomasmueller .
   
   I have replaced the use of `sha-256` for the random value generation with 
`murmur3`, provided by the shaded guava module. This is supposed to be a lot 
faster with a very low collision rate. It's not cryptographically secure, but 
we don't need that for this use case.



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