On Mon, May 26, 2014 at 3:43 AM, Han JU <ju.han.fe...@gmail.com> wrote: > My question for the moment: is it possible to custom the hashCode function > of a avro record? Say a record a a field `uid` and I'd like to return this > value as the hashCode.
If you're using Avro's reflect model then you can simply override your hashCode method. If you're using generic or specific then you can specify a schema where all other fields are ignored, e.g.: {"type":"record", "name":"org.random.Foo", "fields":[ {"name":"uid", "type":"string"}, {"name":"x", "type":"long", "order":"ignore"}, {"name":"y", "type":"float", "order":"ignore"}, {"name":"z", "type":"double", "order":"ignore"} ]} Avro's hashes and comparisons only consider fields that are not ignored. Doug