T
- Type T to be written.public final class ReflectionDatumWriter<T> extends ReflectionWriter<Encoder,T> implements DatumWriter<T>
DatumWriter
that uses java reflection to encode data. The encoding schema it uses is
the same as the binary encoding as specified in Avro, with the enhancement of support for non-string
map keys.schema, seenRefs
Constructor and Description |
---|
ReflectionDatumWriter(co.cask.cdap.api.data.schema.Schema schema) |
Modifier and Type | Method and Description |
---|---|
void |
encode(T data,
Encoder encoder) |
co.cask.cdap.api.data.schema.Schema |
getSchema() |
protected void |
writeArray(Encoder encoder,
Collection<?> col,
co.cask.cdap.api.data.schema.Schema componentSchema) |
protected void |
writeArray(Encoder encoder,
Object array,
co.cask.cdap.api.data.schema.Schema componentSchema) |
protected void |
writeBool(Encoder encoder,
Boolean val) |
protected void |
writeBytes(Encoder encoder,
byte[] val) |
protected void |
writeBytes(Encoder encoder,
ByteBuffer val) |
protected void |
writeDouble(Encoder encoder,
Double val) |
protected void |
writeEnum(Encoder encoder,
String val,
co.cask.cdap.api.data.schema.Schema schema) |
protected void |
writeFloat(Encoder encoder,
Float val) |
protected void |
writeInt(Encoder encoder,
int val) |
protected void |
writeLong(Encoder encoder,
long val) |
protected void |
writeMap(Encoder encoder,
Map<?,?> map,
Map.Entry<co.cask.cdap.api.data.schema.Schema,co.cask.cdap.api.data.schema.Schema> mapSchema) |
protected void |
writeNull(Encoder encoder) |
protected void |
writeString(Encoder encoder,
String val) |
protected void |
writeUnion(Encoder encoder,
Object val,
co.cask.cdap.api.data.schema.Schema schema) |
write, write, writeRecord
public ReflectionDatumWriter(co.cask.cdap.api.data.schema.Schema schema)
public co.cask.cdap.api.data.schema.Schema getSchema()
public void encode(T data, Encoder encoder) throws IOException
encode
in interface DatumWriter<T>
IOException
protected void writeNull(Encoder encoder) throws IOException
writeNull
in class ReflectionWriter<Encoder,T>
IOException
protected void writeBool(Encoder encoder, Boolean val) throws IOException
writeBool
in class ReflectionWriter<Encoder,T>
IOException
protected void writeInt(Encoder encoder, int val) throws IOException
writeInt
in class ReflectionWriter<Encoder,T>
IOException
protected void writeLong(Encoder encoder, long val) throws IOException
writeLong
in class ReflectionWriter<Encoder,T>
IOException
protected void writeFloat(Encoder encoder, Float val) throws IOException
writeFloat
in class ReflectionWriter<Encoder,T>
IOException
protected void writeDouble(Encoder encoder, Double val) throws IOException
writeDouble
in class ReflectionWriter<Encoder,T>
IOException
protected void writeString(Encoder encoder, String val) throws IOException
writeString
in class ReflectionWriter<Encoder,T>
IOException
protected void writeBytes(Encoder encoder, ByteBuffer val) throws IOException
writeBytes
in class ReflectionWriter<Encoder,T>
IOException
protected void writeBytes(Encoder encoder, byte[] val) throws IOException
writeBytes
in class ReflectionWriter<Encoder,T>
IOException
protected void writeEnum(Encoder encoder, String val, co.cask.cdap.api.data.schema.Schema schema) throws IOException
writeEnum
in class ReflectionWriter<Encoder,T>
IOException
protected void writeArray(Encoder encoder, Collection<?> col, co.cask.cdap.api.data.schema.Schema componentSchema) throws IOException
writeArray
in class ReflectionWriter<Encoder,T>
IOException
protected void writeArray(Encoder encoder, Object array, co.cask.cdap.api.data.schema.Schema componentSchema) throws IOException
writeArray
in class ReflectionWriter<Encoder,T>
IOException
protected void writeMap(Encoder encoder, Map<?,?> map, Map.Entry<co.cask.cdap.api.data.schema.Schema,co.cask.cdap.api.data.schema.Schema> mapSchema) throws IOException
writeMap
in class ReflectionWriter<Encoder,T>
IOException
protected void writeUnion(Encoder encoder, Object val, co.cask.cdap.api.data.schema.Schema schema) throws IOException
writeUnion
in class ReflectionWriter<Encoder,T>
IOException
Copyright © 2016 Cask Data, Inc. Licensed under the Apache License, Version 2.0.