voldemort.serialization.protobuf
Class ProtoBufSerializer<T extends com.google.protobuf.Message>
java.lang.Object
voldemort.serialization.protobuf.ProtoBufSerializer<T>
- All Implemented Interfaces:
- Serializer<T>
public class ProtoBufSerializer<T extends com.google.protobuf.Message>
- extends java.lang.Object
- implements Serializer<T>
A serializer that relies on Protocol Buffers for serialization and
deserialization. Only Java clients are supported currently, but there are
plans to support clients in other languages.
An example configuration of a value-serializer follows.
<value-serializer>
<type>protobuf</type>
<schema-info>java=com.linkedin.foobar.FooMessage</schema-info>
</value-serializer>
Once support for clients in other languages is available, a comma-separated
list will be accepted for the schema-info element (one for each language).
Method Summary |
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 |
ProtoBufSerializer
public ProtoBufSerializer(java.lang.String currentSchemaInfo)
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 com.google.protobuf.Message>
- 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 com.google.protobuf.Message>
- Parameters:
bytes
- An array of bytes with the objects data
- Returns:
- A java object serialzed from the bytes
Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu