[ 
https://issues.apache.org/jira/browse/STORM-139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14635414#comment-14635414
 ] 

ASF GitHub Bot commented on STORM-139:
--------------------------------------

Github user d2r commented on a diff in the pull request:

    https://github.com/apache/storm/pull/641#discussion_r35127032
  
    --- Diff: 
storm-core/src/jvm/backtype/storm/grouping/PartialKeyGrouping.java ---
    @@ -65,7 +66,11 @@ public void prepare(WorkerTopologyContext context, 
GlobalStreamId stream, List<I
                     List<Object> selectedFields = outFields.select(fields, 
values);
                     ByteBuffer out = ByteBuffer.allocate(selectedFields.size() 
* 4);
                     for (Object o: selectedFields) {
    -                    out.putInt(o.hashCode());
    +                    if (o instanceof Object[]) {
    --- End diff --
    
    I see. Yes, I could add this.  However, since we do not currently do this 
in backtype.storm.tuple it would be inconsistent.
    
    In b.s.tuple, I always get a List<Object>.  I convert it to an array there 
because the call to Arrays#deepHashCode is simple.  If a tuple is _itself_ a 
List, then Arrays#hashCode will call List#hashCode on it.



> hashCode does not work for byte[]
> ---------------------------------
>
>                 Key: STORM-139
>                 URL: https://issues.apache.org/jira/browse/STORM-139
>             Project: Apache Storm
>          Issue Type: Bug
>            Reporter: James Xu
>            Priority: Minor
>
> https://github.com/nathanmarz/storm/issues/245
> Storm should use a different hashCode method when getting the hash for a 
> byte[] array, since the default one uses the object identity. Should check 
> the behavior on other arrays as well
> ----------
> xiaokang: I tested byte[] and other arrays. The hashCode of array is the 
> array object identity.
> I alse tested that java.util.Arrays.hashCode(xx[]) is based of the array 
> element's hash code. It maybe ok change the list-hash-code function of 
> tuple.clj to fix the problem.
> ----------
> Sirwellington: you may want to read this:
> http://martin.kleppmann.com/2012/06/18/java-hashcode-unsafe-for-distributed-systems.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to