Hazelcast序列化嵌套对象 [英] Hazelcast Serialization nested objects

查看:71
本文介绍了Hazelcast序列化嵌套对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,关于最新的Hazecast版本和序列化,我有一个问题.让我们进行以下课程:

Hello I am having one question in regards of the latest Hazecast versions and serialization. Lets have the following class:

class Customer implements DataSerializeable {
    List<Address> adresses;
    CustomerDetails details;
}

两个类Address和CustomerDetails都实现DataSerializeable.目前,我们对其进行序列化的方式是:

Both classes Address and CustomerDetails implement DataSerializeable. The way we are serializing them at the moment is:

public void writeData(ObjectDataOutput out) throws IOException {
   out.writeObject(address);
   out.writeObject(details);
}

在一些在线示例中,我看到了它们序列化同一类的方式是:

In some examples online I saw that the way they are serializing the same class is:

public void writeData(ObjectDataOutput out) throws IOException {
   address.writeData(out);
   short size = details.size();
   out.writeShort(size);
   for (CustomerDetail detail: details) {
      detail.writeData(out);
   }

}

我对几百万条记录进行了性能测试,我无法观察到性能上的显着差异.

I ran some performance test over couple of milion records I was not able to observe significant difference in performance.

建议对嵌套对象进行序列化的方法是什么.有人可以就最新的Hazelcast 3.6版发表评论吗?

What is the recommended way to do serialization of the Nested Objects. Can someone comment on that with regards of the latest Hazelcast version 3.6.

谢谢

推荐答案

这几天没有明显的区别,因为我们已经针对ArrayList,LinkedList和HashMap优化了序列化器.这样,您可以获得与手写几乎相同的好处.

These days there is no noticeable difference since we have optimized serializers for ArrayList, LinkedList, HashMap. That way you get the almost same benefit as handwriting it.

可以在这里找到ArrayList序列化程序类:

The ArrayList serializer classes can be found here: https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/ArrayListStreamSerializer.java

看看您将看到的代码,它将为您带来几乎相同的好处.

Looking at the code you'll see, that it'll give you almost the same benefit.

这篇关于Hazelcast序列化嵌套对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆