Java Object Serialization Performance tips

后端 未结 9 1208
别那么骄傲
别那么骄傲 2021-02-01 11:15

I must serialize a huge tree of objects (7,000) into disk. Originally we kept this tree in a database with Kodo, but it would make thousands upon thousands of Queries to load t

相关标签:
9条回答
  • 2021-02-01 11:54

    Also, have a look at XStream, a library to serialize objects to XML and back again.

    0 讨论(0)
  • 2021-02-01 11:56

    To avoid having to write your own serialization code, give Google Protocol Buffers a try. According to their site:

    Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages – Java, C++, or Python

    I've not used it, but have heard a lot of positive things about it. Plus, I have to maintain some custom serialization code, and it can be an absolute nightmare to do (let alone tracking down bugs), so getting someone else to do it for you is always a Good Thing.

    0 讨论(0)
  • 2021-02-01 11:56

    Have you tried compressing the stream (GZIPOutputStream) ?

    0 讨论(0)
提交回复
热议问题