[infinispan-dev] Creating ByteArrayKey to solve client/server hashing differences in HotRod

Mircea Markus mircea.markus at jboss.com
Thu Jun 10 11:46:58 EDT 2010


On 10 Jun 2010, at 14:08, galder at redhat.com wrote:

> Hi all,
> 
> Re: https://jira.jboss.org/browse/ISPN-491
> 
> It's apparent that client and server were not calculating hashcode on the same thing. We don't want to force clients to do hash on Java classes cos that would make clients language independent and we can't use byte[] keys in the cache due to equality issues (array equality is based on reference, not Arrays.equals). So, we're forced to create a ByteArrayKey class in core/ to basically mimic what HotRod's CacheKey does in a more generic way. Diablo-D3 suggested using nio.ByteBuffer to wrap the key around, but this sounds like a heavy handed approach for simply having byte array keys that compare as expected, i.e. BB class brings in extra information such as position, limit...etc that has no use and would only take memory space.
+1
> 
> We'll modify MurmurHash2.hash(Object o) so that if a ByteArrayKey is passed, it takes the underlying byte[] and calculates the hash on that. This way we'll make sure that both clients and servers hash on the same thing.
> 
> However, I think the long term goal should be https://jira.jboss.org/browse/ISPN-492. If we had underlying maps that did array equality based on contents, we would not have these problems and would not need for auxiliary classes.
> 
> Cheers,
> --
> Galder Zamarreño
> Sr. Software Engineer
> Infinispan, JBoss Cache
> 
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev




More information about the infinispan-dev mailing list