Hazelcast便携式序列化 [英] Hazelcast Portable serialization
问题描述
我想对存储在IMap
中的对象使用Portable
序列化以实现:
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)
是否可以在不实现Portable
接口的情况下存储我的类?
Is it possible to store my classes without implementing Portable
interface?
是否可以存储不能实现Portable
接口的第三类方,例如Date
或BigDecimal
(或具有嵌套结构)?
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?
推荐答案
您可以使用Portable来实现快速索引编制,是的.在查询未索引字段时,您还将看到好处,因为不会进行完全反序列化. VersionedPortable也支持版本控制,但是
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
- 您必须实现Portable接口
- 对于便携式不支持的类型,您需要将数据转换为受支持的格式,例如,对于长日期".并且您需要为每个属性和序列号编码序列化/反序列化自己处理版本.
- 便携式仅向后兼容以进行读取.如果您从具有先前版本的应用程序更新数据,那么您将丢失以前由具有更高版本的Portable对象的应用程序完成的新字段更新.
因此,根据您的确切要求,您需要选择正确的序列化格式.
So depends on your exact requirements, you need to chose the correct serialization format.
如果版本控制不是那么重要,或者您可以手动处理,但是查询性能很重要,那么可移植"是有意义的.但是,如果您打算大量使用版本控制,我建议您使用向后/向前兼容的序列化格式,例如Google Protocol Buffers.
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.
您可以检查以下示例以了解它: https://github.com/gokhanoner /data-versioning-protobuf
You can check this example to get an idea: https://github.com/gokhanoner/data-versioning-protobuf
这篇关于Hazelcast便携式序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!