Package org.apache.accumulo.core.util
Class ThriftMessageUtil
- java.lang.Object
-
- org.apache.accumulo.core.util.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 Summary
Constructors Constructor Description ThriftMessageUtil()
ThriftMessageUtil(int initialCapacity, double growthCoefficient)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends org.apache.thrift.TBase<?,?>>
Tdeserialize(byte[] serialized, int offset, int length, T instance)
Deserializes a message into the providedinstance
fromserialized
<T extends org.apache.thrift.TBase<?,?>>
Tdeserialize(byte[] serialized, T instance)
Assumes the entire contents of the byte array compose the serializedinstance
ByteBuffer
serialize(org.apache.thrift.TBase<?,?> msg)
Convert themsg
to a byte array representation
-
-
-
Method Detail
-
serialize
public ByteBuffer serialize(org.apache.thrift.TBase<?,?> msg) throws IOException
Convert themsg
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, T instance) throws IOException
Assumes the entire contents of the byte array compose the serializedinstance
- Throws:
IOException
- See Also:
deserialize(byte[], int, int, TBase)
-
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 providedinstance
fromserialized
- Parameters:
serialized
- The serialized representation of the objectinstance
- An instance of the object to reconstitute- Returns:
- The reconstituted instance provided
- Throws:
IOException
- When deserialization fails
-
-