Package org.apache.avro.reflect
Class ReflectDatumReader<T>
java.lang.Object
org.apache.avro.generic.GenericDatumReader<T>
org.apache.avro.specific.SpecificDatumReader<T>
org.apache.avro.reflect.ReflectDatumReader<T>
- All Implemented Interfaces:
DatumReader<T>
DatumReader
for existing classes via
Java reflection.-
Field Summary
Fields inherited from class org.apache.avro.specific.SpecificDatumReader
SERIALIZABLE_PACKAGES
-
Constructor Summary
ConstructorDescriptionReflectDatumReader
(Class<T> c) Construct for reading instances of a class.Construct given aReflectData
.ReflectDatumReader
(Schema root) Construct where the writer's and reader's schemas are the same.ReflectDatumReader
(Schema writer, Schema reader) Construct given writer's and reader's schema.ReflectDatumReader
(Schema writer, Schema reader, ReflectData data) Construct given writer's and reader's schema and the data model. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addToArray
(Object array, long pos, Object e) Called by the default implementation ofGenericDatumReader.readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)
to add a value.protected Object
createString
(String value) Called to create a string from a default value.protected Object
Called to create new array instances.protected Object
Called by the default implementation ofGenericDatumReader.readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)
to retrieve a value from a reused instance.protected Object
readArray
(Object old, Schema expected, ResolvingDecoder in) Called to read an array instance.protected Object
Called to read byte arrays.protected void
readField
(Object record, Schema.Field field, Object oldDatum, ResolvingDecoder in, Object state) Called to read a single field of a record.protected Object
Called to read integers.protected Object
readString
(Object old, Decoder in) Called to read strings.Methods inherited from class org.apache.avro.specific.SpecificDatumReader
findStringClass, getSpecificData, getTrustedPackages, readRecord, setSchema
Methods inherited from class org.apache.avro.generic.GenericDatumReader
addToMap, convert, createBytes, createEnum, createFixed, createFixed, getData, getExpected, getResolver, getSchema, newInstanceFromString, newMap, newRecord, read, read, readBytes, readEnum, readFixed, readMap, readMapKey, readString, readWithConversion, readWithoutConversion, setExpected, skip
-
Constructor Details
-
ReflectDatumReader
public ReflectDatumReader() -
ReflectDatumReader
Construct for reading instances of a class. -
ReflectDatumReader
Construct where the writer's and reader's schemas are the same. -
ReflectDatumReader
Construct given writer's and reader's schema. -
ReflectDatumReader
Construct given writer's and reader's schema and the data model. -
ReflectDatumReader
Construct given aReflectData
.
-
-
Method Details
-
newArray
Description copied from class:GenericDatumReader
Called to create new array instances. Subclasses may override to use a different array implementation. By default, this returns aGenericData.Array
.- Overrides:
newArray
in classGenericDatumReader<T>
-
peekArray
Description copied from class:GenericDatumReader
Called by the default implementation ofGenericDatumReader.readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)
to retrieve a value from a reused instance. The default implementation is forGenericArray
.- Overrides:
peekArray
in classGenericDatumReader<T>
-
addToArray
Description copied from class:GenericDatumReader
Called by the default implementation ofGenericDatumReader.readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)
to add a value. The default implementation is forCollection
.- Overrides:
addToArray
in classGenericDatumReader<T>
-
readArray
Description copied from class:GenericDatumReader
Called to read an array instance. May be overridden for alternate array representations.- Overrides:
readArray
in classGenericDatumReader<T>
- Throws:
IOException
-
readString
Description copied from class:GenericDatumReader
Called to read strings. Subclasses may override to use a different string representation. By default, this callsDecoder.readString(Utf8)
.- Overrides:
readString
in classGenericDatumReader<T>
- Throws:
IOException
-
createString
Description copied from class:GenericDatumReader
Called to create a string from a default value. Subclasses may override to use a different string representation. By default, this callsUtf8(String)
.- Overrides:
createString
in classGenericDatumReader<T>
-
readBytes
Description copied from class:GenericDatumReader
Called to read byte arrays. Subclasses may override to use a different byte array representation. By default, this callsDecoder.readBytes(ByteBuffer)
.- Overrides:
readBytes
in classGenericDatumReader<T>
- Throws:
IOException
-
readInt
Description copied from class:GenericDatumReader
Called to read integers. Subclasses may override to use a different integer representation. By default, this callsDecoder.readInt()
.- Overrides:
readInt
in classGenericDatumReader<T>
- Throws:
IOException
-
readField
protected void readField(Object record, Schema.Field field, Object oldDatum, ResolvingDecoder in, Object state) throws IOException Description copied from class:GenericDatumReader
Called to read a single field of a record. May be overridden for more efficient or alternate implementations.- Overrides:
readField
in classSpecificDatumReader<T>
- Throws:
IOException
-