GenericRecord to POJO

Viewed 2155

I am consuming from Kafka Avro record and creating a GenericRecord Stream. Now for some computation I want to convert GenericRecord to Pojo Object. I have already generated a class using Avro-maven-plugin from the schema.

But I am not able to convert the generic record to This generated class Object.

Please help me how to do this. I want to know how to implement ConvertoPojo function in the below code.

    public void flatMap(Tuple2<Long, GenericRecord> recordTuple2, Collector<Tuple4<Long, Long, Long, Long>> collector) throws Exception {
        GenericRecord record = recordTuple2.f1;
        String event_name = record.get("event_name").toString();

        if (event_name.equals("search_list_keyless")) {
            SearchListKeyelss object = ConvertoPojo(record)
        }

        }

0 Answers
Related