You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by em...@apache.org on 2019/08/01 03:32:05 UTC
[arrow] branch master updated: ARROW-6020: [Java] Refactor
ByteFunctionHelper#hash with new added ArrowBufHasher
This is an automated email from the ASF dual-hosted git repository.
emkornfield pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 0823b49 ARROW-6020: [Java] Refactor ByteFunctionHelper#hash with new added ArrowBufHasher
0823b49 is described below
commit 0823b4979dc611a235a9430d5e0ac5e5d4af25c5
Author: tianchen <ni...@alibaba-inc.com>
AuthorDate: Wed Jul 31 20:31:06 2019 -0700
ARROW-6020: [Java] Refactor ByteFunctionHelper#hash with new added ArrowBufHasher
Related to [ARROW-6020](https://issues.apache.org/jira/browse/ARROW-6020).
Some logic in these two classes are similar, should replace ByteFunctionHelper#hash logic with ArrowBufHasher since it has murmur hash algorithm which could avoid hash collision.
Closes #4938 from tianchen92/ARROW-6020 and squashes the following commits:
108ae1858 <tianchen> fix style
859176620 <tianchen> ARROW-6020: Refactor ByteFunctionHelper#hash with new added ArrowBufHasher
Authored-by: tianchen <ni...@alibaba-inc.com>
Signed-off-by: Micah Kornfield <em...@gmail.com>
---
.../arrow/memory/util/ByteFunctionHelpers.java | 31 +++-------------------
1 file changed, 4 insertions(+), 27 deletions(-)
diff --git a/java/memory/src/main/java/org/apache/arrow/memory/util/ByteFunctionHelpers.java b/java/memory/src/main/java/org/apache/arrow/memory/util/ByteFunctionHelpers.java
index c2f83fc..da81b41 100644
--- a/java/memory/src/main/java/org/apache/arrow/memory/util/ByteFunctionHelpers.java
+++ b/java/memory/src/main/java/org/apache/arrow/memory/util/ByteFunctionHelpers.java
@@ -18,6 +18,8 @@
package org.apache.arrow.memory.util;
import org.apache.arrow.memory.BoundsChecking;
+import org.apache.arrow.memory.util.hash.ArrowBufHasher;
+import org.apache.arrow.memory.util.hash.DirectHasher;
import io.netty.buffer.ArrowBuf;
import io.netty.util.internal.PlatformDependent;
@@ -250,35 +252,10 @@ public class ByteFunctionHelpers {
* Compute hashCode with the given {@link ArrowBuf} and start/end index.
*/
public static final int hash(final ArrowBuf buf, int start, int end) {
- long addr = buf.memoryAddress();
- int len = end - start;
- long pos = addr + start;
- int hash = 0;
+ ArrowBufHasher hasher = DirectHasher.INSTANCE;
- while (len > 7) {
- long value = PlatformDependent.getLong(pos);
- hash = comebineHash(hash, Long.hashCode(value));
-
- pos += 8;
- len -= 8;
- }
-
- while (len > 3) {
- int value = PlatformDependent.getInt(pos);
- hash = comebineHash(hash, value);
-
- pos += 4;
- len -= 4;
- }
-
- while (len-- != 0) {
- byte value = PlatformDependent.getByte(pos);
- hash = comebineHash(hash, value);
- pos ++;
- }
-
- return hash;
+ return hasher.hashCode(buf, start, end - start);
}
/**