Java Object Serialization Performance tips

后端 未结 9 1212
别那么骄傲
别那么骄傲 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: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.

提交回复
热议问题