public class ReflectData extends SpecificData
| Modifier and Type | Class and Description |
|---|---|
static class |
ReflectData.AllowNull
ReflectData implementation that permits null field values. |
SpecificData.SchemaConstructableGenericData.Array<T>, GenericData.EnumSymbol, GenericData.Fixed, GenericData.InstanceSupplier, GenericData.Record, GenericData.StringTypeRESERVED_WORDS, stringableClassesFAST_READER_PROP, STRING_PROP, STRING_TYPE_STRING| Constructor and Description |
|---|
ReflectData()
For subclasses.
|
ReflectData(ClassLoader classLoader)
Construct with a particular classloader.
|
| Modifier and Type | Method and Description |
|---|---|
ReflectData |
addStringable(Class c)
Cause a class to be treated as though it had an
Stringable
annotation. |
protected int |
compare(Object o1,
Object o2,
Schema s,
boolean equals)
Comparison implementation.
|
DatumReader |
createDatumReader(Schema schema)
Returns a
DatumReader for this kind of data. |
DatumReader |
createDatumReader(Schema writer,
Schema reader)
Returns a
DatumReader for this kind of data. |
DatumWriter |
createDatumWriter(Schema schema)
Returns a
DatumWriter for this kind of data. |
protected Schema |
createFieldSchema(Field field,
Map<String,Schema> names)
Create a schema for a field.
|
Object |
createFixed(Object old,
Schema schema)
Called to create an fixed value.
|
protected Schema |
createSchema(Type type,
Map<String,Schema> names)
Create the schema for a Java type.
|
static ReflectData |
get()
Return the singleton instance.
|
protected Collection |
getArrayAsCollection(Object datum)
Called to access an array as a collection.
|
Class |
getClass(Schema schema)
Return the class that implements a schema, or null if none exists.
|
Object |
getField(Object record,
String name,
int position)
Called by
GenericDatumReader.readRecord(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to retrieve a record field
value from a reused instance. |
protected Object |
getField(Object record,
String name,
int pos,
Object state)
Version of
GenericData.getField(java.lang.Object, java.lang.String, int) that has state. |
Protocol |
getProtocol(Class iface)
Return the protocol for a Java interface.
|
protected Schema |
getRecordSchema(Object record)
Called to obtain the schema of a record.
|
protected Object |
getRecordState(Object record,
Schema schema)
Produce state for repeated calls to
GenericData.getField(Object,String,int,Object) and
GenericData.setField(Object,String,int,Object,Object) on the same record. |
protected boolean |
isArray(Object datum)
Returns true for arrays and false otherwise, with the following exceptions:
|
protected boolean |
isBytes(Object datum)
Called by the default implementation of
GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object). |
protected boolean |
isMap(Object datum)
It returns false for non-string-maps because Avro writes out such maps as an
array of records.
|
protected boolean |
isRecord(Object datum)
Called by the default implementation of
GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object). |
protected boolean |
isStringable(Class<?> c)
True if a class should be serialized with toString().
|
static Schema |
makeNullable(Schema schema)
Create and return a union of the null schema and the provided schema.
|
Object |
newRecord(Object old,
Schema schema)
Called to create new record instances.
|
void |
setField(Object record,
String name,
int position,
Object value)
Called by
GenericDatumReader.readRecord(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to set a record fields value
to a record instance. |
protected void |
setField(Object record,
String name,
int position,
Object value,
Object state)
Version of
GenericData.setField(java.lang.Object, java.lang.String, int, java.lang.Object) that has state. |
boolean |
useCustomCoders()
Retrieve the current value of the custom-coders feature flag.
|
boolean |
validate(Schema schema,
Object datum)
Returns true if a Java datum matches a schema.
|
createEnum, getClassName, getDecoder, getEncoder, getEnumSchema, getForClass, getForSchema, getNewRecordSupplier, getSchema, getSchemaName, isEnum, isStringType, newInstance, setCustomCodersaddLogicalTypeConversion, compare, createFixed, deepCopy, getClassLoader, getConversionByClass, getConversionByClass, getConversionFor, getConversions, getDefaultValue, getFastReaderBuilder, getFixedSchema, hashCode, hashCodeAdd, induce, instanceOf, isBoolean, isDouble, isFastReaderEnabled, isFixed, isFloat, isInteger, isLong, isString, newArray, newMap, resolveUnion, setFastReaderEnabled, setStringType, toString, toStringpublic ReflectData()
get().public ReflectData(ClassLoader classLoader)
public boolean useCustomCoders()
SpecificDatatrue, but this default can be overriden using the system
property org.apache.avro.specific.use_custom_coders, and can be
set dynamically by SpecificData.useCustomCoders(). See for more about this feature flag.useCustomCoders in class SpecificDatapublic static ReflectData get()
public ReflectData addStringable(Class c)
Stringable
annotation.public DatumReader createDatumReader(Schema schema)
GenericDataDatumReader for this kind of data.createDatumReader in class SpecificDatapublic DatumReader createDatumReader(Schema writer, Schema reader)
GenericDataDatumReader for this kind of data.createDatumReader in class SpecificDatapublic DatumWriter createDatumWriter(Schema schema)
GenericDataDatumWriter for this kind of data.createDatumWriter in class SpecificDatapublic void setField(Object record, String name, int position, Object value)
GenericDataGenericDatumReader.readRecord(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to set a record fields value
to a record instance. The default implementation is for
IndexedRecord.setField in class GenericDataprotected void setField(Object record, String name, int position, Object value, Object state)
GenericDataGenericData.setField(java.lang.Object, java.lang.String, int, java.lang.Object) that has state.setField in class GenericDatapublic Object getField(Object record, String name, int position)
GenericDataGenericDatumReader.readRecord(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to retrieve a record field
value from a reused instance. The default implementation is for
IndexedRecord.getField in class GenericDataprotected Object getField(Object record, String name, int pos, Object state)
GenericDataGenericData.getField(java.lang.Object, java.lang.String, int) that has state.getField in class GenericDataprotected boolean isRecord(Object datum)
GenericDataGenericData.instanceOf(org.apache.avro.Schema, java.lang.Object).isRecord in class GenericDataprotected boolean isArray(Object datum)
Returns true for non-string-keyed maps, which are written as an array of key/value pair records.
Returns false for arrays of bytes, since those should be treated as byte data type instead.
isArray in class GenericDataprotected Collection getArrayAsCollection(Object datum)
GenericDatagetArrayAsCollection in class GenericDataprotected boolean isBytes(Object datum)
GenericDataGenericData.instanceOf(org.apache.avro.Schema, java.lang.Object).isBytes in class GenericDataprotected Schema getRecordSchema(Object record)
GenericDatagetRecordSchema in class GenericDatapublic boolean validate(Schema schema, Object datum)
GenericDatavalidate in class GenericDataprotected boolean isMap(Object datum)
isMap in class GenericDatapublic Class getClass(Schema schema)
SpecificDatagetClass in class SpecificDataprotected Schema createSchema(Type type, Map<String,Schema> names)
SpecificDatacreateSchema in class SpecificDataprotected boolean isStringable(Class<?> c)
SpecificDataisStringable in class SpecificDatapublic static Schema makeNullable(Schema schema)
protected Schema createFieldSchema(Field field, Map<String,Schema> names)
public Protocol getProtocol(Class iface)
The correct name of the method parameters needs the -parameters
java compiler argument. More info at https://openjdk.java.net/jeps/118
getProtocol in class SpecificDataprotected int compare(Object o1, Object o2, Schema s, boolean equals)
GenericDatacompare in class SpecificDataprotected Object getRecordState(Object record, Schema schema)
GenericDataGenericData.getField(Object,String,int,Object) and
GenericData.setField(Object,String,int,Object,Object) on the same record.getRecordState in class GenericDatapublic Object createFixed(Object old, Schema schema)
GenericDataGenericFixed.createFixed in class SpecificDatapublic Object newRecord(Object old, Schema schema)
GenericDataGenericData.Record.newRecord in class SpecificDataCopyright © 2009–2020 The Apache Software Foundation. All rights reserved.