Nice! This has been requested many times for years. Great to finally have it so we can encourage good Java practices.
Kenn On Tue, Jan 8, 2019 at 1:35 PM Pablo Estrada <[email protected]> wrote: > Very cool. Thanks Jeff & Reuven : ) > > On Tue, Jan 8, 2019 at 12:00 PM Reuven Lax <[email protected]> wrote: > >> Thanks to help from Jeff Klukas, I just merged PR/7334 which adds schema >> support to AutoValue objects. >> >> in particular, since Beam knows how to encode any type with a schema, >> this means that AutoValue objects can now be used inside of PCollections, >> which has been a long-requested feature. >> >> The simplest way to use this is to use the DefaultSchema annotation. For >> example: >> >> @DefaultSchema(AutoValueSchema.class) >> @AutoValue >> abstract class MyAutoValue { >> public abstract String getName(); >> public abstract MyOtherAutoValue getOtherValue(); >> ... >> } >> >> This will automatically register this AutoValue class in the >> SchemaRegistry. >> >> If you can't add the attribute (possibly because you don't own the source >> code containing the AutoValue class), you can manually register it as >> follows: >> >> pipeline.getSchemaRegistry().registerSchemaProvider( >> MyAutoValue.class, new AutoValueSchema()); >> >> Let me know if you have questions or issues with this feature! >> >> Reuven >> >
