public class SchemaRegistry
extends java.lang.Object
SchemaRegistry allows registering Schemas for a given Java Class or a
 TypeDescriptor.
 Types registered in a pipeline's schema registry will automatically be discovered by any
 PCollection that uses SchemaCoder. This allows users
 to write pipelines in terms of their own Java types, yet still register schemas for these types.
 
TODO: Provide support for schemas registered via a ServiceLoader interface. This will allow optional modules to register schemas as well.
| Modifier and Type | Method and Description | 
|---|---|
| static SchemaRegistry | createDefault() | 
| <T> SerializableFunction<Row,T> | getFromRowFunction(java.lang.Class<T> clazz)Retrieve the function that converts a  Rowobject to the specified type. | 
| <T> SerializableFunction<Row,T> | getFromRowFunction(TypeDescriptor<T> typeDescriptor)Retrieve the function that converts a  Rowobject to the specified type. | 
| <T> Schema | getSchema(java.lang.Class<T> clazz)Retrieve a  Schemafor a givenClasstype. | 
| <T> Schema | getSchema(TypeDescriptor<T> typeDescriptor)Retrieve a  Schemafor a givenTypeDescriptortype. | 
| <T> SchemaCoder<T> | getSchemaCoder(java.lang.Class<T> clazz)Retrieve a  SchemaCoderfor a givenClasstype. | 
| <T> SchemaCoder<T> | getSchemaCoder(TypeDescriptor<T> typeDescriptor)Retrieve a  SchemaCoderfor a givenTypeDescriptortype. | 
| <T> SchemaProvider | getSchemaProvider(java.lang.Class<T> clazz)Retrieve a registered  SchemaProviderfor a givenClass. | 
| <T> SchemaProvider | getSchemaProvider(TypeDescriptor<T> typeDescriptor)Retrieve a registered  SchemaProviderfor a givenTypeDescriptor. | 
| <T> SerializableFunction<T,Row> | getToRowFunction(java.lang.Class<T> clazz)Retrieve the function that converts an object of the specified type to a  Rowobject. | 
| <T> SerializableFunction<T,Row> | getToRowFunction(TypeDescriptor<T> typeDescriptor)Retrieve the function that converts an object of the specified type to a  Rowobject. | 
| <T> void | registerJavaBean(java.lang.Class<T> clazz)Register a JavaBean type for automatic schema inference. | 
| <T> void | registerJavaBean(TypeDescriptor<T> typeDescriptor)Register a JavaBean type for automatic schema inference. | 
| <T> void | registerPOJO(java.lang.Class<T> clazz)Register a POJO type for automatic schema inference. | 
| <T> void | registerPOJO(TypeDescriptor<T> typeDescriptor)Register a POJO type for automatic schema inference. | 
| <T> void | registerSchemaForClass(java.lang.Class<T> clazz,
                      Schema schema,
                      SerializableFunction<T,Row> toRow,
                      SerializableFunction<Row,T> fromRow)Register a schema for a specific  Classtype. | 
| <T> void | registerSchemaForType(TypeDescriptor<T> type,
                     Schema schema,
                     SerializableFunction<T,Row> toRow,
                     SerializableFunction<Row,T> fromRow)Register a schema for a specific  TypeDescriptortype. | 
| <T> void | registerSchemaProvider(java.lang.Class<T> clazz,
                      SchemaProvider schemaProvider)Register a  SchemaProviderto be used for a specific type. | 
| void | registerSchemaProvider(SchemaProvider schemaProvider)Register a  SchemaProvider. | 
| <T> void | registerSchemaProvider(TypeDescriptor<T> typeDescriptor,
                      SchemaProvider schemaProvider)Register a  SchemaProviderto be used for a specific type. | 
public static SchemaRegistry createDefault()
public <T> void registerSchemaForClass(java.lang.Class<T> clazz,
                                       Schema schema,
                                       SerializableFunction<T,Row> toRow,
                                       SerializableFunction<Row,T> fromRow)
Class type.public <T> void registerSchemaForType(TypeDescriptor<T> type, Schema schema, SerializableFunction<T,Row> toRow, SerializableFunction<Row,T> fromRow)
TypeDescriptor type.public void registerSchemaProvider(SchemaProvider schemaProvider)
SchemaProvider.
 A SchemaProvider allows for deferred lookups of per-type schemas. This can be used
 when schemas are registered in an external service. The SchemaProvider will lookup the type in
 the external service and return the correct Schema.
public <T> void registerSchemaProvider(java.lang.Class<T> clazz,
                                       SchemaProvider schemaProvider)
SchemaProvider to be used for a specific type. *public <T> void registerSchemaProvider(TypeDescriptor<T> typeDescriptor, SchemaProvider schemaProvider)
SchemaProvider to be used for a specific type. *public <T> void registerPOJO(java.lang.Class<T> clazz)
Currently schema field names will match field names in the POJO, and all fields must be mutable (i.e. no final fields).
public <T> void registerPOJO(TypeDescriptor<T> typeDescriptor)
Currently schema field names will match field names in the POJO, and all fields must be mutable (i.e. no final fields). The Java object is expected to have implemented a correct .equals() and .hashCode methods The equals method must be completely determined by the schema fields. i.e. if the object has hidden fields that are not reflected in the schema but are compared in equals, then results will be incorrect.
public <T> void registerJavaBean(java.lang.Class<T> clazz)
Currently schema field names will match getter names in the bean, and all getters must have matching setters. The Java object is expected to have implemented a correct .equals() and .hashCode methods The equals method must be completely determined by the schema fields. i.e. if the object has hidden fields that are not reflected in the schema but are compared in equals, then results will be incorrect.
public <T> void registerJavaBean(TypeDescriptor<T> typeDescriptor)
Currently schema field names will match getter names in the bean, and all getters must have matching setters.
public <T> Schema getSchema(java.lang.Class<T> clazz) throws NoSuchSchemaException
NoSuchSchemaExceptionpublic <T> Schema getSchema(TypeDescriptor<T> typeDescriptor) throws NoSuchSchemaException
Schema for a given TypeDescriptor type. If no schema exists, throws
 NoSuchSchemaException.NoSuchSchemaExceptionpublic <T> SerializableFunction<T,Row> getToRowFunction(java.lang.Class<T> clazz) throws NoSuchSchemaException
Row object.NoSuchSchemaExceptionpublic <T> SerializableFunction<T,Row> getToRowFunction(TypeDescriptor<T> typeDescriptor) throws NoSuchSchemaException
Row object.NoSuchSchemaExceptionpublic <T> SerializableFunction<Row,T> getFromRowFunction(java.lang.Class<T> clazz) throws NoSuchSchemaException
Row object to the specified type.NoSuchSchemaExceptionpublic <T> SerializableFunction<Row,T> getFromRowFunction(TypeDescriptor<T> typeDescriptor) throws NoSuchSchemaException
Row object to the specified type.NoSuchSchemaExceptionpublic <T> SchemaCoder<T> getSchemaCoder(java.lang.Class<T> clazz) throws NoSuchSchemaException
NoSuchSchemaExceptionpublic <T> SchemaCoder<T> getSchemaCoder(TypeDescriptor<T> typeDescriptor) throws NoSuchSchemaException
SchemaCoder for a given TypeDescriptor type. If no schema exists,
 throws NoSuchSchemaException.NoSuchSchemaExceptionpublic <T> SchemaProvider getSchemaProvider(TypeDescriptor<T> typeDescriptor) throws NoSuchSchemaException
SchemaProvider for a given TypeDescriptor. If no schema
 exists, throws NoSuchSchemaException.NoSuchSchemaExceptionpublic <T> SchemaProvider getSchemaProvider(java.lang.Class<T> clazz) throws NoSuchSchemaException
SchemaProvider for a given Class. If no schema exists,
 throws NoSuchSchemaException.NoSuchSchemaException