Class DataClaySerializationLib


  • public final class DataClaySerializationLib
    extends Object
    Serialization library.
    • Field Detail

      • DEBUG_ENABLED

        public static final boolean DEBUG_ENABLED
        Indicates if debug is enabled.
      • LOGGER

        public static final org.apache.logging.log4j.Logger LOGGER
        Logger.
    • 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 serialize
        ignoreUserTypes - 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 use
        curSerializedObjs - 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 return
        it - 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 - DCObject
        clientLib - Client lib
        ignoreUserTypes - Indicates if user types inside the instance must be ignored or not
        ifaceBitMaps - Interface bitmaps.
        curIt - Pending objects
        forUpdate - Indicates whether this serialization is for an update or not
        hint - Hint to set
        forcePendingToRegister - 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 wrappers
        ifaceBitMaps - 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 operation
        hint - Hint to set in volatiles
        ignoreSubObjects - 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/update
        objectMetaData - Object metadata
        theBytes - Serialized bytes
        isStore - 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 serialize
        ignoreUserTypes - Indicates if user types must be ignored
        ifaceBitMaps - Iface bitmaps
        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:
        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 wrapper
        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.
      • serializeReferenceCounting

        public static void serializeReferenceCounting​(DataClayObject dcObject,
                                                      DataClayByteBuffer dcBuffer,
                                                      ReferenceCounting referenceCounting)
        Serialize reference counting
        Parameters:
        dcObject - object being serialized with ref. counting
        dcBuffer - Buffer in which to write bytes.
        referenceCounting - Reference counting from this object.