Package org.apache.avro.hadoop.io
Class AvroSerialization<T>
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.avro.hadoop.io.AvroSerialization<T>
- Type Parameters:
T- The Java type of the Avro data to serialize.
- All Implemented Interfaces:
Configurable,Serialization<AvroWrapper<T>>
The
Serialization used by jobs
configured with AvroJob.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic voidAdds the AvroSerialization scheme to the configuration, so SerializationFactory instances constructed from the given configuration will be aware of it.static org.apache.avro.generic.GenericDatacreateDataModel(Configuration conf) Gets an instance of data model implementation, defaulting toReflectDataif not explicitly specified.static Class<? extends org.apache.avro.generic.GenericData> Gets the data model class for de/serialization.getDeserializer(Class<AvroWrapper<T>> c) Gets an object capable of deserializing the output from a Mapper.static org.apache.avro.SchemaGets the reader schema of the AvroKey datum that is being serialized/deserialized.static org.apache.avro.SchemaGets the writer schema of the AvroKey datum that is being serialized/deserialized.getSerializer(Class<AvroWrapper<T>> c) Gets an object capable of serializing output from a Mapper.static org.apache.avro.SchemaGets the reader schema of the AvroValue datum that is being serialized/deserialized.static org.apache.avro.SchemaGets the writer schema of the AvroValue datum that is being serialized/deserialized.static voidsetDataModelClass(Configuration conf, Class<? extends org.apache.avro.generic.GenericData> modelClass) Sets the data model class for de/serialization.static voidsetKeyReaderSchema(Configuration conf, org.apache.avro.Schema schema) Sets the reader schema of the AvroKey datum that is being serialized/deserialized.static voidsetKeyWriterSchema(Configuration conf, org.apache.avro.Schema schema) Sets the writer schema of the AvroKey datum that is being serialized/deserialized.static voidsetValueReaderSchema(Configuration conf, org.apache.avro.Schema schema) Sets the reader schema of the AvroValue datum that is being serialized/deserialized.static voidsetValueWriterSchema(Configuration conf, org.apache.avro.Schema schema) Sets the writer schema of the AvroValue datum that is being serialized/deserialized.Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
-
Constructor Details
-
AvroSerialization
public AvroSerialization()
-
-
Method Details
-
accept
- Specified by:
acceptin interfaceSerialization<T>
-
getDeserializer
Gets an object capable of deserializing the output from a Mapper.- Specified by:
getDeserializerin interfaceSerialization<T>- Parameters:
c- The class to get a deserializer for.- Returns:
- A deserializer for objects of class
c.
-
getSerializer
Gets an object capable of serializing output from a Mapper.- Specified by:
getSerializerin interfaceSerialization<T>- Parameters:
c- The class to get a serializer for.- Returns:
- A serializer for objects of class
c.
-
addToConfiguration
Adds the AvroSerialization scheme to the configuration, so SerializationFactory instances constructed from the given configuration will be aware of it.- Parameters:
conf- The configuration to add AvroSerialization to.
-
setKeyWriterSchema
Sets the writer schema of the AvroKey datum that is being serialized/deserialized.- Parameters:
conf- The configuration.schema- The Avro key schema.
-
setKeyReaderSchema
Sets the reader schema of the AvroKey datum that is being serialized/deserialized.- Parameters:
conf- The configuration.schema- The Avro key schema.
-
setValueWriterSchema
Sets the writer schema of the AvroValue datum that is being serialized/deserialized.- Parameters:
conf- The configuration.schema- The Avro value schema.
-
setValueReaderSchema
Sets the reader schema of the AvroValue datum that is being serialized/deserialized.- Parameters:
conf- The configuration.schema- The Avro value schema.
-
setDataModelClass
public static void setDataModelClass(Configuration conf, Class<? extends org.apache.avro.generic.GenericData> modelClass) Sets the data model class for de/serialization.- Parameters:
conf- The configuration.modelClass- The data model class.
-
getKeyWriterSchema
Gets the writer schema of the AvroKey datum that is being serialized/deserialized.- Parameters:
conf- The configuration.- Returns:
- The Avro key writer schema, or null if none was set.
-
getKeyReaderSchema
Gets the reader schema of the AvroKey datum that is being serialized/deserialized.- Parameters:
conf- The configuration.- Returns:
- The Avro key reader schema, or null if none was set.
-
getValueWriterSchema
Gets the writer schema of the AvroValue datum that is being serialized/deserialized.- Parameters:
conf- The configuration.- Returns:
- The Avro value writer schema, or null if none was set.
-
getValueReaderSchema
Gets the reader schema of the AvroValue datum that is being serialized/deserialized.- Parameters:
conf- The configuration.- Returns:
- The Avro value reader schema, or null if none was set.
-
getDataModelClass
public static Class<? extends org.apache.avro.generic.GenericData> getDataModelClass(Configuration conf) Gets the data model class for de/serialization.- Parameters:
conf- The configuration.
-
createDataModel
Gets an instance of data model implementation, defaulting toReflectDataif not explicitly specified.- Parameters:
conf- The job configuration.- Returns:
- Instance of the job data model implementation.
-