M
- type used to represent stored records@API(value=MAINTAINED) public interface RecordSerializer<M extends Message>
Modifier and Type | Interface and Description |
---|---|
static class |
RecordSerializer.Counts
Instrumentation counts related to record serialization.
|
static class |
RecordSerializer.Events
Instrumentation events related to record serialization.
|
Modifier and Type | Method and Description |
---|---|
M |
deserialize(RecordMetaData metaData,
Tuple primaryKey,
byte[] serialized,
StoreTimer timer)
Convert a byte array to a Protobuf record.
|
byte[] |
serialize(RecordMetaData metaData,
RecordType recordType,
M record,
StoreTimer timer)
Convert a Protobuf record to bytes.
|
RecordSerializer<Message> |
widen()
Convert this typed record serializer to an untyped one.
|
@Nonnull byte[] serialize(@Nonnull RecordMetaData metaData, @Nonnull RecordType recordType, @Nonnull M record, @Nullable StoreTimer timer)
MessageLite.toByteArray()
method for serialization,
record stores may elect to first wrap the raw Protobuf record in another
wrapping type or perform additional transformations like encrypt or
compress records. Implementors of this interface can control how
exactly which transformations are done, with the main constraint being
that whatever operation is done should be reversible by calling the
deserialize()
method on those bytes. Implementors should also be careful as they
evolve this method that the deserialize
method is still able
to read older data unless they are certain that any record store that
used the older implementation has since been cleared out or migrated
to a newer format.metaData
- the store's meta-datarecordType
- the record type of the messagerecord
- the Protobuf record to serializetimer
- a timer used to instrument serialization@Nonnull M deserialize(@Nonnull RecordMetaData metaData, @Nonnull Tuple primaryKey, @Nonnull byte[] serialized, @Nullable StoreTimer timer)
serialize()
method.metaData
- the store's meta-dataprimaryKey
- the primary key of the recordserialized
- the serialized bytestimer
- a timer used to instrument deserialization@Nonnull RecordSerializer<Message> widen()
widen
that serializer and return the result wrapped equivalently.
If a FDBTypedRecordStore
is created without calling
FDBTypedRecordStore.Builder.setUntypedSerializer(com.apple.foundationdb.record.provider.common.RecordSerializer<com.google.protobuf.Message>)
, then
in order to make the untyped record store that is paired with the typed store (used, for instance, to rebuild indexes),
the given typed serializer will be widened by calling this method.