You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by "Davor Bonaci (JIRA)" <ji...@apache.org> on 2016/05/03 09:02:12 UTC

[jira] [Commented] (BEAM-233) Make Registering Avro Specific Records Easier

    [ https://issues.apache.org/jira/browse/BEAM-233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15268234#comment-15268234 ] 

Davor Bonaci commented on BEAM-233:
-----------------------------------

[~kenn], can you comment?

> Make Registering Avro Specific Records Easier
> ---------------------------------------------
>
>                 Key: BEAM-233
>                 URL: https://issues.apache.org/jira/browse/BEAM-233
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-core
>            Reporter: Jesse Anderson
>            Assignee: Kenneth Knowles
>
> There should be a helper method to make it easier to register Avro specific record classes. This will be the most common type that needs to be registered. The code would look something like:
> {code:java}
> public class AvroHelper {
>     public static void registerAvro(Pipeline p, Class<? extends SpecificRecordBase> clazz) {
>         p.getCoderRegistry().registerCoder(clazz, new CoderFactory() {
>             @Override
>             public Coder<?> create(List<? extends Coder<?>> componentCoders) {
>                 return AvroCoder.of(clazz);
>             }
>             @Override
>             public List<Object> getInstanceComponents(Object value) {
>                 return null;
>             }
>         });
>     }
> }
> {code}
> With usage:
> {code:java}
>         Pipeline p = Pipeline.create(options);
>         
>         AvroHelper.registerAvro(p, LogEntry.class);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)