public abstract class SimpleTypeSerializer<T> extends Object implements TypeSerializer<T>
| Constructor and Description |
|---|
SimpleTypeSerializer(DataType dataType) |
| Modifier and Type | Method and Description |
|---|---|
DataType |
getDataType()
Gets the
DataType that is represented by the given T. |
T |
read(Buffer buffer,
GraphBinaryReader context)
Reads the type information and value from the buffer and returns an instance of T.
|
protected abstract T |
readValue(Buffer buffer,
GraphBinaryReader context)
Reads a non-nullable value according to the type format.
|
T |
readValue(Buffer buffer,
GraphBinaryReader context,
boolean nullable)
Reads the value from the buffer (not the type information) and returns an instance of T.
|
void |
write(T value,
Buffer buffer,
GraphBinaryWriter context)
Writes the type code, information and value to a buffer using the provided allocator.
|
protected abstract void |
writeValue(T value,
Buffer buffer,
GraphBinaryWriter context)
Writes a non-nullable value into a buffer using the provided allocator.
|
void |
writeValue(T value,
Buffer buffer,
GraphBinaryWriter context,
boolean nullable)
Writes the value to a buffer, composed by the value flag and the sequence of bytes.
|
public SimpleTypeSerializer(DataType dataType)
public DataType getDataType()
TypeSerializerDataType that is represented by the given T.getDataType in interface TypeSerializer<T>public T read(Buffer buffer, GraphBinaryReader context) throws IOException
TypeSerializerread in interface TypeSerializer<T>IOExceptionpublic T readValue(Buffer buffer, GraphBinaryReader context, boolean nullable) throws IOException
TypeSerializerImplementors should throw an exception when a complex type doesn't support reading without the type information.
readValue in interface TypeSerializer<T>IOExceptionprotected abstract T readValue(Buffer buffer, GraphBinaryReader context) throws IOException
buffer - A buffer which reader index has been set to the beginning of the {value}.context - The binary writer.IOExceptionpublic void write(T value, Buffer buffer, GraphBinaryWriter context) throws IOException
TypeSerializerwrite in interface TypeSerializer<T>IOExceptionpublic void writeValue(T value, Buffer buffer, GraphBinaryWriter context, boolean nullable) throws IOException
TypeSerializerwriteValue in interface TypeSerializer<T>IOExceptionprotected abstract void writeValue(T value, Buffer buffer, GraphBinaryWriter context) throws IOException
value - A non-nullable value.buffer - The buffer allocator to use.context - The binary writer.IOExceptionCopyright © 2013–2022 Apache Software Foundation. All rights reserved.