Class DataClaySerializationLib
- java.lang.Object
-
- es.bsc.dataclay.serialization.lib.DataClaySerializationLib
-
public final class DataClaySerializationLib extends Object
Serialization library.
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEBUG_ENABLED
Indicates if debug is enabled.static org.apache.logging.log4j.Logger
LOGGER
Logger.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DataClayByteArray
createBufferAndSerialize(DataClaySerializable instance, boolean ignoreUserTypes, Map<MetaClassID,byte[]> ifaceBitMaps, IdentityHashMap<Object,Integer> curSerializedObjs, ListIterator<DataClayObject> pendingObjs, boolean returnNullIfNoRefCounting)
Create buffer and serializestatic void
serializeAssociation(DataClayObject element, DataClayByteBuffer dcBuffer, boolean ignoreUserTypes, Map<MetaClassID,byte[]> ifaceBitMaps, IdentityHashMap<Object,Integer> curSerializedObjs, ListIterator<DataClayObject> pendingObjs, ReferenceCounting referenceCounting)
Serialize association to another user type.static ObjectWithDataParamOrReturn
serializeDataClayObjectWithData(DataClayObject dcObject, DataClayRuntime clientLib, boolean ignoreUserTypes, Map<MetaClassID,byte[]> ifaceBitMaps, ListIterator<DataClayObject> curIt, boolean forUpdate, BackendID hint, boolean forcePendingToRegister)
Serialize DataClayObject with data.static byte[]
serializeForDB(ObjectID objectID, DataClayObjectMetaData objectMetaData, DataClayByteArray theBytes, boolean isStore)
Serialize for DBstatic byte[]
serializeForDBGarbageCollection(DataClayExecutionObject instance, boolean ignoreUserTypes, Map<MetaClassID,byte[]> ifaceBitMaps, boolean returnNullIfNoRefCounting)
Serialize for DBstatic void
serializeJavaField(DataClayJavaWrapper wrapper, DataClayByteBuffer dcBuffer, boolean ignoreUserTypes, Map<MetaClassID,byte[]> ifaceBitMaps, IdentityHashMap<Object,Integer> curSerializedObjs, ListIterator<DataClayObject> pendingObjs, ReferenceCounting referenceCounting)
Serialize java field.static DataClayByteArray
serializeParameterOrReturn(DataClaySerializable paramReturn, ListIterator<DataClayObject> it)
Serialize parameter or returnstatic SerializedParametersOrReturn
serializeParamsOrReturn(List<DataClaySerializable> wrappedParamsOrRet, Map<MetaClassID,byte[]> ifaceBitMaps, DataClayRuntime runtime, boolean forUpdate, BackendID hint, boolean ignoreSubObjects)
Serialize parameters or return of an executionstatic void
serializeReferenceCounting(DataClayObject dcObject, DataClayByteBuffer dcBuffer, ReferenceCounting referenceCounting)
Serialize reference counting
-
-
-
Method Detail
-
createBufferAndSerialize
public static DataClayByteArray createBufferAndSerialize(DataClaySerializable instance, boolean ignoreUserTypes, Map<MetaClassID,byte[]> ifaceBitMaps, IdentityHashMap<Object,Integer> curSerializedObjs, ListIterator<DataClayObject> pendingObjs, boolean returnNullIfNoRefCounting)
Create buffer and serialize- Parameters:
instance
- Instance to serializeignoreUserTypes
- Indicates if user types found during serialization must be ignored or not (for instance, non recursive make persistent)ifaceBitMaps
- Map of bitmaps representing the interfaces to usecurSerializedObjs
- Current serialized objects Object -> OID tag. This structure must be different during each serialization since OID tags are not shared.pendingObjs
- Pending objs.returnNullIfNoRefCounting
- If true, return null if object does not reference any other object except language object. This is useful during GC of not dirty objects without references.- Returns:
- Byte array.
-
serializeParameterOrReturn
public static DataClayByteArray serializeParameterOrReturn(DataClaySerializable paramReturn, ListIterator<DataClayObject> it)
Serialize parameter or return- Parameters:
paramReturn
- parameter or returnit
- Iterator in which to add found objects- Returns:
- Byte array containing serialization.
-
serializeDataClayObjectWithData
public static ObjectWithDataParamOrReturn serializeDataClayObjectWithData(DataClayObject dcObject, DataClayRuntime clientLib, boolean ignoreUserTypes, Map<MetaClassID,byte[]> ifaceBitMaps, ListIterator<DataClayObject> curIt, boolean forUpdate, BackendID hint, boolean forcePendingToRegister)
Serialize DataClayObject with data.- Parameters:
dcObject
- DCObjectclientLib
- Client libignoreUserTypes
- Indicates if user types inside the instance must be ignored or notifaceBitMaps
- Interface bitmaps.curIt
- Pending objectsforUpdate
- Indicates whether this serialization is for an update or nothint
- Hint to setforcePendingToRegister
- If TRUE, object is going to be set as pending to register. Take into account that this function is also called to serialize objects in 'moves','replicas',... and in that case this parameter must be FALSE to avoid overriding the actual value of the instance (actual pending or not).- Returns:
- The serialization of the given object
-
serializeParamsOrReturn
public static SerializedParametersOrReturn serializeParamsOrReturn(List<DataClaySerializable> wrappedParamsOrRet, Map<MetaClassID,byte[]> ifaceBitMaps, DataClayRuntime runtime, boolean forUpdate, BackendID hint, boolean ignoreSubObjects)
Serialize parameters or return of an execution- Parameters:
wrappedParamsOrRet
- Parameters or return to serialize in wrappersifaceBitMaps
- Interface bitmaps (for Client - DS communication)runtime
- Runtime, to lock serialization of volatiles and find new volatiles.forUpdate
- Indicates whether this serialization is for an update operationhint
- Hint to set in volatilesignoreSubObjects
- Indicates if sub-objects must be ignored. Only for make persistent.- Returns:
- Serialized parameters or return
-
serializeForDB
public static byte[] serializeForDB(ObjectID objectID, DataClayObjectMetaData objectMetaData, DataClayByteArray theBytes, boolean isStore)
Serialize for DB- Parameters:
objectID
- ID of object to store/updateobjectMetaData
- Object metadatatheBytes
- Serialized bytesisStore
- Serializing for a store (not update) or not.- Returns:
- Serialized bytes
-
serializeForDBGarbageCollection
public static byte[] serializeForDBGarbageCollection(DataClayExecutionObject instance, boolean ignoreUserTypes, Map<MetaClassID,byte[]> ifaceBitMaps, boolean returnNullIfNoRefCounting)
Serialize for DB- Parameters:
instance
- Object to serializeignoreUserTypes
- Indicates if user types must be ignoredifaceBitMaps
- Iface bitmapsreturnNullIfNoRefCounting
- If true, return null if object does not reference any other object except language object. This is useful during GC of not dirty objects without references.- Returns:
- Serialized bytes
-
serializeAssociation
public static void serializeAssociation(DataClayObject element, DataClayByteBuffer dcBuffer, boolean ignoreUserTypes, Map<MetaClassID,byte[]> ifaceBitMaps, IdentityHashMap<Object,Integer> curSerializedObjs, ListIterator<DataClayObject> pendingObjs, ReferenceCounting referenceCounting)
Serialize association to another user type.- Parameters:
element
- Element association.dcBuffer
- Buffer in which to write bytes.ignoreUserTypes
- IgnoreUserTypes flag.ifaceBitMaps
- Interface bitmaps.curSerializedObjs
- Current serialized objects (see Serialization mechanism doc.)pendingObjs
- Pending objects (see Serialization mechanism doc.)referenceCounting
- Reference counting from this object.
-
serializeJavaField
public static void serializeJavaField(DataClayJavaWrapper wrapper, DataClayByteBuffer dcBuffer, boolean ignoreUserTypes, Map<MetaClassID,byte[]> ifaceBitMaps, IdentityHashMap<Object,Integer> curSerializedObjs, ListIterator<DataClayObject> pendingObjs, ReferenceCounting referenceCounting)
Serialize java field.- Parameters:
wrapper
- Java type inside a DataClayObject wrapperdcBuffer
- Buffer in which to write bytes.ignoreUserTypes
- IgnoreUserTypes flag.ifaceBitMaps
- Interface bitmaps.curSerializedObjs
- Current serialized objects (see Serialization mechanism doc.)pendingObjs
- Pending objects (see Serialization mechanism doc.)referenceCounting
- Reference counting from this object.
-
serializeReferenceCounting
public static void serializeReferenceCounting(DataClayObject dcObject, DataClayByteBuffer dcBuffer, ReferenceCounting referenceCounting)
Serialize reference counting- Parameters:
dcObject
- object being serialized with ref. countingdcBuffer
- Buffer in which to write bytes.referenceCounting
- Reference counting from this object.
-
-