Java 快速序列化庫,FST 2.09 發布
FST 2.09 發布,該版本修復了自定義序列化器無法工作的問題,詳情請看 Issue 34
下載地址:fst-2.09.zip
FST fast-serialization 是重新實現的 Java 快速對象序列化的開發包。專注于速度,大小,兼容性。序列化速度更快(2-10倍)、體積更小,而且兼容 JDK 原生的序列化。要求 JDK 1.7 支持。使用該庫替換原來的基本不需要修改代碼。
特性:
- Faster serialization and smaller object size.
-
drop-in replacement. Does not require special getters/setters/Constructors/Interfaces to serialize a class. Extends Outputstream, implements
ObjectInput/ObjectOutput
. Few code changes required. - Full support of JDK-serialization features such as Externalizable writeObject/readObject/readReplace/validation/putField/getField, hooks etc.. If an object is serializable with JDK, it should be serializable with FST without any further work.
- preserves links inside the serialized object graph same as JDK default serialization
- custom optimization using annotations, custom serializers
- conditional decoding (skip decoding parts of an object/stream in case)
支持 java 1.7+
- Fast serialization should be adaptable to 1.6 (no use of 1.7 features). A build is here
- FST-structs does require 1.7 API
示例:
// ! reuse this Object, it caches metadata. Performance degrades massively // if you create a new Configuration Object with each serialization ! static FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration(); ... public MyClass myreadMethod(InputStream stream) throws IOException, ClassNotFoundException { FSTObjectInput in = conf.getObjectInput(stream); MyClass result = in.readObject(MyClass.class); // DON'T: in.close(); here prevents reuse and will result in an exception stream.close(); return result; } public void mywriteMethod( OutputStream stream, MyClass toWrite ) throws IOException { FSTObjectOutput out = conf.getObjectOutput(stream); out.writeObject( toWrite, MyClass.class ); // DON'T out.close() when using factory method; out.flush(); stream.close(); }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!