I encountered that before. Unfortunately this is a legitimate thing to
do, as documented in Object.hashCode()
I have a write-up of the problem and how we wound up solving it (not
elegant.. suggestions welcome) here:
http://squarecog.wordpress.com/2011/02/20/hadoop-requires-stable-hashcode-implementations/
D
> --
> You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
> To post to this group, send email to prot...@googlegroups.com.
> To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
>
>
the corner-stone of Hash* containers is:(A.equals(B)) => (A.hashCode() == B.hashCode()) for all A, B.
I personally switched my particular problem to use Strings as keys,
since that works for the use case here and is easier for corresponding
command-line tools, I just generally see a consistent hashcode as a
good idea if supportable.
That definitely seems acceptable. Any reason not to make the default
implementation return toByteString().hashCode() and get the best of
both worlds? It's a little more expensive probably, but
Object.hashCode() is already deceptively expensive to begin with.
I personally switched my particular problem to use Strings as keys,