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

Switch to Threaded View
Avro >> mail # user >> How to use java-class with JSON schema?

Copy link to this message
Re: How to use java-class with JSON schema?
The java-class attribute is supported by the reflect implementation,
not by the code-generating specific implementation.  So you could
define Foo in Java with something like:

public class Foo {
  private long batchId;
  @Stringable private Timestamp timestamp;
  public Foo() {}
  public Foo(long batchId, Timestamp timestamp) { ... }

then use ReflectData to read/write instances.  Note that
java.sql.Timestamp doesn't have a string constructor.  Are you using a
different timestamp class?  If you're defining your own then you could
instead add the @Stringable annotation to your Timestamp class rather
than to each field where it is used.

Reflect-defined schemas can refer to specific-defined classes, but not
vice-versa, since the compiler doesn't use reflection to discover
schemas, but rather always generates from the schema alone.


On Wed, Jul 2, 2014 at 8:05 AM, Ian Hummel <[EMAIL PROTECTED]> wrote: