public class AvroMode extends Object implements ReaderWriterFactory
Modifier and Type | Class and Description |
---|---|
static class |
AvroMode.ModeType
Internal enum which represents the various Avro data types.
|
Modifier and Type | Field and Description |
---|---|
static String |
AVRO_MODE_PROPERTY |
static String |
AVRO_SHUFFLE_MODE_PROPERTY |
static AvroMode |
GENERIC
Default mode to use for reading and writing
Generic types. |
static AvroMode |
REFLECT
Default mode to use for reading and writing
Reflect types. |
static AvroMode |
SPECIFIC
Default mode to use for reading and writing
Specific types. |
Modifier and Type | Method and Description |
---|---|
void |
configure(org.apache.hadoop.conf.Configuration conf)
Populates the
conf with mode specific settings. |
void |
configure(FormatBundle bundle)
Populates the
bundle with mode specific settings for the specific FormatBundle . |
void |
configureFactory(org.apache.hadoop.conf.Configuration conf)
Deprecated.
|
void |
configureShuffle(org.apache.hadoop.conf.Configuration conf)
Populates the
conf with mode specific settings for use during the shuffle phase. |
boolean |
equals(Object o) |
static AvroMode |
fromConfiguration(org.apache.hadoop.conf.Configuration conf)
Creates an AvroMode based on the
AVRO_MODE_PROPERTY property in the conf . |
static AvroMode |
fromShuffleConfiguration(org.apache.hadoop.conf.Configuration conf)
Creates an AvroMode based on the
AVRO_SHUFFLE_MODE_PROPERTY property in the conf . |
static AvroMode |
fromType(AvroType<?> type)
Creates an
AvroMode based upon the specified type . |
org.apache.avro.generic.GenericData |
getData()
Returns a
GenericData instance based on the mode type. |
ReaderWriterFactory |
getFactory()
Returns the factory that will be used for the mode.
|
Map<String,String> |
getModeProperties()
Returns the entries that a
Configuration instance needs to enable
this AvroMode as a serializable map of key-value pairs. |
<T> org.apache.avro.io.DatumReader<T> |
getReader(org.apache.avro.Schema schema)
Creates a
DatumReader based on the schema . |
static ClassLoader |
getSpecificClassLoader()
Get the configured
ClassLoader to be used for loading Avro org.apache.specific.SpecificRecord
and reflection implementation classes. |
<T> org.apache.avro.io.DatumWriter<T> |
getWriter(org.apache.avro.Schema schema)
Creates a
DatumWriter based on the schema . |
int |
hashCode() |
AvroMode |
override(ReaderWriterFactory factory)
Deprecated.
use
withFactory(ReaderWriterFactory) instead. |
static void |
setSpecificClassLoader(ClassLoader loader)
Set the
ClassLoader that will be used for loading Avro org.apache.avro.specific.SpecificRecord
and reflection implementation classes. |
AvroMode |
withFactory(ReaderWriterFactory factory)
Creates a new
AvroMode instance which will utilize the factory instance
for creating Avro readers and writers. |
AvroMode |
withFactoryFromConfiguration(org.apache.hadoop.conf.Configuration conf) |
public static final AvroMode REFLECT
Reflect
types.public static final AvroMode SPECIFIC
Specific
types.public static final AvroMode GENERIC
Generic
types.public static final String AVRO_MODE_PROPERTY
public static final String AVRO_SHUFFLE_MODE_PROPERTY
public static AvroMode fromConfiguration(org.apache.hadoop.conf.Configuration conf)
AVRO_MODE_PROPERTY
property in the conf
.conf
- The configuration holding the properties for mode to be created.AVRO_MODE_PROPERTY
property in the conf
.public static AvroMode fromShuffleConfiguration(org.apache.hadoop.conf.Configuration conf)
AVRO_SHUFFLE_MODE_PROPERTY
property in the conf
.conf
- The configuration holding the properties for mode to be created.AVRO_SHUFFLE_MODE_PROPERTY
property in the conf
.public static AvroMode fromType(AvroType<?> type)
AvroMode
based upon the specified type
.type
- the Avro type which indicates a specific mode.AvroMode
based upon the specified type
.public static void setSpecificClassLoader(ClassLoader loader)
ClassLoader
that will be used for loading Avro org.apache.avro.specific.SpecificRecord
and reflection implementation classes. It is typically not necessary to call this method -- it should only be used
if a specific class loader is needed in order to load the specific datum classes.loader
- the ClassLoader
to be used for loading specific datum classespublic static ClassLoader getSpecificClassLoader()
ClassLoader
to be used for loading Avro org.apache.specific.SpecificRecord
and reflection implementation classes. The return value may be null.ClassLoader
for loading specific or reflection datum classes, may be nullpublic org.apache.avro.generic.GenericData getData()
GenericData
instance based on the mode type.getData
in interface ReaderWriterFactory
GenericData
instance based on the mode type.public <T> org.apache.avro.io.DatumReader<T> getReader(org.apache.avro.Schema schema)
DatumReader
based on the schema
.getReader
in interface ReaderWriterFactory
T
- the record type created by the reader.schema
- the schema to be readDatumReader
based on the schema
.public <T> org.apache.avro.io.DatumWriter<T> getWriter(org.apache.avro.Schema schema)
DatumWriter
based on the schema
.getWriter
in interface ReaderWriterFactory
T
- the record type created by the writer.schema
- the schema to be readDatumWriter
based on the schema
.@Deprecated public AvroMode override(ReaderWriterFactory factory)
withFactory(ReaderWriterFactory)
instead.AvroMode
instance which will utilize the factory
instance
for creating Avro readers and writers.factory
- factory implementation for the mode to useAvroMode
instance which will utilize the factory
instance
for creating Avro readers and writers.public AvroMode withFactory(ReaderWriterFactory factory)
AvroMode
instance which will utilize the factory
instance
for creating Avro readers and writers. If null
the default factory for the mode
will be used.factory
- factory implementation for the mode to useAvroMode
instance which will utilize the factory
instance
for creating Avro readers and writers.public void configureShuffle(org.apache.hadoop.conf.Configuration conf)
conf
with mode specific settings for use during the shuffle phase.conf
- the configuration to populate.public void configure(FormatBundle bundle)
bundle
with mode specific settings for the specific FormatBundle
.bundle
- the bundle to populate.public void configure(org.apache.hadoop.conf.Configuration conf)
conf
with mode specific settings.conf
- the configuration to populate.public Map<String,String> getModeProperties()
Configuration
instance needs to enable
this AvroMode as a serializable map of key-value pairs.@Deprecated public void configureFactory(org.apache.hadoop.conf.Configuration conf)
configure(org.apache.hadoop.conf.Configuration)
conf
with mode specific settings.conf
- the configuration to populate.public ReaderWriterFactory getFactory()
public AvroMode withFactoryFromConfiguration(org.apache.hadoop.conf.Configuration conf)
Copyright © 2016 The Apache Software Foundation. All rights reserved.