@API(value=UNSTABLE) public class DynamicMessageRecordSerializer extends Object implements RecordSerializer<Message>
DynamicMessage
.RecordSerializer.Counts, RecordSerializer.Events
Modifier | Constructor and Description |
---|---|
protected |
DynamicMessageRecordSerializer() |
Modifier and Type | Method and Description |
---|---|
Message |
deserialize(RecordMetaData metaData,
Tuple primaryKey,
byte[] serialized,
StoreTimer timer)
Convert a byte array to a Protobuf record.
|
protected DynamicMessage |
deserializeFromBytes(Descriptors.Descriptor storedDescriptor,
byte[] serialized) |
protected DynamicMessage |
deserializeUnion(Descriptors.Descriptor unionDescriptor,
Tuple primaryKey,
byte[] serialized,
int metaDataVersion) |
protected org.apache.commons.lang3.tuple.Pair<Descriptors.FieldDescriptor,DynamicMessage> |
getUnionField(DynamicMessage unionMessage,
Tuple primaryKey) |
static RecordSerializer<Message> |
instance() |
byte[] |
serialize(RecordMetaData metaData,
RecordType recordType,
Message record,
StoreTimer timer)
Convert a Protobuf record to bytes.
|
protected byte[] |
serializeToBytes(Message storedRecord) |
RecordSerializer<Message> |
widen()
Convert this typed record serializer to an untyped one.
|
@Nonnull public static RecordSerializer<Message> instance()
@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<Message>
@Nonnull public byte[] serialize(@Nonnull RecordMetaData metaData, @Nonnull RecordType recordType, @Nonnull Message 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<Message>
metaData
- the store's meta-datarecordType
- the record type of the messagerecord
- the Protobuf record to serializetimer
- a timer used to instrument serialization@Nonnull public Message deserialize(@Nonnull RecordMetaData metaData, @Nonnull Tuple primaryKey, @Nonnull byte[] serialized, @Nullable StoreTimer timer)
RecordSerializer
serialize()
method.deserialize
in interface RecordSerializer<Message>
metaData
- the store's meta-dataprimaryKey
- the primary key of the recordserialized
- the serialized bytestimer
- a timer used to instrument deserialization@Nonnull protected DynamicMessage deserializeUnion(@Nonnull Descriptors.Descriptor unionDescriptor, @Nonnull Tuple primaryKey, @Nonnull byte[] serialized, int metaDataVersion)
@Nonnull protected DynamicMessage deserializeFromBytes(@Nonnull Descriptors.Descriptor storedDescriptor, @Nonnull byte[] serialized)
@Nonnull protected org.apache.commons.lang3.tuple.Pair<Descriptors.FieldDescriptor,DynamicMessage> getUnionField(@Nonnull DynamicMessage unionMessage, @Nonnull Tuple primaryKey)