Skip to content

Commit 0bb79e2

Browse files
committed
ARROW-6234: [Java] ListVector hashCode() is not correct
1 parent cafb00f commit 0bb79e2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.arrow.memory.BaseAllocator;
2929
import org.apache.arrow.memory.BufferAllocator;
3030
import org.apache.arrow.memory.OutOfMemoryException;
31+
import org.apache.arrow.memory.util.ByteFunctionHelpers;
3132
import org.apache.arrow.util.Preconditions;
3233
import org.apache.arrow.vector.AddOrGetResult;
3334
import org.apache.arrow.vector.BitVectorHelper;
@@ -422,7 +423,7 @@ public int hashCode(int index) {
422423
final int start = offsetBuffer.getInt(index * OFFSET_WIDTH);
423424
final int end = offsetBuffer.getInt((index + 1) * OFFSET_WIDTH);
424425
for (int i = start; i < end; i++) {
425-
hash = 31 * vector.hashCode(i);
426+
hash = ByteFunctionHelpers.comebineHash(hash, vector.hashCode(i));
426427
}
427428
return hash;
428429
}

java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.Map;
2727

2828
import org.apache.arrow.memory.BufferAllocator;
29+
import org.apache.arrow.memory.util.ByteFunctionHelpers;
2930
import org.apache.arrow.util.Preconditions;
3031
import org.apache.arrow.vector.DensityAwareVector;
3132
import org.apache.arrow.vector.FieldVector;
@@ -294,7 +295,7 @@ public int hashCode(int index) {
294295
for (String child : getChildFieldNames()) {
295296
ValueVector v = getChild(child);
296297
if (v != null && index < v.getValueCount()) {
297-
hash += 31 * hash + v.hashCode(index);
298+
hash = ByteFunctionHelpers.comebineHash(hash, v.hashCode(index));
298299
}
299300
}
300301
return hash;

0 commit comments

Comments
 (0)