M
- generated Protobuf class for the record message typeU
- generated Protobuf class for the union messageB
- generated Protobuf class for the union message's builder@API(value=UNSTABLE) public abstract class MessageBuilderRecordSerializerBase<M extends Message,U extends Message,B extends Message.Builder> extends Object implements RecordSerializer<M>
DynamicMessageRecordSerializer
RecordSerializer.Counts, RecordSerializer.Events
Constructor and Description |
---|
MessageBuilderRecordSerializerBase(Supplier<B> builderSupplier) |
Modifier and Type | Method and Description |
---|---|
M |
deserialize(RecordMetaData metaData,
Tuple primaryKey,
byte[] serialized,
StoreTimer timer)
Convert a byte array to a Protobuf record.
|
protected abstract M |
getUnionField(Descriptors.Descriptor unionDescriptor,
U storedRecord) |
byte[] |
serialize(RecordMetaData metaData,
RecordType recordType,
M record,
StoreTimer timer)
Convert a Protobuf record to bytes.
|
protected abstract void |
setUnionField(RecordMetaData metaData,
RecordType recordType,
B unionBuilder,
M record) |
RecordSerializer<Message> |
widen()
Convert this typed record serializer to an untyped one.
|
@Nonnull public byte[] serialize(@Nonnull RecordMetaData metaData, @Nonnull RecordType recordType, @Nonnull M record, @Nullable StoreTimer timer)
RecordSerializer
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.serialize
in interface RecordSerializer<M extends Message>
metaData
- the store's meta-datarecordType
- the record type of the messagerecord
- the Protobuf record to serializetimer
- a timer used to instrument serializationprotected abstract void setUnionField(@Nonnull RecordMetaData metaData, @Nonnull RecordType recordType, @Nonnull B unionBuilder, @Nonnull M record)
@Nonnull public M deserialize(@Nonnull RecordMetaData metaData, @Nonnull Tuple primaryKey, @Nonnull byte[] serialized, @Nullable StoreTimer timer)
RecordSerializer
serialize()
method.deserialize
in interface RecordSerializer<M extends Message>
metaData
- the store's meta-dataprimaryKey
- the primary key of the recordserialized
- the serialized bytestimer
- a timer used to instrument deserialization@Nonnull protected abstract M getUnionField(@Nonnull Descriptors.Descriptor unionDescriptor, @Nonnull U storedRecord)
@Nonnull public RecordSerializer<Message> widen()
RecordSerializer
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.
widen
in interface RecordSerializer<M extends Message>