fast-serialization

简介

FST is fast java serialization drop in-replacement。

特性

up to 10 times faster 100% JDK Serialization compatible drop-in replacement (Ok, might be 99% ..). As an example: Lambda Serialization which came with 1.8 worked instantly.

Android compatible since version >= 2.17 (use FSTConfiguration.createAndroidDefaultConfiguration() both on server and client side. The configuration object has to be passed into FSTObjectIn/Output constructors)

OffHeap Maps, Persistent OffHeap maps

FSTStructs is very similar to IBM’s packed objects.

Difference is: You can run it with Oracle JDK today.

optionally en/decode any Serializable object graph to JSON (incl. shared references) (since 2.29) for interop Apache 2.0 license since 2.17

使用案例

maven 引入

<dependency>
    <groupId>de.ruedigermoeller</groupId>
    <artifactId>fst</artifactId>
    <version>2.56</version>
</dependency>

简单使用

As I constantly see people tinkering with ByteArrayOutputStreams and stuff (very inefficent), so here is the simplest way of using fast serialization (threadsafe)

static FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
// maybe register most frequently used classes on conf
[...]
// write
byte barray[] = conf.asByteArray(mySerializableObject);
[...]
// read
MyObject object = (MyObject)conf.asObject(barray);

参考资料

高效的Java序列化(Kryo和FST)

高性能序列化框架FST