Serializing Data with Protocol Buffers
Vinicius Vielmo Cogo
Smalltalks, DI, FC/UL. February 12, 2014.
Problem statement
2 / 19
App1
App2
Storage
Problem statement
2 / 19
Correct object
Efficient (time and space)
Language interoperable
Easy to use
App1
App2
Storage
Context
Data serialization (in Java):
1. Java built-in serialization
Ex.: writeObject/readObject(aObject)
Easy to use, but inefficient in terms of space (extra fields)
No language interoperability
2. Manual binary encoding
Ex.: 4 ints as - and aObject.getBytes()
Space efficient, but time efficiency depends on parsing methods
Difficult for complex objects
Language interoperable
3. Human-readable formats
Ex.: Using XML, JSON, DOM, SAX, STAX, JAXB, JAXP, etc.
Inefficient (space and time w/ human readable format)
Language interoperable
3 / 19
Protocol Buffers
4 / 19
Protocol Buffers (Protobuf) is a solution to data serialization:
A description language
A compiler
A library
Easy-to-use, efficient automatic binary encoding
Created by and in production at Google Inc.
Publicly launched in 2008.
Language interoperable:
Officially: Java, C++, and Python
Unofficially: C, C#, Erlang, Perl, PHP, Ruby, etc.
Download and install the Protocol Buffers
Available at:
https://developers.google.com/protocol-buffers/