public class GenericDatumReader<D> extends Object implements DatumReader<D>
DatumReader
for generic Java objects.Modifier | Constructor and Description |
---|---|
|
GenericDatumReader() |
protected |
GenericDatumReader(GenericData data) |
|
GenericDatumReader(Schema schema)
Construct where the writer's and reader's schemas are the same.
|
|
GenericDatumReader(Schema writer,
Schema reader)
Construct given writer's and reader's schema.
|
|
GenericDatumReader(Schema writer,
Schema reader,
GenericData data) |
Modifier and Type | Method and Description |
---|---|
protected void |
addToArray(Object array,
long pos,
Object e)
Called by the default implementation of
readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to add a
value. |
protected void |
addToMap(Object map,
Object key,
Object value)
Called by the default implementation of
readMap(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to add a
key/value pair. |
protected Object |
createBytes(byte[] value)
Called to create byte arrays from default values.
|
protected Object |
createEnum(String symbol,
Schema schema)
Called to create an enum value.
|
protected Object |
createFixed(Object old,
byte[] bytes,
Schema schema)
Deprecated.
As of Avro 1.6.0 this method has been moved to
GenericData.createFixed(Object, byte[], Schema) |
protected Object |
createFixed(Object old,
Schema schema)
Deprecated.
As of Avro 1.6.0 this method has been moved to
GenericData.createFixed(Object, Schema) |
protected Object |
createString(String value)
Called to create a string from a default value.
|
protected Class |
findStringClass(Schema schema)
Determines the class to used to represent a string Schema.
|
GenericData |
getData()
Return the
GenericData implementation. |
Schema |
getExpected()
Get the reader's schema.
|
protected ResolvingDecoder |
getResolver(Schema actual,
Schema expected)
Gets a resolving decoder for use by this GenericDatumReader.
|
Schema |
getSchema()
Return the writer's schema.
|
protected Object |
newArray(Object old,
int size,
Schema schema)
Called to create new array instances.
|
protected Object |
newInstanceFromString(Class c,
String s) |
protected Object |
newMap(Object old,
int size)
Called to create new array instances.
|
protected Object |
newRecord(Object old,
Schema schema)
Deprecated.
As of Avro 1.6.0 this method has been moved to
GenericData.newRecord(Object, Schema) |
protected Object |
peekArray(Object array)
Called by the default implementation of
readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to retrieve a
value from a reused instance. |
D |
read(D reuse,
Decoder in)
Read a datum.
|
protected Object |
read(Object old,
Schema expected,
ResolvingDecoder in)
Called to read data.
|
protected Object |
readArray(Object old,
Schema expected,
ResolvingDecoder in)
Called to read an array instance.
|
protected Object |
readBytes(Object old,
Decoder in)
Called to read byte arrays.
|
protected Object |
readBytes(Object old,
Schema s,
Decoder in)
Called to read byte arrays.
|
protected Object |
readEnum(Schema expected,
Decoder in)
Called to read an enum value.
|
protected void |
readField(Object r,
Schema.Field f,
Object oldDatum,
ResolvingDecoder in,
Object state)
Called to read a single field of a record.
|
protected Object |
readFixed(Object old,
Schema expected,
Decoder in)
Called to read a fixed value.
|
protected Object |
readInt(Object old,
Schema expected,
Decoder in)
Called to read integers.
|
protected Object |
readMap(Object old,
Schema expected,
ResolvingDecoder in)
Called to read a map instance.
|
protected Object |
readMapKey(Object old,
Schema expected,
Decoder in)
Called by the default implementation of
readMap(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to read a
key value. |
protected Object |
readRecord(Object old,
Schema expected,
ResolvingDecoder in)
Called to read a record instance.
|
protected Object |
readString(Object old,
Decoder in)
Called to read strings.
|
protected Object |
readString(Object old,
Schema expected,
Decoder in)
Called to read strings.
|
void |
setExpected(Schema reader)
Set the reader's schema.
|
void |
setSchema(Schema writer)
Set the writer's schema.
|
static void |
skip(Schema schema,
Decoder in)
Skip an instance of a schema.
|
public GenericDatumReader()
public GenericDatumReader(Schema schema)
public GenericDatumReader(Schema writer, Schema reader)
public GenericDatumReader(Schema writer, Schema reader, GenericData data)
protected GenericDatumReader(GenericData data)
public GenericData getData()
GenericData
implementation.public Schema getSchema()
public void setSchema(Schema writer)
DatumReader
setSchema
in interface DatumReader<D>
public Schema getExpected()
public void setExpected(Schema reader)
protected final ResolvingDecoder getResolver(Schema actual, Schema expected) throws IOException
IOException
public D read(D reuse, Decoder in) throws IOException
DatumReader
read
in interface DatumReader<D>
IOException
protected Object read(Object old, Schema expected, ResolvingDecoder in) throws IOException
IOException
protected Object readRecord(Object old, Schema expected, ResolvingDecoder in) throws IOException
IOException
protected void readField(Object r, Schema.Field f, Object oldDatum, ResolvingDecoder in, Object state) throws IOException
IOException
protected Object readEnum(Schema expected, Decoder in) throws IOException
IOException
protected Object createEnum(String symbol, Schema schema)
protected Object readArray(Object old, Schema expected, ResolvingDecoder in) throws IOException
IOException
protected Object peekArray(Object array)
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 for GenericArray
.protected void addToArray(Object array, long pos, Object e)
readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)
to add a
value. The default implementation is for Collection
.protected Object readMap(Object old, Schema expected, ResolvingDecoder in) throws IOException
IOException
protected Object readMapKey(Object old, Schema expected, Decoder in) throws IOException
readMap(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)
to read a
key value. The default implementation returns delegates to
readString(Object, org.apache.avro.io.Decoder)
.IOException
protected void addToMap(Object map, Object key, Object value)
readMap(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)
to add a
key/value pair. The default implementation is for Map
.protected Object readFixed(Object old, Schema expected, Decoder in) throws IOException
GenericFixed
.IOException
@Deprecated protected Object createFixed(Object old, Schema schema)
GenericData.createFixed(Object, Schema)
GenericFixed
.@Deprecated protected Object createFixed(Object old, byte[] bytes, Schema schema)
GenericData.createFixed(Object, byte[], Schema)
GenericFixed
.@Deprecated protected Object newRecord(Object old, Schema schema)
GenericData.newRecord(Object, Schema)
GenericData.Record
.protected Object newArray(Object old, int size, Schema schema)
GenericData.Array
.protected Object newMap(Object old, int size)
HashMap
.protected Object readString(Object old, Schema expected, Decoder in) throws IOException
readString(Object,Decoder)
.IOException
protected Object readString(Object old, Decoder in) throws IOException
Decoder.readString(Utf8)
.IOException
protected Object createString(String value)
Utf8.Utf8(String)
.protected Class findStringClass(Schema schema)
GenericData.STRING_PROP
to determine whether Utf8
or
String
is used. Subclasses may override for alternate
representations.protected Object readBytes(Object old, Schema s, Decoder in) throws IOException
Decoder.readBytes(ByteBuffer)
.IOException
protected Object readBytes(Object old, Decoder in) throws IOException
Decoder.readBytes(ByteBuffer)
.IOException
protected Object readInt(Object old, Schema expected, Decoder in) throws IOException
Decoder.readInt()
.IOException
protected Object createBytes(byte[] value)
ByteBuffer.wrap(byte[])
.public static void skip(Schema schema, Decoder in) throws IOException
IOException
Copyright © 2009-2014 The Apache Software Foundation. All Rights Reserved.