Class TransformedRecordSerializer<M extends Message>

  • Type Parameters:
    M - type of Message that underlying records will use
    All Implemented Interfaces:
    RecordSerializer<M>
    Direct Known Subclasses:
    TransformedRecordSerializerJCE

    @API(UNSTABLE)
    public class TransformedRecordSerializer<M extends Message>
    extends Object
    implements RecordSerializer<M>
    A RecordSerializer implementation that transforms the bytes produced by another serializer before returning (and likewise performs the reverse transformation before deserializing). At the moment, the transformations are encryption and compression, but other transformations could be added in the future.

    This serializer will begin each serialized string with a one-byte prefix containing information about which transformations were performed. This way, when deserializing, it can detect which transformations were applied so it knows which ones it needs to use to restore the original record. This also allows it to do things like decide not to compress records, even if compression is turned on, if the compression algorithm actually produces a byte array that is larger than the raw record, for example.

    This base class does not itself support encryption: an exception will be thrown when trying to construct a serializer with encryption enabled or when encountering a serialized record that requires decryption. Subclasses, such as TransformedRecordSerializerJCE, implement encryption and have additional state like secret keys.

    It is designed to be compatible with the DynamicMessageRecordSerializer insofar as it can deserialize records written by that serializer, though records serialized by this class cannot be read by instances of that class. In the future, we might remove that capability (when all existing data have been migrated to use this class).