Class OnHeapCoder
java.lang.Object
org.nustaq.serialization.simpleapi.OnHeapCoder
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionprotected byte[]protected FSTConfigurationprotected FSTObjectInputprotected FSTObjectOutputprotected HeapBytezprotected HeapBytez -
Constructor Summary
ConstructorsConstructorDescriptionOnHeapCoder(boolean sharedRefs) OnHeapCoder(boolean sharedRefs, Class... preregister) OnHeapCoder(Class... preregister) throw -
Method Summary
Modifier and TypeMethodDescriptiongetConf()byte[]inttoByteArray(Object o, byte[] arr, int startIndex, int availableSize) throws FSTBufferTooSmallExcpetion in case object does not fit into given range Zero Copy methodtoObject(byte[] arr) decode object into byte array (at position null)toObject(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
throw- Parameters:
preregister-
-
OnHeapCoder
-
-
Method Details
-
toByteArray
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:
IOException
-
toByteArray
- Specified by:
toByteArrayin interfaceFSTCoder
-
getConf
-
toObject
throws FSTBufferTooSmallExcpetion in case object does not fit into given range -
toObject
decode object into byte array (at position null)
-