@Experimental(value=SCHEMAS) public class AvroUtils extends java.lang.Object
| Modifier and Type | Class and Description | 
|---|---|
| static class  | AvroUtils.AvroConvertType | 
| static class  | AvroUtils.AvroConvertValueForGetter | 
| static class  | AvroUtils.AvroConvertValueForSetter | 
| static class  | AvroUtils.FixedBytesFieldWrapper for fixed byte fields. | 
| Modifier and Type | Method and Description | 
|---|---|
| static @Nullable java.lang.Object | convertAvroFieldStrict(@Nullable java.lang.Object value,
                      Schema avroSchema,
                      Schema.FieldType fieldType)Strict conversion from AVRO to Beam, strict because it doesn't do widening or narrowing during
 conversion. | 
| static SimpleFunction<byte[],Row> | getAvroBytesToRowFunction(Schema beamSchema)Returns a function mapping encoded AVRO  GenericRecords to BeamRows. | 
| static <T> SchemaUserTypeCreator | getCreator(java.lang.Class<T> clazz,
          Schema schema)Get an object creator for an AVRO-generated SpecificRecord. | 
| static <T> java.util.List<FieldValueTypeInformation> | getFieldTypes(java.lang.Class<T> clazz,
             Schema schema)Get field types for an AVRO-generated SpecificRecord or a POJO. | 
| static <T> SerializableFunction<Row,T> | getFromRowFunction(java.lang.Class<T> clazz) | 
| static SerializableFunction<GenericRecord,Row> | getGenericRecordToRowFunction(@Nullable Schema schema)Returns a function mapping AVRO  GenericRecords to BeamRows for use inPCollection.setSchema(org.apache.beam.sdk.schemas.Schema, org.apache.beam.sdk.values.TypeDescriptor<T>, org.apache.beam.sdk.transforms.SerializableFunction<T, org.apache.beam.sdk.values.Row>, org.apache.beam.sdk.transforms.SerializableFunction<org.apache.beam.sdk.values.Row, T>). | 
| static <T> java.util.List<FieldValueGetter> | getGetters(java.lang.Class<T> clazz,
          Schema schema)Get generated getters for an AVRO-generated SpecificRecord or a POJO. | 
| static SimpleFunction<Row,byte[]> | getRowToAvroBytesFunction(Schema beamSchema)Returns a function mapping Beam  Rows to encoded AVROGenericRecords. | 
| static SerializableFunction<Row,GenericRecord> | getRowToGenericRecordFunction(Schema avroSchema)Returns a function mapping Beam  Rows to AVROGenericRecords for use inPCollection.setSchema(org.apache.beam.sdk.schemas.Schema, org.apache.beam.sdk.values.TypeDescriptor<T>, org.apache.beam.sdk.transforms.SerializableFunction<T, org.apache.beam.sdk.values.Row>, org.apache.beam.sdk.transforms.SerializableFunction<org.apache.beam.sdk.values.Row, T>). | 
| static <T> @Nullable Schema | getSchema(java.lang.Class<T> clazz,
         Schema schema) | 
| static <T> SerializableFunction<T,Row> | getToRowFunction(java.lang.Class<T> clazz,
                Schema schema) | 
| static <T> SchemaCoder<T> | schemaCoder(AvroCoder<T> avroCoder)Returns an  SchemaCoderinstance based on the provided AvroCoder for the element type. | 
| static <T> SchemaCoder<T> | schemaCoder(java.lang.Class<T> clazz)Returns an  SchemaCoderinstance for the provided element class. | 
| static <T> SchemaCoder<T> | schemaCoder(java.lang.Class<T> clazz,
           Schema schema)Returns an  SchemaCoderinstance for the provided element type using the provided Avro
 schema. | 
| static SchemaCoder<GenericRecord> | schemaCoder(Schema schema)Returns an  SchemaCoderinstance for the Avro schema. | 
| static <T> SchemaCoder<T> | schemaCoder(TypeDescriptor<T> type)Returns an  SchemaCoderinstance for the provided element type. | 
| static Schema.Field | toAvroField(Schema.Field field,
           java.lang.String namespace)Get Avro Field from Beam Field. | 
| static Schema | toAvroSchema(Schema beamSchema) | 
| static Schema | toAvroSchema(Schema beamSchema,
            @Nullable java.lang.String name,
            @Nullable java.lang.String namespace)Converts a Beam Schema into an AVRO schema. | 
| static Schema.Field | toBeamField(Schema.Field field)Get Beam Field from avro Field. | 
| static Row | toBeamRowStrict(GenericRecord record,
               @Nullable Schema schema)Strict conversion from AVRO to Beam, strict because it doesn't do widening or narrowing during
 conversion. | 
| static Schema | toBeamSchema(Schema schema)Converts AVRO schema to Beam row schema. | 
| static GenericRecord | toGenericRecord(Row row)Convert from a Beam Row to an AVRO GenericRecord. | 
| static GenericRecord | toGenericRecord(Row row,
               Schema avroSchema)Convert from a Beam Row to an AVRO GenericRecord. | 
public static Schema.Field toBeamField(Schema.Field field)
public static Schema.Field toAvroField(Schema.Field field, java.lang.String namespace)
public static Schema toBeamSchema(Schema schema)
schema - schema of type RECORDpublic static Schema toAvroSchema(Schema beamSchema, @Nullable java.lang.String name, @Nullable java.lang.String namespace)
public static Row toBeamRowStrict(GenericRecord record, @Nullable Schema schema)
public static GenericRecord toGenericRecord(Row row)
public static GenericRecord toGenericRecord(Row row, Schema avroSchema)
public static <T> SerializableFunction<T,Row> getToRowFunction(java.lang.Class<T> clazz, Schema schema)
public static <T> SerializableFunction<Row,T> getFromRowFunction(java.lang.Class<T> clazz)
public static SimpleFunction<byte[],Row> getAvroBytesToRowFunction(Schema beamSchema)
GenericRecords to Beam Rows.public static SimpleFunction<Row,byte[]> getRowToAvroBytesFunction(Schema beamSchema)
Rows to encoded AVRO GenericRecords.public static SerializableFunction<GenericRecord,Row> getGenericRecordToRowFunction(@Nullable Schema schema)
GenericRecords to Beam Rows for use in PCollection.setSchema(org.apache.beam.sdk.schemas.Schema, org.apache.beam.sdk.values.TypeDescriptor<T>, org.apache.beam.sdk.transforms.SerializableFunction<T, org.apache.beam.sdk.values.Row>, org.apache.beam.sdk.transforms.SerializableFunction<org.apache.beam.sdk.values.Row, T>).public static SerializableFunction<Row,GenericRecord> getRowToGenericRecordFunction(Schema avroSchema)
Rows to AVRO GenericRecords for use in PCollection.setSchema(org.apache.beam.sdk.schemas.Schema, org.apache.beam.sdk.values.TypeDescriptor<T>, org.apache.beam.sdk.transforms.SerializableFunction<T, org.apache.beam.sdk.values.Row>, org.apache.beam.sdk.transforms.SerializableFunction<org.apache.beam.sdk.values.Row, T>).public static <T> SchemaCoder<T> schemaCoder(TypeDescriptor<T> type)
SchemaCoder instance for the provided element type.T - the element typepublic static <T> SchemaCoder<T> schemaCoder(java.lang.Class<T> clazz)
SchemaCoder instance for the provided element class.T - the element typepublic static SchemaCoder<GenericRecord> schemaCoder(Schema schema)
SchemaCoder instance for the Avro schema. The implicit type is
 GenericRecord.public static <T> SchemaCoder<T> schemaCoder(java.lang.Class<T> clazz, Schema schema)
SchemaCoder instance for the provided element type using the provided Avro
 schema.
 If the type argument is GenericRecord, the schema may be arbitrary. Otherwise, the schema must correspond to the type provided.
T - the element typepublic static <T> SchemaCoder<T> schemaCoder(AvroCoder<T> avroCoder)
SchemaCoder instance based on the provided AvroCoder for the element type.T - the element typepublic static <T> java.util.List<FieldValueTypeInformation> getFieldTypes(java.lang.Class<T> clazz, Schema schema)
public static <T> java.util.List<FieldValueGetter> getGetters(java.lang.Class<T> clazz, Schema schema)
public static <T> SchemaUserTypeCreator getCreator(java.lang.Class<T> clazz, Schema schema)
public static @Nullable java.lang.Object convertAvroFieldStrict(@Nullable java.lang.Object value,
                                                                @Nonnull
                                                                Schema avroSchema,
                                                                @Nonnull
                                                                Schema.FieldType fieldType)
value - GenericRecord or any nested valueavroSchema - schema for valuefieldType - target beam field typeRow