Class OnHeapCoder

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

public class OnHeapCoder
extends java.lang.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 Summary

    Fields 
    Modifier and Type Field Description
    protected byte[] buff  
    protected FSTConfiguration conf  
    protected FSTObjectInput in  
    protected FSTObjectOutput out  
    protected HeapBytez readTarget  
    protected HeapBytez writeTarget  
  • Constructor Summary

    Constructors 
    Constructor Description
    OnHeapCoder()  
    OnHeapCoder​(boolean sharedRefs)  
    OnHeapCoder​(boolean sharedRefs, java.lang.Class... preregister)  
    OnHeapCoder​(java.lang.Class... preregister)
    throw
  • Method Summary

    Modifier and Type Method Description
    FSTConfiguration getConf()  
    byte[] toByteArray​(java.lang.Object o)  
    int toByteArray​(java.lang.Object o, byte[] arr, int startIndex, int availableSize)
    throws FSTBufferTooSmallExcpetion in case object does not fit into given range Zero Copy method
    java.lang.Object toObject​(byte[] arr)
    decode object into byte array (at position null)
    java.lang.Object toObject​(byte[] arr, int startIndex, int availableSize)
    throws FSTBufferTooSmallExcpetion in case object does not fit into given range

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • OnHeapCoder

      public OnHeapCoder()
    • OnHeapCoder

      public OnHeapCoder​(boolean sharedRefs)
    • OnHeapCoder

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

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

    • toByteArray

      public int toByteArray​(java.lang.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:
      java.io.IOException
    • toByteArray

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

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

      public java.lang.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:
      java.lang.Exception
    • toObject

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