Hi All,

I am creating java objects using Avro Maven plugin, and I have a requirement
to generate hashCode and equals based on specific fields. Is that possible?

For example, I have a schema, Question
{
  "type" : "record",
  "name" : "Question",
  "namespace" : "com.tugo.questions.schema",
  "fields" : [ {
    "name" : "id",
    "type" : "string",
  }, {
    "name" : "text",
    "type" : "string"
  }, {
    "name" : "type",
    "type" : "string"
  },
  .... // few more fields
}

I want to generate hashCode and equals based on just the id string in the
Question
schema. By default, the generated class inherit hashCode and equals from
SpecificRecordBase
which calls GenericData.hashCode, which iterates over all fields and
compute the hashCode.
This takes a considerable amount of time with the large schema. Any advice
on how to achieve
this?

Thanks & Regards,
-Tushar.

Reply via email to