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>>

      public class AvroSerialization<T>
      extends Configured
      implements Serialization<AvroWrapper<T>>

  The `Serialization` used by jobs configured with `AvroJob`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AvroSerialization()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `accept(Class<?> c)`
    `static void` | `addToConfiguration(Configuration conf)` Adds the AvroSerialization scheme to the configuration, so SerializationFactory instances constructed from the given configuration will be aware of it.
    `static GenericData` | `createDataModel(Configuration conf)` Gets an instance of data model implementation, defaulting to `ReflectData` if not explicitly specified.
    `static Class<? extends GenericData>` | `getDataModelClass(Configuration conf)` Gets the data model class for de/serialization.
    `Deserializer<AvroWrapper<T>>` | `getDeserializer(Class<AvroWrapper<T>> c)` Gets an object capable of deserializing the output from a Mapper.
    `static Schema` | `getKeyReaderSchema(Configuration conf)` Gets the reader schema of the AvroKey datum that is being serialized/deserialized.
    `static Schema` | `getKeyWriterSchema(Configuration conf)` Gets the writer schema of the AvroKey datum that is being serialized/deserialized.
    `Serializer<AvroWrapper<T>>` | `getSerializer(Class<AvroWrapper<T>> c)` Gets an object capable of serializing output from a Mapper.
    `static Schema` | `getValueReaderSchema(Configuration conf)` Gets the reader schema of the AvroValue datum that is being serialized/deserialized.
    `static Schema` | `getValueWriterSchema(Configuration conf)` Gets the writer schema of the AvroValue datum that is being serialized/deserialized.
    `static void` | `setDataModelClass(Configuration conf, Class<? extends GenericData> modelClass)` Sets the data model class for de/serialization.
    `static void` | `setKeyReaderSchema(Configuration conf, Schema schema)` Sets the reader schema of the AvroKey datum that is being serialized/deserialized.
    `static void` | `setKeyWriterSchema(Configuration conf, Schema schema)` Sets the writer schema of the AvroKey datum that is being serialized/deserialized.
    `static void` | `setValueReaderSchema(Configuration conf, Schema schema)` Sets the reader schema of the AvroValue datum that is being serialized/deserialized.
    `static void` | `setValueWriterSchema(Configuration conf, 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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AvroSerialization

          public AvroSerialization()

  - ### Method Detail

    - #### accept

          public boolean accept(Class<?> c)

      Specified by:
        `accept` in interface `Serialization<AvroWrapper<T>>`

    - #### getDeserializer

          public Deserializer<AvroWrapper<T>> getDeserializer(Class<AvroWrapper<T>> c)

      Gets an object capable of deserializing the output from a Mapper.
      Specified by:
        `getDeserializer` in interface `Serialization<AvroWrapper<T>>`
      Parameters:
        `c` - The class to get a deserializer for.
      Returns:
        A deserializer for objects of class `c`.

    - #### getSerializer

          public Serializer<AvroWrapper<T>> getSerializer(Class<AvroWrapper<T>> c)

      Gets an object capable of serializing output from a Mapper.
      Specified by:
        `getSerializer` in interface `Serialization<AvroWrapper<T>>`
      Parameters:
        `c` - The class to get a serializer for.
      Returns:
        A serializer for objects of class `c`.

    - #### addToConfiguration

          public static void addToConfiguration(Configuration conf)

      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

          public static void setKeyWriterSchema(Configuration conf,
                                                Schema schema)

      Sets the writer schema of the AvroKey datum that is being serialized/deserialized.
      Parameters:
        `conf` - The configuration.
        `schema` - The Avro key schema.

    - #### setKeyReaderSchema

          public static void setKeyReaderSchema(Configuration conf,
                                                Schema schema)

      Sets the reader schema of the AvroKey datum that is being serialized/deserialized.
      Parameters:
        `conf` - The configuration.
        `schema` - The Avro key schema.

    - #### setValueWriterSchema

          public static void setValueWriterSchema(Configuration conf,
                                                  Schema schema)

      Sets the writer schema of the AvroValue datum that is being serialized/deserialized.
      Parameters:
        `conf` - The configuration.
        `schema` - The Avro value schema.

    - #### setValueReaderSchema

          public static void setValueReaderSchema(Configuration conf,
                                                  Schema schema)

      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 GenericData> modelClass)

      Sets the data model class for de/serialization.
      Parameters:
        `conf` - The configuration.
        `modelClass` - The data model class.

    - #### getKeyWriterSchema

          public static Schema getKeyWriterSchema(Configuration conf)

      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

          public static Schema getKeyReaderSchema(Configuration conf)

      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

          public static Schema getValueWriterSchema(Configuration conf)

      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

          public static Schema getValueReaderSchema(Configuration conf)

      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 GenericData> getDataModelClass(Configuration conf)

      Gets the data model class for de/serialization.
      Parameters:
        `conf` - The configuration.

    - #### createDataModel

          public static GenericData createDataModel(Configuration conf)

      Gets an instance of data model implementation, defaulting to `ReflectData` if not explicitly specified.
      Parameters:
        `conf` - The job configuration.
      Returns:
        Instance of the job data model implementation.

Copyright © 2009–2024 The Apache Software Foundation. All rights reserved.