Class OffHeapCoder

java.lang.Object
org.nustaq.serialization.simpleapi.OffHeapCoder

public class OffHeapCoder
extends java.lang.Object
Created by ruedi on 09.11.14. enables zero copy encoding to offheap memory. The encoding is platform dependent (endianess) and no attemps on compression are made. Use case: messaging, offheap en/decoding, tmp preservation of state NOT thread safe Future version may choose to operate on DirectByteBuffer in case unsafe class vanishes Do not confuse this with a stream. Each single writeObject is an isolated operation, so restoring of references inside an object graph only happens for refs inside the object graph given to writeObject. *********************************************************************** USE ONLY IF DEFAULTCODER (no unsafe) HAS BEEN PROVEN TO SLOW YOU DOWN. *********************************************************************** Note this does not satisfy the FSTCoder interface. Its purely targeted to directly read/write native memory allocates using unsafe.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected FSTConfiguration conf  
  • Constructor Summary

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

    Modifier and Type Method Description
    int toMemory​(java.lang.Object o, long address, int availableSize)
    throws FSTBufferTooSmallException in case object does not fit into given range
    java.lang.Object toObject​(long address, int availableSize)  

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • OffHeapCoder

      public OffHeapCoder()
    • OffHeapCoder

      public OffHeapCoder​(boolean sharedRefs)
    • OffHeapCoder

      public OffHeapCoder​(boolean sharedRefs, java.lang.Class... preregister)
      throw
      Parameters:
      preregister -
    • OffHeapCoder

      public OffHeapCoder​(java.lang.Class... preregister)
  • Method Details

    • toMemory

      public int toMemory​(java.lang.Object o, long address, int availableSize) throws java.io.IOException
      throws FSTBufferTooSmallException in case object does not fit into given range
      Parameters:
      o -
      address -
      availableSize -
      Returns:
      number of bytes written to the memory region
      Throws:
      java.io.IOException
    • toObject

      public java.lang.Object toObject​(long address, int availableSize) throws java.io.IOException, java.lang.ClassNotFoundException
      Throws:
      java.io.IOException
      java.lang.ClassNotFoundException