Class GridBinaryMarshaller
- java.lang.Object
-
- org.apache.ignite.internal.binary.GridBinaryMarshaller
-
public class GridBinaryMarshaller extends Object
Binary objects marshaller.
-
-
Field Summary
Fields Modifier and Type Field Description static byteARR_LISTstatic byteBINARY_ENUMBinary enumstatic byteBINARY_OBJstatic byteBOOLEANstatic byteBOOLEAN_ARRstatic byteBYTEstatic byteBYTE_ARRstatic byteCHARstatic byteCHAR_ARRstatic byteCLASSstatic byteCOLstatic byteDATEstatic byteDATE_ARRstatic byteDECIMALstatic byteDECIMAL_ARRstatic byteDFLT_HDR_LENstatic byteDOUBLEstatic byteDOUBLE_ARRstatic byteENUMstatic byteENUM_ARRstatic intFLAGS_POSFlags position in header.static byteFLOATstatic byteFLOAT_ARRstatic byteHANDLEstatic intHASH_CODE_POSstatic byteHASH_MAPstatic byteHASH_SETstatic byteINTstatic byteINT_ARRstatic byteLINKED_HASH_MAPstatic byteLINKED_HASH_SETstatic byteLINKED_LISTstatic byteLONGstatic byteLONG_ARRstatic byteMAPstatic byteNULLstatic byteOBJstatic byteOBJ_ARRstatic intOBJECTstatic byteOPTM_MARSHstatic bytePLATFORM_JAVA_OBJECT_FACTORY_PROXYstatic bytePROTO_VERProtocol version.static intPROTO_VER_POSProtocol version position.static bytePROXYProxy.static intSCHEMA_ID_POSstatic intSCHEMA_OR_RAW_OFF_POSSchema or raw offset position.static byteSHORTstatic byteSHORT_ARRstatic byteSINGLETON_LISTstatic byteSTRINGstatic byteSTRING_ARRstatic byteTIMETime.static byteTIME_ARRTime array.static byteTIMESTAMPTimestamp.static byteTIMESTAMP_ARRTimestamp array.static intTOTAL_LEN_POSstatic byteTRANSFORMEDstatic intTYPE_ID_POSstatic intUNREGISTERED_TYPE_IDstatic ThreadLocal<Boolean>USE_CACHEFlag whether class caching should be used by the current thread.static byteUSER_COLstatic byteUSER_SETstatic byteUUIDstatic byteUUID_ARR
-
Constructor Summary
Constructors Constructor Description GridBinaryMarshaller(BinaryContext ctx)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BinaryContextcontext()<T> Tdeserialize(byte[] arr, @Nullable ClassLoader ldr)<T> Tdeserialize(BinaryInputStream in, @Nullable ClassLoader ldr, @Nullable BinaryReaderHandles hnds)byte[]marshal(@Nullable Object obj, boolean failIfUnregistered)booleanmustDeserialize(Object obj)Whether object must be deserialized anyway.static voidpopContext(@Nullable BinaryContext oldCtx)Pop binary context and restore the old one.BinaryContextpushContext()Push binary context and return the old one.BinaryReaderExImplreader(BinaryInputStream stream)Creates a reader.static BinaryContextthreadLocalContext()<T> Tunmarshal(byte[] bytes, @Nullable ClassLoader clsLdr)<T> Tunmarshal(BinaryInputStream in)BinaryWriterExImplwriter(BinaryOutputStream out)Gets writer for the given output stream.
-
-
-
Field Detail
-
USE_CACHE
public static final ThreadLocal<Boolean> USE_CACHE
Flag whether class caching should be used by the current thread.
-
TRANSFORMED
public static final byte TRANSFORMED
- See Also:
- Constant Field Values
-
OPTM_MARSH
public static final byte OPTM_MARSH
- See Also:
- Constant Field Values
-
BYTE
public static final byte BYTE
- See Also:
- Constant Field Values
-
SHORT
public static final byte SHORT
- See Also:
- Constant Field Values
-
INT
public static final byte INT
- See Also:
- Constant Field Values
-
LONG
public static final byte LONG
- See Also:
- Constant Field Values
-
FLOAT
public static final byte FLOAT
- See Also:
- Constant Field Values
-
DOUBLE
public static final byte DOUBLE
- See Also:
- Constant Field Values
-
CHAR
public static final byte CHAR
- See Also:
- Constant Field Values
-
BOOLEAN
public static final byte BOOLEAN
- See Also:
- Constant Field Values
-
DECIMAL
public static final byte DECIMAL
- See Also:
- Constant Field Values
-
STRING
public static final byte STRING
- See Also:
- Constant Field Values
-
UUID
public static final byte UUID
- See Also:
- Constant Field Values
-
DATE
public static final byte DATE
- See Also:
- Constant Field Values
-
BYTE_ARR
public static final byte BYTE_ARR
- See Also:
- Constant Field Values
-
SHORT_ARR
public static final byte SHORT_ARR
- See Also:
- Constant Field Values
-
INT_ARR
public static final byte INT_ARR
- See Also:
- Constant Field Values
-
LONG_ARR
public static final byte LONG_ARR
- See Also:
- Constant Field Values
-
FLOAT_ARR
public static final byte FLOAT_ARR
- See Also:
- Constant Field Values
-
DOUBLE_ARR
public static final byte DOUBLE_ARR
- See Also:
- Constant Field Values
-
CHAR_ARR
public static final byte CHAR_ARR
- See Also:
- Constant Field Values
-
BOOLEAN_ARR
public static final byte BOOLEAN_ARR
- See Also:
- Constant Field Values
-
DECIMAL_ARR
public static final byte DECIMAL_ARR
- See Also:
- Constant Field Values
-
STRING_ARR
public static final byte STRING_ARR
- See Also:
- Constant Field Values
-
UUID_ARR
public static final byte UUID_ARR
- See Also:
- Constant Field Values
-
DATE_ARR
public static final byte DATE_ARR
- See Also:
- Constant Field Values
-
OBJ_ARR
public static final byte OBJ_ARR
- See Also:
- Constant Field Values
-
COL
public static final byte COL
- See Also:
- Constant Field Values
-
MAP
public static final byte MAP
- See Also:
- Constant Field Values
-
BINARY_OBJ
public static final byte BINARY_OBJ
- See Also:
- Constant Field Values
-
ENUM
public static final byte ENUM
- See Also:
- Constant Field Values
-
ENUM_ARR
public static final byte ENUM_ARR
- See Also:
- Constant Field Values
-
CLASS
public static final byte CLASS
- See Also:
- Constant Field Values
-
TIMESTAMP
public static final byte TIMESTAMP
Timestamp.- See Also:
- Constant Field Values
-
TIMESTAMP_ARR
public static final byte TIMESTAMP_ARR
Timestamp array.- See Also:
- Constant Field Values
-
PROXY
public static final byte PROXY
Proxy.- See Also:
- Constant Field Values
-
TIME
public static final byte TIME
Time.- See Also:
- Constant Field Values
-
TIME_ARR
public static final byte TIME_ARR
Time array.- See Also:
- Constant Field Values
-
BINARY_ENUM
public static final byte BINARY_ENUM
Binary enum- See Also:
- Constant Field Values
-
NULL
public static final byte NULL
- See Also:
- Constant Field Values
-
HANDLE
public static final byte HANDLE
- See Also:
- Constant Field Values
-
OBJ
public static final byte OBJ
- See Also:
- Constant Field Values
-
USER_SET
public static final byte USER_SET
- See Also:
- Constant Field Values
-
USER_COL
public static final byte USER_COL
- See Also:
- Constant Field Values
-
ARR_LIST
public static final byte ARR_LIST
- See Also:
- Constant Field Values
-
LINKED_LIST
public static final byte LINKED_LIST
- See Also:
- Constant Field Values
-
HASH_SET
public static final byte HASH_SET
- See Also:
- Constant Field Values
-
LINKED_HASH_SET
public static final byte LINKED_HASH_SET
- See Also:
- Constant Field Values
-
SINGLETON_LIST
public static final byte SINGLETON_LIST
- See Also:
- Constant Field Values
-
HASH_MAP
public static final byte HASH_MAP
- See Also:
- Constant Field Values
-
LINKED_HASH_MAP
public static final byte LINKED_HASH_MAP
- See Also:
- Constant Field Values
-
PLATFORM_JAVA_OBJECT_FACTORY_PROXY
public static final byte PLATFORM_JAVA_OBJECT_FACTORY_PROXY
- See Also:
- Constant Field Values
-
OBJECT
public static final int OBJECT
- See Also:
- Constant Field Values
-
UNREGISTERED_TYPE_ID
public static final int UNREGISTERED_TYPE_ID
- See Also:
- Constant Field Values
-
PROTO_VER
public static final byte PROTO_VER
Protocol version.- See Also:
- Constant Field Values
-
PROTO_VER_POS
public static final int PROTO_VER_POS
Protocol version position.- See Also:
- Constant Field Values
-
FLAGS_POS
public static final int FLAGS_POS
Flags position in header.- See Also:
- Constant Field Values
-
TYPE_ID_POS
public static final int TYPE_ID_POS
- See Also:
- Constant Field Values
-
HASH_CODE_POS
public static final int HASH_CODE_POS
- See Also:
- Constant Field Values
-
TOTAL_LEN_POS
public static final int TOTAL_LEN_POS
- See Also:
- Constant Field Values
-
SCHEMA_ID_POS
public static final int SCHEMA_ID_POS
- See Also:
- Constant Field Values
-
SCHEMA_OR_RAW_OFF_POS
public static final int SCHEMA_OR_RAW_OFF_POS
Schema or raw offset position.- See Also:
- Constant Field Values
-
DFLT_HDR_LEN
public static final byte DFLT_HDR_LEN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GridBinaryMarshaller
public GridBinaryMarshaller(BinaryContext ctx)
- Parameters:
ctx- Context.
-
-
Method Detail
-
marshal
public byte[] marshal(@Nullable @Nullable Object obj, boolean failIfUnregistered) throws BinaryObjectException- Parameters:
obj- Object to marshal.failIfUnregistered- Throw exception if class isn't registered.- Returns:
- Byte array.
- Throws:
BinaryObjectException- In case of error.
-
unmarshal
@Nullable public <T> T unmarshal(byte[] bytes, @Nullable @Nullable ClassLoader clsLdr) throws BinaryObjectException- Parameters:
bytes- Bytes array.- Returns:
- Binary object.
- Throws:
BinaryObjectException- In case of error.
-
unmarshal
@Nullable public <T> T unmarshal(BinaryInputStream in) throws BinaryObjectException
- Parameters:
in- Input stream.- Returns:
- Binary object.
- Throws:
BinaryObjectException- In case of error.
-
deserialize
@Nullable public <T> T deserialize(byte[] arr, @Nullable @Nullable ClassLoader ldr) throws BinaryObjectException- Parameters:
arr- Byte array.ldr- Class loader.- Returns:
- Deserialized object.
- Throws:
BinaryObjectException- In case of error.
-
deserialize
@Nullable public <T> T deserialize(BinaryInputStream in, @Nullable @Nullable ClassLoader ldr, @Nullable @Nullable BinaryReaderHandles hnds) throws BinaryObjectException
- Parameters:
in- Input stream.ldr- Class loader.hnds- Handles.- Returns:
- Deserialized object.
- Throws:
BinaryObjectException- In case of error.
-
pushContext
public BinaryContext pushContext()
Push binary context and return the old one.- Returns:
- Old binary context.
-
popContext
public static void popContext(@Nullable @Nullable BinaryContext oldCtx)Pop binary context and restore the old one.- Parameters:
oldCtx- Old binary context.
-
reader
public BinaryReaderExImpl reader(BinaryInputStream stream)
Creates a reader.- Parameters:
stream- Stream.- Returns:
- Reader.
-
mustDeserialize
public boolean mustDeserialize(Object obj)
Whether object must be deserialized anyway. I.e. it cannot be converted to BinaryObject.- Parameters:
obj- Object.- Returns:
Trueif object will be deserialized on unmarshal.
-
writer
public BinaryWriterExImpl writer(BinaryOutputStream out)
Gets writer for the given output stream.- Parameters:
out- Output stream.- Returns:
- Writer.
-
context
public BinaryContext context()
- Returns:
- Context.
-
threadLocalContext
public static BinaryContext threadLocalContext()
- Returns:
- Thread-bound context.
-
-