Class MessageBuilderRecordSerializerBase<M extends Message,​U extends Message,​B extends Message.Builder>

    • Constructor Detail

      • MessageBuilderRecordSerializerBase

        public MessageBuilderRecordSerializerBase​(@Nonnull
                                                  Supplier<B> builderSupplier)
    • Method Detail

      • serialize

        @Nonnull
        public byte[] serialize​(@Nonnull
                                RecordMetaData metaData,
                                @Nonnull
                                RecordType recordType,
                                @Nonnull
                                M record,
                                @Nullable
                                StoreTimer timer)
        Description copied from interface: RecordSerializer
        Convert a Protobuf record to bytes. While Protobuf messages provide their own 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.
        Specified by:
        serialize in interface RecordSerializer<M extends Message>
        Parameters:
        metaData - the store's meta-data
        recordType - the record type of the message
        record - the Protobuf record to serialize
        timer - a timer used to instrument serialization
        Returns:
        the serialized record