Aliases may help here.  If you have a schema in one namespace and wish
to read data written with a schema in another namespace, potentially
with different field names even, then you can add aliases to your
schema naming the other schema (and its fields, if needed).

For example, if you want to read data written with:

{"type":"record", "name":"org.foo.Frob" ...}

into a class org.bar.Fritz, then you'd generate code from a schema with:

{"type":"record", "name":"org.bar.Fritz", "alias":"org.foo.Frob" ...}

Does that make sense?  Does it apply to your situation?

Doug


On Fri, Jun 27, 2014 at 9:22 AM, Hans Uhlig <huh...@uhlisys.com> wrote:
> Is it possible to coerce the SpecificDatumReader to read a file from a
> different Schema? We use Avro code generation for speed and type enforcement
> in our environment normally but one of the data sources out of our control.
> This other source doesn't use a namespace which means our use of codegen
> isnt possible in java. Is there a way for us to read the data into our
> codegenerated classes (only difference is the namespace) from the
> namespaceless files we receive? Without doing double class allocation?

Reply via email to