2
votes

As per apache beam documentation, I can find data type specific coders and also custom coders. It provides feasibility to create custom coders by registering with code registry. But I would like to know if there is any coder available for POJO/bean. For example,what is the coder for PCollection

1

1 Answers

3
votes

If your POJO is defined within your project, then take a look at DefaultSchema. The example there does exactly what you want, registering a schema (which implicitly registers a coder) by inspecting JavaBean-compliant methods:

@DefaultSchema(JavaBeanSchema.class)
class MyClass {
  public String getFoo();
  void setFoo(String foo);
        ....
}

Note that coders are for elements of a collection, so there is no coder for PCollection. Rather, a PCollection can have a coder set, determining how individual elements are serialized and deserialized.