Class OnHeapCoder

java.lang.Object
org.nustaq.serialization.simpleapi.OnHeapCoder
All Implemented Interfaces:
FSTCoder

public class OnHeapCoder extends Object implements FSTCoder
Created by ruedi on 13.11.14. A coder writing fast binary encoding using unsafe to an underlying byte array ZERO COPY. Future version may choose to operate on DirectByteBuffer in case unsafe vanishes Note there is some copied code from OffHeaüCoder to avoid losing performance caused by polymorphic method dispatch. *********************************************************************** USE ONLY IF DEFAULTCODER (no unsafe) HAS BEEN PROVEN TO SLOW YOU DOWN. ***********************************************************************
  • Field Details

  • Constructor Details

    • OnHeapCoder

      public OnHeapCoder()
    • OnHeapCoder

      public OnHeapCoder(boolean sharedRefs)
    • OnHeapCoder

      public OnHeapCoder(Class... preregister)
      throw
      Parameters:
      preregister -
    • OnHeapCoder

      public OnHeapCoder(boolean sharedRefs, Class... preregister)
  • Method Details

    • toByteArray

      public int toByteArray(Object o, byte[] arr, int startIndex, int availableSize)
      throws FSTBufferTooSmallExcpetion in case object does not fit into given range Zero Copy method
      Specified by:
      toByteArray in interface FSTCoder
      Parameters:
      o -
      availableSize -
      Returns:
      number of bytes written to the memory region
      Throws:
      IOException
    • toByteArray

      public byte[] toByteArray(Object o)
      Specified by:
      toByteArray in interface FSTCoder
    • getConf

      public FSTConfiguration getConf()
      Specified by:
      getConf in interface FSTCoder
    • toObject

      public Object toObject(byte[] arr, int startIndex, int availableSize)
      throws FSTBufferTooSmallExcpetion in case object does not fit into given range
      Specified by:
      toObject in interface FSTCoder
      Parameters:
      arr -
      startIndex -
      availableSize -
      Returns:
      Throws:
      Exception
    • toObject

      public Object toObject(byte[] arr)
      decode object into byte array (at position null)
      Specified by:
      toObject in interface FSTCoder
      Parameters:
      arr -
      Returns:
      Throws:
      Exception