When a java POJO is serialized, the following are the steps involved
- Add metadata of the class associated with the object, meta information will be the entire package name and the class name.
- If there are any superclasses, metadata will be added recursively until we find the Object class
- The purpose of adding the package name and the class name as meta is to help in deserialization.
- In the above image, we can see the metadata information that is appended as part of GenericJackson2Json serializer, such as @class, java.util.ImmutableCollections.List.
- In this example, College contains List and every teacher object contains List, so for every teacher and student, this meta-information will be occupying additional space.
refer: https://developers.google.com/protocol-buffers
In protocol buffers, the transmission of data is done in binary format. Because of this it is faster and saves space. The protobuf (protocol buffers) consist of context file (.proto file)
{ string name = 1; string address = 2; }
The protobuf doesn’t main the order, so field numbers are used for deserializtion.
Another major advantage of using protobuf is that, the SDK will be able to generate code for other languages as well.
TODO: Add a golang example, of fetching values from redis using prtobuf