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 FSTConfigurationconf -
Constructor Summary
Constructors Constructor Description OffHeapCoder()OffHeapCoder(boolean sharedRefs)OffHeapCoder(boolean sharedRefs, java.lang.Class... preregister)throwOffHeapCoder(java.lang.Class... preregister) -
Method Summary
-
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.IOExceptionthrows 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.IOExceptionjava.lang.ClassNotFoundException
-