Class ThriftMessageUtil


  • public class ThriftMessageUtil
    extends Object
    Serializes and deserializes Thrift messages to and from byte arrays. This class is not thread-safe, external synchronization is necessary if it is used concurrently.
    • Constructor Detail

      • ThriftMessageUtil

        public ThriftMessageUtil()
      • ThriftMessageUtil

        public ThriftMessageUtil​(int initialCapacity,
                                 double growthCoefficient)
    • Method Detail

      • serialize

        public ByteBuffer serialize​(org.apache.thrift.TBase<?,​?> msg)
                             throws IOException
        Convert the msg to a byte array representation
        Parameters:
        msg - The message to serialize
        Returns:
        The serialized message
        Throws:
        IOException - When serialization fails
      • deserialize

        public <T extends org.apache.thrift.TBase<?,​?>> T deserialize​(byte[] serialized,
                                                                            int offset,
                                                                            int length,
                                                                            T instance)
                                                                     throws IOException
        Deserializes a message into the provided instance from serialized
        Parameters:
        serialized - The serialized representation of the object
        instance - An instance of the object to reconstitute
        Returns:
        The reconstituted instance provided
        Throws:
        IOException - When deserialization fails