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[]buffprotected FSTConfigurationconfprotected FSTObjectInputinprotected FSTObjectOutputoutprotected HeapBytezreadTargetprotected HeapBytezwriteTarget -
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 FSTConfigurationgetConf()byte[]toByteArray(java.lang.Object o)inttoByteArray(java.lang.Object o, byte[] arr, int startIndex, int availableSize)throws FSTBufferTooSmallExcpetion in case object does not fit into given range Zero Copy methodjava.lang.ObjecttoObject(byte[] arr)decode object into byte array (at position null)java.lang.ObjecttoObject(byte[] arr, int startIndex, int availableSize)throws FSTBufferTooSmallExcpetion in case object does not fit into given range
-
Field Details
-
conf
-
writeTarget
-
readTarget
-
out
-
in
-
buff
protected byte[] buff
-
-
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:
toByteArrayin interfaceFSTCoder- 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:
toByteArrayin interfaceFSTCoder
-
getConf
-
toObject
public java.lang.Object toObject(byte[] arr, int startIndex, int availableSize)throws FSTBufferTooSmallExcpetion in case object does not fit into given range -
toObject
public java.lang.Object toObject(byte[] arr)decode object into byte array (at position null)
-