Serializing Data
All data moving out of the client cache must be serializable.
Region Data Requiring Serialization
Certain region types (including client regions) require serialization.
-
The C++ client API provides two serialization options: the
apache::geode::client::Serializable
interface and GemFire PDX serialization. Serializing Data with PDX Serialization
PDX is a cross-language data format that can reduce the cost of distributing and serializing your objects. PDX stores data in named fields that you can access individually to avoid the cost of deserializing the entire data object. When you use PDX serialization with a C++ client, you can register a PdxSerializer for the entire cache, implement PDX serialization for each domain object or use automatic PDX serialization by running the
pdxautoserializer
tool.Serializing Data with the Serializable Interface
The C++ client API provides a
Serializable
interface that you can use for fast and compact data serialization. This section discusses the GemFire serializable interface, and presents implementation examples.-
If you have a graph of objects where each node can be serializable, the parent node can call
DataOutput::writeObject
to delegate the serialization responsibility to its child nodes. Similarly, your application can callDataInput::readObject
to deserialize the object graph. Serializing and Accessing Data as a Blob
If you have data that is best handled as a blob, such as structs that do not contain pointers, use the serializable type
CacheableBytes
.CacheableBytes
is a blob class that implements the serialization for you.