Hazelcast Portable serialization

2019-08-07 13:14发布

问题:

I want to use Portable serialization for objects stored in IMap to achieve:

  • fast indexing during insertion (without deserializing objects and reflection)
  • class evolution (versioning)

Is it possible to store my classes without implementing Portableinterface?

Is it possible to store 3rd party classes like Date or BigDecimal (or with nested structure) which can not implement Portable interface, while still being indexable?

回答1:

You can achieve fast indexing using Portable, yes. You'll also see benefits when you're querying on non-indexed fields since there'll be no full deserialization. VersionedPortable support versioning as well but

  1. You must implement Portable interface
  2. For types that doesn't supported by portable, you need to convert the data to a supported format, For date Long for example. And you need to code serialization/deserialization for each property & handle versioning yourself.
  3. Portable is backward compatible only for read. If you update the data from an app who has a previous version, then you'll lost the new field updates done previously by an app has higher version of the Portable object.

So depends on your exact requirements, you need to chose the correct serialization format.

If versioning is not so important or you can handle it manually, but query performance is, then yes Portable make sense. But if you're planning to use versioning heavily, I would suggest using a backward/forward compatible serialization format like Google Protocol Buffers.

You can check this example to get an idea: https://github.com/gokhanoner/data-versioning-protobuf



标签: hazelcast