Class SchemaRegistry


  • @Experimental(SCHEMAS)
    public class SchemaRegistry
    extends java.lang.Object
    A 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.

    • Method Detail

      • registerSchemaProvider

        public void registerSchemaProvider​(SchemaProvider schemaProvider)
        Register a 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.

      • registerSchemaProvider

        public <T> void registerSchemaProvider​(java.lang.Class<T> clazz,
                                               SchemaProvider schemaProvider)
        Register a SchemaProvider to be used for a specific type. *
      • registerPOJO

        public <T> void registerPOJO​(java.lang.Class<T> clazz)
        Register a POJO type for automatic schema inference.

        Currently schema field names will match field names in the POJO, and all fields must be mutable (i.e. no final fields).

      • registerPOJO

        public <T> void registerPOJO​(TypeDescriptor<T> typeDescriptor)
        Register a POJO type for automatic schema inference.

        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.

      • registerJavaBean

        public <T> void registerJavaBean​(java.lang.Class<T> clazz)
        Register a JavaBean type for automatic schema inference.

        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.

      • registerJavaBean

        public <T> void registerJavaBean​(TypeDescriptor<T> typeDescriptor)
        Register a JavaBean type for automatic schema inference.

        Currently schema field names will match getter names in the bean, and all getters must have matching setters.