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 7f6f010 ARROW-6234: [Java] ListVector hashCode() is not correct 7f6f010 is described below commit 7f6f010eeabd6eb58cb45a298843d5133c268331 Author: tianchen <niki...@alibaba-inc.com> AuthorDate: Wed Aug 14 22:06:30 2019 -0700 ARROW-6234: [Java] ListVector hashCode() is not correct Related to [ARROW-6234](https://issues.apache.org/jira/browse/ARROW-6234). Current implement is not correct: for (int i = start; i < end; i++) { hash = 31 * vector.hashCode(i); } Should be something like: hash = 31 * hash + vector.hashCode(i); Closes #5082 from tianchen92/ARROW-6234 and squashes the following commits: 9ad7a7ed9 <tianchen92> Merge branch 'master' into ARROW-6234 ff2b01f3c <tianchen92> Merge branch 'master' into ARROW-6234 0bb79e299 <tianchen> ARROW-6234: ListVector hashCode() is not correct Lead-authored-by: tianchen <niki...@alibaba-inc.com> Co-authored-by: tianchen92 <niki...@alibaba-inc.com> Signed-off-by: Micah Kornfield <emkornfi...@gmail.com> --- .../src/main/java/org/apache/arrow/vector/complex/ListVector.java | 3 ++- .../java/org/apache/arrow/vector/complex/NonNullableStructVector.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java index cfe3278..81dc880 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java @@ -28,6 +28,7 @@ import java.util.List; import org.apache.arrow.memory.BaseAllocator; import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.OutOfMemoryException; +import org.apache.arrow.memory.util.ByteFunctionHelpers; import org.apache.arrow.util.Preconditions; import org.apache.arrow.vector.AddOrGetResult; import org.apache.arrow.vector.BitVectorHelper; @@ -425,7 +426,7 @@ public class ListVector extends BaseRepeatedValueVector implements FieldVector, final int start = offsetBuffer.getInt(index * OFFSET_WIDTH); final int end = offsetBuffer.getInt((index + 1) * OFFSET_WIDTH); for (int i = start; i < end; i++) { - hash = 31 * vector.hashCode(i); + hash = ByteFunctionHelpers.comebineHash(hash, vector.hashCode(i)); } return hash; } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java index 9c43db4..9c71156 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Map; import org.apache.arrow.memory.BufferAllocator; +import org.apache.arrow.memory.util.ByteFunctionHelpers; import org.apache.arrow.util.Preconditions; import org.apache.arrow.vector.DensityAwareVector; import org.apache.arrow.vector.FieldVector; @@ -301,7 +302,7 @@ public class NonNullableStructVector extends AbstractStructVector { for (String child : getChildFieldNames()) { ValueVector v = getChild(child); if (v != null && index < v.getValueCount()) { - hash += 31 * hash + v.hashCode(index); + hash = ByteFunctionHelpers.comebineHash(hash, v.hashCode(index)); } } return hash;