0

I am trying to figure out how big my objects are when serialized in ObjectGrid (IBM Extreme Scale). I want to add more data to the object but want to see how much increase in space it will take. Is there a way I can determine this? For instance, can I call a method on any of the object grid classes to get the bytes?

Thanks

devo
  • 1,290
  • 1
  • 15
  • 28

1 Answers1

0

In order to see the size of the serialized value of an inserted entry into the grid you would do code like the following:

ObjectMap map = session.getMap("map");
map.setValueOutputFormat(OutputFormat.RAW);
SerializedValue sv = (SerializedValue) map.get(key);
int size = sv.getInputStream().size();
System.out.println("The serialized size of the value for key " + key + " is " + size);
Jared Anderson
  • 249
  • 1
  • 5
  • Thanks for the response. I am getting an error when I try to get the serialized value:map is not compatible with the RAW output format on the value objects. Is there a setting I need to change? – devo May 07 '20 at 15:43
  • 1
    My response assumed that you were using a map that used the COPY_TO_BYTES CopyMode since you asked about the size of the serialized value. Without using the COPY_TO_BYTES or COPY_TO_BYTES_RAW CopyMode, the data is not put into byte form in the map and stays in its more memory consuming POJO form. So to answer your question, you would need to use the COPY_TO_BYTES CopyMode in order to use the code that I provided. – Jared Anderson May 10 '20 at 18:49