jfboeuf commented on code in PR #11900:
URL: https://github.com/apache/lucene/pull/11900#discussion_r1019030241


##########
lucene/codecs/src/java/org/apache/lucene/codecs/bloom/MurmurHash64.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.codecs.bloom;
+
+import org.apache.lucene.util.BytesRef;
+
+/**
+ * This is a very fast, non-cryptographic hash suitable for general hash-based 
lookup. See
+ * http://murmurhash.googlepages.com/ for more details.
+ *
+ * <p>The code from Apache Commons was adapted in the form here to work with 
BytesRefs with offsets
+ * and lengths rather than raw byte arrays.
+ */
+public class MurmurHash64 extends HashFunction {
+  private static final long M64 = 0xc6a4a7935bd1e995L;
+  private static final int R64 = 47;
+  public static final HashFunction INSTANCE = new MurmurHash64();
+
+  /**
+   * Generates a 64-bit hash from byte array of the given length and seed.
+   *
+   * @param data The input byte array
+   * @param seed The initial seed value
+   * @param length The length of the array
+   * @return The 64-bit hash of the given array
+   */
+  public static long hash64(byte[] data, int seed, int offset, int length) {
+    long h = (seed & 0xffffffffL) ^ (length * M64);
+
+    final int nblocks = length >> 3;
+
+    // body
+    for (int i = 0; i < nblocks; i++) {
+
+      long k = getLittleEndianLong(data, offset);

Review Comment:
   Thanks, I will do it.



-- 
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...@lucene.apache.org

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


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

Reply via email to