Interface StorableBuffer


public interface StorableBuffer
It's useful to return this object when multiple serializable objects are to be composed into a single ByteBuffer or byte[]. This allows serializable objects to report their size so that callers may get the total size of all objects and allocate a sufficiently large ByteBuffer/byte[]. Then the store() methods may be used to serialize.

This avoids extra copies and wasted memory/gc pressure in the case of just returning a byte[].

The getSerializedSize() method is provided because an object may need to use private data in order to calculate the size needed.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final StorableBuffer
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    void
    store(ByteBuffer byteBuffer)
     
  • Field Details

  • Method Details

    • store

      void store(ByteBuffer byteBuffer)
    • getSerializedSize

      int getSerializedSize()