T
- the type of record that is to be Serialized and De-Serialized by
this objectpublic interface SerDe<T>
Modifier and Type | Method and Description |
---|---|
default void |
close()
Closes any resources that the SerDe is holding open
|
T |
deserializeEdit(java.io.DataInputStream in,
java.util.Map<java.lang.Object,T> currentRecordStates,
int version)
Reads an Edit Record from the given
DataInputStream and merges
that edit with the current version of the record, returning the new,
merged version. |
T |
deserializeRecord(java.io.DataInputStream in,
int version)
Reads a Record from the given
DataInputStream and returns this
record. |
java.lang.String |
getLocation(T record)
Returns the external location of the given record; this is used when a
record is moved away from WALI or is being re-introduced to WALI.
|
java.lang.Object |
getRecordIdentifier(T record)
Returns the unique ID for the given record
|
UpdateType |
getUpdateType(T record)
Returns the UpdateType for the given record
|
int |
getVersion()
Returns the version that this SerDe will use when writing.
|
default void |
readHeader(java.io.DataInputStream in)
Provides the SerDe the opportunity to read header information before deserializing any records
|
void |
serializeEdit(T previousRecordState,
T newRecordState,
java.io.DataOutputStream out)
Serializes an Edit Record to the log via the given
DataOutputStream . |
void |
serializeRecord(T record,
java.io.DataOutputStream out)
Serializes a Record in a form suitable for a Snapshot via the given
DataOutputStream . |
default void |
writeHeader(java.io.DataOutputStream out)
Provides the SerDe a chance to write header information to the given output stream
|
default void writeHeader(java.io.DataOutputStream out) throws java.io.IOException
out
- the DataOutputStream to write tojava.io.IOException
- if unable to write to the OutputStreamvoid serializeEdit(T previousRecordState, T newRecordState, java.io.DataOutputStream out) throws java.io.IOException
Serializes an Edit Record to the log via the given
DataOutputStream
.
previousRecordState
- previous statenewRecordState
- new stateout
- stream to write tojava.io.IOException
- if fail during writevoid serializeRecord(T record, java.io.DataOutputStream out) throws java.io.IOException
Serializes a Record in a form suitable for a Snapshot via the given
DataOutputStream
.
record
- to serializeout
- to write tojava.io.IOException
- if failed to writedefault void readHeader(java.io.DataInputStream in) throws java.io.IOException
in
- the InputStream to read fromjava.io.IOException
- if unable to read from the InputStreamT deserializeEdit(java.io.DataInputStream in, java.util.Map<java.lang.Object,T> currentRecordStates, int version) throws java.io.IOException
Reads an Edit Record from the given DataInputStream
and merges
that edit with the current version of the record, returning the new,
merged version. If the Edit Record indicates that the entity was deleted,
must return a Record with an UpdateType of UpdateType.DELETE
.
This method must never return null
.
in
- to deserialize fromcurrentRecordStates
- an unmodifiable map of Record ID's to the
current state of that recordversion
- the version of the SerDe that was used to serialize the
edit recordjava.io.IOException
- if failure readingT deserializeRecord(java.io.DataInputStream in, int version) throws java.io.IOException
Reads a Record from the given DataInputStream
and returns this
record. If no data is available, returns null
.
in
- stream to read fromversion
- the version of the SerDe that was used to serialize the
recordjava.io.IOException
- failure readingjava.lang.Object getRecordIdentifier(T record)
record
- to obtain identifier forUpdateType getUpdateType(T record)
record
- to retrieve update type forjava.lang.String getLocation(T record)
UpdateType.SWAP_OUT
that indicates a Location of
file://tmp/external1 and can then be re-introduced to WALI by updating
WALI with a record of type UpdateType.CREATE
that indicates a
Location of file://tmp/external1record
- to get location ofint getVersion()
default void close() throws java.io.IOException
java.io.IOException
- if unable to close resources