voldemort.serialization.thrift
Class ThriftSerializer<T extends org.apache.thrift.TBase<?,?>>
java.lang.Object
voldemort.serialization.thrift.ThriftSerializer<T>
- All Implemented Interfaces:
- Serializer<T>
public class ThriftSerializer<T extends org.apache.thrift.TBase<?,?>>
- extends java.lang.Object
- implements Serializer<T>
ThriftSerializer uses one of the Thrift protocols (binary, json and
simple-json) to serialize and deserialize a Thrift generated object.
The following is a sample configuration for value-serializer:
<value-serializer>
<type>thrift</type>
<schema-info>java=com.linkedin.foobar.FooMessage,protocol=binary</schema-info>
</value-serializer>
Currently, only Java clients are supported. Once support for clients in other
languages is available, a semi-colon separated list will be accepted for the
schema-info element (one for each language).
Method Summary |
protected org.apache.thrift.protocol.TProtocol |
createThriftProtocol(org.apache.thrift.transport.TTransport transport)
|
protected voldemort.serialization.thrift.ThriftSerializer.ThriftProtocol |
getThriftProtocol(java.lang.String protocolStr)
|
protected java.lang.String[] |
parseSchemaInfo(java.lang.String schemaInfo)
|
byte[] |
toBytes(T object)
Construct an array of bytes from the given object |
T |
toObject(byte[] bytes)
Create an object from an array of bytes |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ThriftSerializer
public ThriftSerializer(java.lang.String schemaInfo)
toBytes
public byte[] toBytes(T object)
- Description copied from interface:
Serializer
- Construct an array of bytes from the given object
- Specified by:
toBytes
in interface Serializer<T extends org.apache.thrift.TBase<?,?>>
- Parameters:
object
- The object
- Returns:
- The bytes taken from the object
toObject
public T toObject(byte[] bytes)
- Description copied from interface:
Serializer
- Create an object from an array of bytes
- Specified by:
toObject
in interface Serializer<T extends org.apache.thrift.TBase<?,?>>
- Parameters:
bytes
- An array of bytes with the objects data
- Returns:
- A java object serialzed from the bytes
parseSchemaInfo
protected java.lang.String[] parseSchemaInfo(java.lang.String schemaInfo)
getThriftProtocol
protected voldemort.serialization.thrift.ThriftSerializer.ThriftProtocol getThriftProtocol(java.lang.String protocolStr)
createThriftProtocol
protected org.apache.thrift.protocol.TProtocol createThriftProtocol(org.apache.thrift.transport.TTransport transport)
Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu