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
Modifier and TypeFieldDescriptionprotected byte[]
protected FSTConfiguration
protected FSTObjectInput
protected FSTObjectOutput
protected HeapBytez
protected HeapBytez
-
Constructor Summary
ConstructorDescriptionOnHeapCoder
(boolean sharedRefs) OnHeapCoder
(boolean sharedRefs, Class... preregister) OnHeapCoder
(Class... preregister) throw -
Method Summary
Modifier and TypeMethodDescriptiongetConf()
byte[]
int
toByteArray
(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:
toByteArray
in interfaceFSTCoder
- Parameters:
o
-availableSize
-- Returns:
- number of bytes written to the memory region
- Throws:
IOException
-
toByteArray
- Specified by:
toByteArray
in interfaceFSTCoder
-
getConf
-
toObject
throws FSTBufferTooSmallExcpetion in case object does not fit into given range -
toObject
decode object into byte array (at position null)
-