Class ThriftCoder<T>

Type Parameters:
T - type of element handled by coder.
All Implemented Interfaces:
Serializable

public class ThriftCoder<T> extends CustomCoder<T>
A Coder using a Thrift TProtocol to serialize/deserialize elements.
See Also:
  • Constructor Details

    • ThriftCoder

      protected ThriftCoder(Class<T> type, org.apache.thrift.protocol.TProtocolFactory protocolFactory)
  • Method Details

    • of

      public static <T> ThriftCoder<T> of(Class<T> clazz, org.apache.thrift.protocol.TProtocolFactory protocolFactory)
      Returns an ThriftCoder instance for the provided clazz and protocolFactory.
      Type Parameters:
      T - element type
      Parameters:
      clazz - TBase class used to decode into/ encode from.
      protocolFactory - factory for TProtocol to be used to encode/decode.
      Returns:
      ThriftCoder initialize with class to be encoded/decoded and TProtocolFactory used to encode/decode.
    • encode

      public void encode(T value, OutputStream outStream) throws CoderException, IOException
      Encodes the given value of type T onto the given output stream using provided protocolFactory.
      Specified by:
      encode in class Coder<T>
      Parameters:
      value - TBase to encode.
      outStream - stream to output encoded value to.
      Throws:
      IOException - if writing to the OutputStream fails for some reason
      CoderException - if the value could not be encoded for some reason
    • decode

      public T decode(InputStream inStream) throws CoderException, IOException
      Decodes a value of type T from the given input stream using provided protocolFactory. Returns the decoded value.
      Specified by:
      decode in class Coder<T>
      Parameters:
      inStream - stream of input values to be decoded
      Returns:
      TBase decoded object
      Throws:
      IOException - if reading from the InputStream fails for some reason
      CoderException - if the value could not be decoded for some reason