Apache Ignite BinaryObject 膨胀 [英] Apache Ignite BinaryObject Bloat
问题描述
我有一个自定义对象,在将其放入 ignite 缓存之前,我将其转换为 BinaryObject(使用 BinaryObjectBuilder).我计算了自定义对象的深度大小,大约 500 字节.
I have a custom object which I am converting to BinaryObject (using the BinaryObjectBuilder) before putting it into ignite cache. I calculated the deep size of my custom object and it is about 500 bytes.
但是当我计算 BinaryObject 的大小时,它高达 8 MB.
But when I calculate the size of BinaryObject, it is a whopping ~8 MB.
这是预期的吗?
推荐答案
如果你看看 BinaryObjectImpl
类,你会看到,有些字段有 @GridDirectTransient
注释,这意味着这些字段在序列化过程中会被忽略.这些是非常大的对象,例如 BinaryContext
,其中包含相当多的系统内容.
If you take a look at BinaryObjectImpl
class, you will see, that some fields have @GridDirectTransient
annotations, meaning that these fields are ignored during serialization. These are pretty big objects, like BinaryContext
, which contains quite a lot of system stuff.
如果你想获得一个 BinaryObject
的近似大小,你可以将它转换为 BinaryObjectImpl
并调用 BinaryObjectImpl#array()
方法在上面.您将获得一个字节数组,它是您的对象的序列化表示.此数组的大小将为您提供 BinaryObject
大小的近似值.
If you want to get approximation of size of a BinaryObject
, you can cast it to BinaryObjectImpl
and call BinaryObjectImpl#array()
method on it. You will get a byte array which is a serialized representation of your object. Size of this array will give you an approximation of the BinaryObject
's size.
这篇关于Apache Ignite BinaryObject 膨胀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!