ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrey Mashenkov <andrey.mashen...@gmail.com>
Subject Re: Same object different hashes
Date Fri, 23 Mar 2018 13:31:55 GMT
Hi,

LiteralByteString has 'hash' field for caching hash code. It is equals to
zero by default that means that it was not calculated yet.
LiteralByteString can change its state after hash() method called.
So, from Ignite perspective, they will be two different objects when serialized
before and after the hash() call.



On Fri, Mar 23, 2018 at 9:39 AM, Ariel Tubaltsev <tubaltzev@gmail.com>
wrote:

> When fetching a key from different data structures on the client side, I
> can
> end up with not finding the object in the cache after putting it there.
>
> Server logs will show different hash values for the same object:
>
> PUT:
> *** Received event [cache=demo, evt=CACHE_OBJECT_PUT,
> key=com.google.protobuf.ByteString$LiteralByteString [idHash=2039727365,
> hash=-943417763, bytes=[86, 83], hash=0]
>
> GET succeeds:
> *** Received event [cache=demo, evt=CACHE_OBJECT_READ,
> key=com.google.protobuf.ByteString$LiteralByteString [idHash=1894334736,
> hash=-943417763, bytes=[86, 83], hash=0]
>
> GET fails: *** Received event [cache=demo, evt=CACHE_OBJECT_READ,
> key=com.google.protobuf.ByteString$LiteralByteString [idHash=1467314555,
> hash=-941523632, bytes=[86, 83], hash=4671]
>
> Hash of 4671 is a valid Java hash. Why in first 2 cases hash is 0?
> I believe the reason for discrepancies is different values of hash
> -943417763 and -941523632. Can you point how it's calculated?
>
> Thank you
> Ariel
>
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>



-- 
Best regards,
Andrey V. Mashenkov

Mime
View raw message