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 |
convert(Object datum,
Schema schema,
LogicalType type,
Conversion<?> conversion)
Convert an underlying representation of a logical type (such as a ByteBuffer)
to a higher level object (such as a BigDecimal).
|
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 record,
Schema.Field field,
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.
|
protected Object |
readWithConversion(Object old,
Schema expected,
LogicalType logicalType,
Conversion<?> conversion,
ResolvingDecoder in) |
protected Object |
readWithoutConversion(Object old,
Schema expected,
ResolvingDecoder in) |
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)
DatumReadersetSchema in interface DatumReader<D>public Schema getExpected()
public void setExpected(Schema reader)
protected final ResolvingDecoder getResolver(Schema actual, Schema expected) throws IOException
IOExceptionpublic D read(D reuse, Decoder in) throws IOException
DatumReaderread in interface DatumReader<D>IOExceptionprotected Object read(Object old, Schema expected, ResolvingDecoder in) throws IOException
IOExceptionprotected Object readWithConversion(Object old, Schema expected, LogicalType logicalType, Conversion<?> conversion, ResolvingDecoder in) throws IOException
IOExceptionprotected Object readWithoutConversion(Object old, Schema expected, ResolvingDecoder in) throws IOException
IOExceptionprotected Object convert(Object datum, Schema schema, LogicalType type, Conversion<?> conversion)
IllegalArgumentException - if a null schema or logicalType is passed in
while datum and conversion are not null.
Please be noticed that the exception type
has changed. With version 1.8.0 and earlier,
in above circumstance, the exception thrown
out depends on the implementation of
conversion (most likely a
NullPointerException). Now, an
IllegalArgumentException will be thrown out
instead.protected Object readRecord(Object old, Schema expected, ResolvingDecoder in) throws IOException
IOExceptionprotected void readField(Object record, Schema.Field field, Object oldDatum, ResolvingDecoder in, Object state) throws IOException
IOExceptionprotected Object readEnum(Schema expected, Decoder in) throws IOException
IOExceptionprotected Object createEnum(String symbol, Schema schema)
protected Object readArray(Object old, Schema expected, ResolvingDecoder in) throws IOException
IOExceptionprotected 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
IOExceptionprotected 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).IOExceptionprotected 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).IOExceptionprotected Object readString(Object old, Decoder in) throws IOException
Decoder.readString(Utf8).IOExceptionprotected Object createString(String value)
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).IOExceptionprotected Object readBytes(Object old, Decoder in) throws IOException
Decoder.readBytes(ByteBuffer).IOExceptionprotected Object readInt(Object old, Schema expected, Decoder in) throws IOException
Decoder.readInt().IOExceptionprotected Object createBytes(byte[] value)
ByteBuffer.wrap(byte[]).public static void skip(Schema schema, Decoder in) throws IOException
IOExceptionCopyright © 2009–2023 The Apache Software Foundation. All rights reserved.