Serializing Java Objects

I have to serialize a huge tree of objects (7000) to disk. Initially, we saved this tree in a database with Kodo, but this caused thousands and thousands of requests to load this tree into memory, and it will take a significant part of the available time of the local universe.

I tried serialization for this and I am really improving performance. However, I get the feeling that I can improve this by writing my own custom serialization code. I need to load this serialized object as quickly as possible.

In my machine, serializing / deserializing these objects takes about 15 seconds. It takes about 40 seconds to load from the database.

Any advice on what I can do to improve this performance, given that since the objects are in the tree, they refer to each other?

+5
source share
9 answers

One optimization configures class descriptors, so you store class descriptors in another database, and in the stream of objects you only reference them by identifier. This reduces the space required for serialized data. See For example, how in one project the classes SerialUtil and ClassesTable do it.

Externalizable Serializable . , .

, jserial, , Java. , , , , (. " ?" jserial FAQ).

+6

"" , . , / .

+10

writeObject() readObject(). , node . , node .

, writeObject() Tree ( ) , .

LinkedList, , . , .

+4

, Google Protocol Buffers . :

- Google , , - , XML, , . , , , , - Java, ++ Python

, . , , ( ), - - .

+4

(GZIPOutputStream)?

+1

,

  • , , . ( UUID, )
  • / /

Unserialization

  • ( , ),
  • , , , , , ( ) , , .

, , , - .

+1

java.io . .

java.io , , , ( TreeSet), ( , readObject).

, ( ).

0

Also, check out XStream , a library for serializing objects into XML and vice versa.

0
source

You can use Colfer to generate beans, and the standard Java serialization performance will get a boost of 10 - 1000x. If the size does not reach the probability of GB, you will be much lower than a second.

0
source

All Articles