Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # user >> Schema generation from POJO


Copy link to this message
-
Re: Schema generation from POJO
You can use Avro's reflect facilities:

http://avro.apache.org/docs/current/api/java/org/apache/avro/reflect/package-summary.html

In particular, you can use:
  Schema s = ReflectData.get().getSchema(MyPojo.class);
or
  DatumWriter<MyPojo> writer = new ReflectDatumWriter<MyPojo>(MyPojo.class);
or
  DatumReader<MyPojo> reader = new ReflectDatumReader<MyPojo>(MyPojo.class);
etc.

Doug

On Wed, Aug 21, 2013 at 12:21 PM, Sathwik B P <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> Is  there a way to generate the schema from existing pojos.
>
> regards,
> sathwik