快速序列化Java開源庫,Fast-serialization 2.18 發布

jopen 9年前發布 | 19K 次閱讀 FST

FST fast-serialization重新實現的Java序列化,注重速度,大小和兼容性。使用FST代替原有功能,只需要修復很少的代碼。

項目地址:http://ruedigermoeller.github.io/fast-serialization/

特性:

  • 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
  • supports versioning (2.x only)
  • conditional decoding (skip decoding parts of an object/stream in case)
  • </ul>

    支持 java 1.7+ (fst 1.62: JDK 1.6)

    • fst 1.x is jdk 1.6 compatible (no use of 1.7 features). I backport 2.x fixes from time to time or upon request
    • FST-structs does require 1.7 API
    • </ul>

      示例:

      // ! 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(); }</pre>
      FST 2.18 發布了,從 2.17 版本開始 FST 的許可證由原來的 LGPL 改為 Apache。

      與 2.16 版本比較,其他改進包括:

      • Wavesonics contributed an android port (only plain serialization tested). Merged this to keep a single branch. For android a different object instantiation strategy is used. Adds a dependency to objenesis-2.1

      • fixed 2.x structs (for fast-cast 3.0). Had some issues because of low test coverage. Writing unit tests for structs still open.

      • </ul>

        Bug 修復:

        • changes done from 1.x to 2.x introduced an unnecessary perf degradation when reading from byte[]. Affects small objects most. fixed.

        • kson supports thousand separator in numbers '_'

        • fixed stackoverflow on some android devices with smallish stack sizes

        • fixed a buffer overflow reading externalizables when using fastBinaryConfiguration

        • </ul>

           本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
           轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
           本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!