Serialization method, deserialization method, device, chip and medium
By using the first-level singly linked list for data serialization and deserialization on the SOC platform, the problem of data serialization efficiency and memory usage of existing tools in SRAM-limited environments is solved, and efficient data processing and memory saving are achieved.
Patent Information
- Application Number
- CN202011364246.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-27
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-11-27
AI Technical Summary
Existing data serialization tools such as FlatBuffer have large code sizes due to code versatility and structural complexity, and cannot be effectively used on SRAM-limited SOC platforms. After serialization, the data size increases significantly and takes up too much memory.
By using the first-level singly linked list to store and map data structures, serialization efficiency and speed are improved, and the data storage design is simplified during the deserialization process, controlling the code size of serialized data and reducing memory usage.
On SRAM's precious SOC platform, efficient data serialization and deserialization are achieved, reducing memory requirements, especially only about 5K of memory during the deserialization process.
Smart Images

Figure CN114564509B
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the field of communications, and more specifically, to a serialization method, a deserialization method, a device, a chip, and a medium. Background Art
[0002] So far, the main storage tool for data serialization is a cross-platform serialization framework released by Google, namely FlatBuffer. FlatBuffer can store the data hierarchy in a flat binary cache, while maintaining direct access to the structured data inside without parsing, and can also ensure forward and backward compatibility of data structure changes. Its cross-platform feature is widely used by software developers.
[0003] However, due to the common characteristics of its code and the complexity of its structure, its code size is relatively large. For example, the code size of the dynamic (runtime) library of flatbuffer is about 170K, while the static random access memory (SRAM) of the system on chip (SOC) platform usually has only tens to hundreds of KB of space. In addition to the operating system (OS) and the driver, there is not much memory space left for other functions. Therefore, the SOC platform cannot meet the memory requirements of flatbuffer. In addition, after the data is serialized based on flatbuffer, the size (SIZE) of the original data will increase a lot. For example, a piece of binary data of about 70K will increase to nearly 700K after being serialized using flatbuffer.
[0004] Therefore, for SOC platforms where SRAM is particularly valuable, a method for data serialization and data deserialization is urgently needed. Summary of the invention
[0005] Provided are a serialization method, a deserialization method, a device, a chip, and a medium. During the serialization process, the serialization efficiency or speed can be improved. During the deserialization process, the code size of the serialized data can be controlled and the memory occupation or demand can be reduced. The method is particularly suitable for a SOC platform where SRAM is particularly valuable.
[0006] In a first aspect, a serialization method is provided, comprising:
[0007] Acquire a data structure to be serialized, the data structure comprising at least one data item;
[0008] Acquire a first-level singly linked list corresponding to the data structure; the first-level singly linked list includes a first node, the first node is used to represent storage information of data of a first data item in the at least one data item, or the first node is used to represent storage information of a secondary singly linked list corresponding to the first data item;
[0009] The data of the first-level single linked list and the data structure are stored in the first memory area and the second memory area respectively.
[0010] In a second aspect, a deserialization method is provided, including:
[0011] Get serialized data;
[0012] Mapping the data of the first-level singly linked list and at least one data item in the serialized data to the third memory area and the fourth memory area respectively; the first-level singly linked list includes a first node, the first node is used to represent the storage information of the data of the first data item in the at least one data item, or the first node is used to represent the storage information of the secondary singly linked list corresponding to the first data item;
[0013] Based on the nodes in the first-level singly linked list, data of the at least one data item is acquired to obtain a data structure.
[0014] In a third aspect, a device is provided for executing the method in the first aspect or its implementations. Specifically, the device includes a functional module for executing the method in the first aspect or its implementations.
[0015] In a fourth aspect, a device is provided for executing the method in the second aspect or its implementations. Specifically, the device includes a functional module for executing the method in the second aspect or its implementations.
[0016] In a fifth aspect, a communication device is provided, comprising a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the method in the first aspect or its implementation manners.
[0017] In a sixth aspect, a communication device is provided, comprising a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the method in the second aspect or its implementation manners.
[0018] In a seventh aspect, a chip is provided for implementing the method in any one of the first to second aspects or their respective implementations. Specifically, the chip includes: a processor for calling and running a computer program from a memory, so that a device equipped with the chip executes the method in any one of the first to second aspects or their respective implementations.
[0019] In an eighth aspect, a computer-readable storage medium is provided for storing a computer program, wherein the computer program enables a computer to execute the method of any one of the first to second aspects or any of their implementations.
[0020] Based on the above technical solution, the first node in the first-level single linked list represents the storage information of the data of the first data item in the at least one data item or the storage information of the secondary single linked list corresponding to the first data item. On the one hand, the storage information of the data of the at least one data item can be stored as a whole, thereby improving the serialization efficiency or speed. On the other hand, during the deserialization process, the design of the storage information of the data of the at least one data item can be simplified through the first-level single linked list. Accordingly, the code size of the serialized data can be controlled and the memory occupancy or demand can be reduced, which is particularly suitable for SOC platforms where SRAM is particularly valuable.
[0021] For example, during the deserialization process, the memory requirement of the deserialization tool can be reduced, for example, only about 5K of memory is required. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a schematic block diagram of the serialization system framework provided in an embodiment of the present application.
[0023] Figure 2 It is a schematic block diagram of the deserialization system framework provided in an embodiment of the present application.
[0024] Figure 3 It is a schematic flow chart of the serialization method of an embodiment of the present application.
[0025] Figure 4 It is a schematic structural diagram of the relationship between nodes and data in an embodiment of the present application.
[0026] Figure 5 It is a schematic flow chart of the deserialization method provided in an embodiment of the present application.
[0027] Figure 6 It is a schematic flowchart of serialization and deserialization provided in an embodiment of the present application.
[0028] Figure 7 and Figure 8It is a schematic block diagram of the device provided in an embodiment of the present application.
[0029] Fig. 9 It is a schematic block diagram of a communication device provided in an embodiment of the present application.
[0030] Fig.10 It is a schematic block diagram of the chip provided in the embodiment of the present application. DETAILED DESCRIPTION
[0031] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0032] The emergence of the Internet has brought about the need for communication between machines, and the two parties in the interconnected communication need to adopt an agreed protocol. Serialization and deserialization are part of the communication protocol. The communication protocol can adopt a layered model, and the functional definition and granularity of the layers of different models can be different. For example, the TCP / IP protocol is a four-layer protocol, while the OSI model is a seven-layer protocol model. In the OSI seven-layer protocol model, the main function of the presentation layer is to convert the data structure of the application layer into a continuous binary string, or vice versa, to convert the binary string into the data structure of the application layer. The function of the presentation layer is serialization and deserialization.
[0033] The application layer of the TCP / IP protocol can correspond to the application layer, presentation layer and session layer of the OSI seven-layer protocol model. In other words, serialization and deserialization can also be understood as part of the functions of the application layer of the TCP / IP protocol.
[0034] Serialization can refer to the process of converting a data structure into a binary string. The binary string generated by serialization refers to a piece of data stored in memory. It should be noted that data structure and object can be used interchangeably in this application. In addition, string (String) is a first-class citizen of Java and a special object (Object), that is, it is also a data structure. For cross-language communication, the serialized data cannot be a special data type of a certain language. Binary string in Java refers to bytes (byte). In addition, the behavior of serialization may occur at any stage of the data transmission process, such as network transmission, data transmission between different processes, parameter transmission between different classes, storing data on disk, etc.
[0035] Deserialization may refer to the process of converting a binary string generated during serialization into a data structure.
[0036] Serialization requires adding description fields or domains to the original data to facilitate deserialization and parsing.
[0037] It should be noted that the data serialization process takes place on laptops / desktops, etc., and in this process, you don't need to worry about the memory consumption of the serialization tool. The data deserialization stage takes place inside the SOC, that is, the data serialized by the host platform is parsed for its own use, so this process will pay more attention to the memory consumption of the deserialization tool.
[0038] If the additional overhead introduced by the serialization process is too high, it may cause excessive pressure on the network, disk, etc. For massive distributed storage systems, the amount of data is often measured in TB, and the huge additional space overhead means high costs.
[0039] The present application provides a serialization method and a deserialization method that can reduce memory consumption.
[0040] Figure 1 It is a schematic block diagram of the serialization system framework 110 provided in an embodiment of the present application.
[0041] like Figure 1 As shown, the serialization system framework 110 may include a parsing module 111 , a single linked list building module 112 , a data saving module 113 and a memory management module 114 .
[0042] The serialized system framework 110 may be various types of devices with computing functions. For example, the system framework 110 may be a personal computer (PC), that is, the system framework 110 may be a multi-purpose computer with a size, price, and performance suitable for personal use. For example, the personal computer may be a laptop, a desktop, a small notebook computer, a tablet computer, an ultrabook, etc. For example, the serialized system framework 110 may be a distributed system client.
[0043] The parsing module 111 is used to receive data at the application layer and parse the data at the application layer to generate a data structure (struct).
[0044] In other words, the data structure output by the parsing module 111 can be used as input data of the serialization method provided by the present application. The data structure can be used by the single linked list building module 112 and the data saving module 113.
[0045] The single linked list creation module 112 may be used to output an index node representing storage information of data of the data structure based on the data structure output by the parsing module 111 .
[0046] The data storage module 113 may be used to store the data of the index node and the data structure.
[0047] It should be noted that the data of the data structure can be of any data type, and the memory alignment principle needs to be met when storing the data of the data structure. For example, string data can be 1-byte aligned. For another example, int integer data and structure data need to be aligned based on a preset number of bytes. For example, the preset number of bytes includes 4 bytes or 8 bytes.
[0048] The memory management module 114 may be used to allocate or apply for memory for the index node and the data structure. For example, the memory may be applied for memory for the single linked list creation module 112 and the data storage module 113 respectively. For example, the memory management module 114 may be used to allocate or apply for two blocks of memory. One of the two blocks of memory may be used to store the index node, and the other of the two blocks of memory may be used to store data continuously.
[0049] For example, the memory management module 114 can be used to pre-allocate a large continuous memory for subsequent continuous storage of index nodes and data structure data. It should be noted that the memory management module 114 can apply for or allocate scattered memory or continuous memory for the single linked list creation module 112. If it is continuous memory, it is convenient to serialize the data structure, and it is also conducive to saving and restoring the data structure.
[0050] In addition, the memory management module 114 may be used to save the data of the data structure and the index node as serialized data, and the serialized data may also be referred to as a binary file.
[0051] Figure 2 It is a schematic block diagram of the deserialization system framework 120 provided in an embodiment of the present application.
[0052] like Figure 2 As shown, the deserialization system framework 120 may include a memory mapping module 121 , a parsing module 122 , and a data access module 123 .
[0053] The deserialization system framework 120 may be a chip-level system, which may also be called a system on chip (System On Chip, SOC). The chip-level system may be a product or an integrated circuit with a dedicated target, and the product or integrated circuit includes a complete system and all the contents of the embedded software. For example, the system chip may be an NPU AI chip.
[0054] The memory mapping module 121 can map the serialized data output by the serialization system framework 110 to the memory inside the chip-level system (System On Chip, SOC) as a whole. For example, the memory mapping module 121 can map the serialized data output by the serialization system framework 110 as a whole to the double data rate synchronous dynamic random access memory (Double Data Rate SDRAM, DDR SDRAM) of the SOC. The space of the DDR SDRAM is much larger than that of the static random access memory (static RAM, SRAM) to ensure that the SOC has sufficient capacity to map the data structure.
[0055] The parsing module 122 may be used to parse the serialized data to obtain the index nodes of the data structure. For example, the parsing module 122 may restore each index node based on the definition of the index node, and then restore the information of all nodes in the single linked list.
[0056] The data access module 123 may parse or access the data of the structure based on the index nodes acquired by the parsing module 122 and the definition of the index nodes to complete the deserialization of the serialized data.
[0057] It should be noted that the serialization system framework 110 and the deserialization system framework 120 can communicate with each other. For example, the serialization data output by the serialization system framework 110 can be converted into digital signals through the underlying transport layer, network layer, link layer and physical layer protocols and transmitted to the deserialization system framework 120 on the Internet.
[0058] Figure 3 1 shows a schematic flow chart of a serialization method 200 according to an embodiment of the present application, and the method 200 can be performed by a serialization device. For example, Figure 1 A serialization system framework 110 is shown.
[0059] like Figure 3 As shown, the method 200 may include some or all of the following contents:
[0060] S210, obtaining a data structure to be serialized, the data structure including at least one data item;
[0061] S220, obtaining a first-level singly linked list corresponding to the data structure; the first-level singly linked list includes a first node, the first node is used to represent storage information of data of a first data item in the at least one data item, or the first node is used to represent storage information of a secondary singly linked list corresponding to the first data item;
[0062] S230, storing the data of the first-level single linked list and the data structure in the first memory area and the second memory area respectively.
[0063] It should be noted that the first node may be an index node for representing data of the first data item. In other words, the first memory area may be an index area, and the second memory area may also be called a data area. Optionally, the first memory area and the second memory area are continuous memory areas. Optionally, the first memory area is located before the second memory area.
[0064] By representing the storage information of the data of the first data item in the at least one data item or the storage information of the secondary single linked list corresponding to the first data item through the first node in the first-level single linked list, on the one hand, the storage information of the data of the at least one data item can be stored as a whole, thereby improving the serialization efficiency or speed. On the other hand, during the deserialization process, the design of the storage information of the data of the at least one data item can be simplified through the first-level single linked list. Accordingly, the code size of the serialized data can be controlled and the memory occupancy or demand can be reduced, which is particularly suitable for SOC platforms where SRAM is particularly valuable.
[0065] For example, during the deserialization process, the memory requirement of the deserialization tool can be reduced, for example, only about 5K of memory is required.
[0066] It should be noted that, in the embodiment of the present application, each of the at least one data item may include data of the data item and description information of the data of the data item. Each node may serve as an index node of the data item to represent storage information of the data of the data item.
[0067] For example, the data structure may be various model (Schema) data or model files. For example, the data structure may be an IDL file generated by an interface description language (IDL). It should be understood that the parties involved in the communication need to make relevant agreements (Specifications) on the content of the communication. In order to establish an agreement that is independent of the language and platform, the agreement can be described in a language that is independent of the specific development language and platform. This language can be called an interface description language (IDL), and the data structure written in IDL can be called an IDL file.
[0068] For example, the data structure may be JSON data.
[0069] JSON data is data represented using JavaScript Object Notation (JSON).
[0070] For example, data can be described based on a collection of name / value pairs and / or an ordered list of values. In other alternative embodiments, the collection of name / value pairs can also be understood or referred to as an object, a record, a structure, a dictionary, a hash table, a keyed list, or an associative array. An ordered list of values can also be understood or referred to as an array.
[0071] The data structure of this application is explained below by taking JSON data applicable to a network processing unit (NPU) artificial intelligence (AI) chip as an example.
[0072] Among them, AI can be a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence.
[0073] For example, the data structure may be the following:
[0074] {"models":[
[0075] {"field": "magic", "fieldValue": {"value": "xxxx", "type": "immediate"}, "fieldType": "char"},
[0076] {"field": "version", "fieldValue": {"value": "0.1", "type": "immediate"}, "fieldType": "char"},
[0077] {"field":"model1","fieldValue":{"model1":"0.1","type":"pointer"},"fieldType":"table"},
[0078] {"field":"model2","fieldValue":{"model2":"0.1","type":"pointer"},"fieldType":"table"}, ]
[0080] }
[0081] Wherein, model represents a data structure. For example, models represents a data structure including sub-data structures, and model1 and model2 represent a sub-data structure respectively. For example, the data structure is used to describe an AI model, which may further include one or more AI models.
[0082] Taking model1 as an example, the model1 sub-data structure may be the following structure:
[0083] {"model1":[
[0084] {"field": "name", "fieldValue": {"value": "xxxx", "type": "immediate"}, "fieldType": "char"},
[0085] {"field":"add_size","fieldValue":{"value":"1234","type":"immediate"},"fieldType":"uint"},
[0086] {"field":"vector <xxx>”,"fieldValue”:{"value”:"c: / / file path1”,"type”:"path”},"fieldType”:"structure1”},
[0087] {"field”:"vector <xxx>", "fieldValue": {"value": "c: / / file path2", "type": "path"}, "fieldType": "unit"}, ]
[0089] }
[0090] The following is an explanation of the set of "name / value" pairs in the above data structure or sub-data structure.
[0091] It should be noted that each data item in the data structure and the sub-data structure may be a set of "name / value" pairs included in [].
[0092] field is used to describe the function of a data item; for example, the value of field can be a function (magic), version (version), sub-data structure (model1 or mode2), address (add_size), or variable xxx (vector <xxx>).
[0093] fieldValue value is used to describe the data of the data item.
[0094] The value of fieldValue value may include two sets of "name / value" pairs. The name of a set of "name / value" pairs is data (value), and its assigned value is the data of the data item, or the name of the set of "name / value" pairs may be the name of a sub-data structure (such as model1 or model2). For example, the value of value may be a string or an integer, etc. For example, "1234" or "c: / / file path". Further, the name of another set of "name / value" pairs is type (type), which is used to describe the usage of the data described by value. For example, the value of type may be an immediate number, indicating that the data of the data item is an immediate number. For another example, the value of type may be sub-data structure address indication information, which is used to describe that the data of the data item is an address indication information, which is used to point to a sub-data structure or a sub-table. For another example, the value of type may be path address indication information, which is used to describe the path of the file to which the data of the data item belongs, that is, the data of the data item is contained in this file.
[0095] fieldType is used to describe the data category of the field value; for example, the value of fieldType can be a string type (char) or a subtable (table); the char indicates that the data of the field value is a string type, and the table indicates that the data represented by the field value is a subtable or a subdata structure.
[0096] It should be noted that, in the embodiments of the present application, the data of the data items mentioned above may refer to a set of "name / value" pairs with "name" as data (value), and in other alternative embodiments, the descriptive information of the data items mentioned above may include a set of "name / value" pairs other than the set of "name / value" pairs with "name" as data (value).
[0097] In addition, the single linked list in the present application includes at least one node, and each of the at least one node is used to represent storage information of data of a data item in the data structure.
[0098] In other words, each of the at least one node may be defined by various description information.
[0099] For example, the description information of each node in the at least one node may be defined based on the description information of each data item.
[0100] In some embodiments of the present application, in some embodiments of the present application, the first-level single linked list includes a node corresponding to each data item in the at least one data item, and the first node in the first-level single linked list except the last node is also used to represent the storage information of the next node adjacent to the first node.
[0101] For example, the serialization system framework 110 may establish a node for one of the at least one data item, and insert or link a next node established for a next data item of the first data item to the first node.
[0102] In some embodiments of the present application, the first node includes node address indication information of the next node, and the node address indication information is: the address of the next node in the first memory area, and the offset of the address of the first node in the first-level single linked list in the first memory area.
[0103] Based on the node address indication information, all nodes corresponding to the at least one data item may be associated to form a single linked list.
[0104] For example, the node address indication information may be unsigned integer data.
[0105] In other words, the description information of the first node may include a Node next parameter, and the Node next parameter may associate the first node with the next node.
[0106] Of course, in other alternative embodiments, the node address indication information may also be the actual address of the next node in the first memory area.
[0107] In some embodiments of the present application, the first node includes data address indication information, and the data address indication information is: the address of the data of the first data item in the second memory area, relative to the offset of the address of the first node in the first-level single linked list in the first memory area. For example, the first data item does not include a child data structure, and the first node includes data address indication information.
[0108] For example, the data address indication information may be an offset value calculated according to the following formula:
[0109] P1=P0–ADDR0 formula (1).
[0110] Among them, P1 is the stored offset value, P0 is the actual address of the data of the first data item in the second memory area, and ADDR0 is the actual address of the first node in the first-level single linked list in the first memory area.
[0111] It should be noted that the ADDR0 may be determined according to the actual allocation of the first memory area. For example, the ADDR0 may be the actual address of the first byte in the first memory area.
[0112] Of course, in other alternative embodiments, the data address indication information may also be the actual address of the data of the first data item in the second memory area.
[0113] In some embodiments of the present application, the first-level singly linked list includes a first node corresponding to a first data item in the at least one data item, and the first data item includes a sub-data structure.
[0114] Based on this, the S240 may include:
[0115] Obtain a secondary single linked list corresponding to the sub-data structure, wherein the linked list address indication information is: the address of the first secondary node in the secondary single linked list in the first memory area, and the offset of the address of the first node in the first-level single linked list in the first memory area; store the first-level single linked list and the secondary single linked list in the first memory area, and store the data of the at least one data item and the data of the sub-data item in the sub-data structure in the second memory area.
[0116] For example, the linked list address indication information may be an offset value calculated according to the following formula:
[0117] P3=P2–ADDR0 formula (2).
[0118] Among them, P3 is the stored offset value, P2 is the address of the first secondary node in the secondary single linked list in the first memory area, and ADDR0 is the actual address of the first node in the first level single linked list in the first memory area.
[0119] It should be noted that the ADDR0 may be determined according to the actual allocation of the first memory area. For example, the ADDR0 may be the actual address of the first byte in the first memory area.
[0120] Of course, in other alternative embodiments, the data address indication information may also be the actual address of the data of the first data item in the second memory area.
[0121] The above data address indication information or linked list address indication information can be understood as different attributes of one address indication information.
[0122] For example, the description information of the first node may include a Node fieldptr parameter, which may be data address indication information or linked list address indication information. If the value of fieldType in the data structure is table, it may be used as linked list address indication information to point to the head of the singly linked list. If the value of fieldType in the data structure is not table, it may be used as data address indication information to point to the address of its data in the data area.
[0123] In some embodiments of the present application, the secondary singly linked list is located after the first-level singly linked list, and a storage location of the secondary singly linked list in the first memory area is continuous with a storage location of the first-level singly linked list in the first memory area.
[0124] In some embodiments of the present application, the type of information included in the nodes in the first-level singly linked list is the same as the type of information included in the secondary nodes in the secondary singly linked list.
[0125] In some embodiments of the present application, the first node further includes at least one of the following:
[0126] A function field, used to indicate the function of the first data item;
[0127] A length field, used to indicate the length of the data of the first data item; or
[0128] The type field is used to indicate the type of data of the first data item.
[0129] For example, a node can be defined in the following way:
[0130] For example, the function field (Node field) may include the value of a set of "name / value" pairs whose name may be "field" in the data structure.
[0131] For example, the length field (Node fieldlen) may be unsigned integer data.
[0132] For example, the type field (Node fieldType) may be used to characterize the type of data of the data item in the data structure, that is, the value of a set of "name / value" pairs whose name in the data structure may be "fieldType", for example, "unit" or "char".
[0133] In some embodiments of the present application, the function includes the name of the first data item and / or the length of the address of the data of the first data item.
[0134] In other words, the functional domain may include the value of a set of "name / value" pairs in the data structure, whose name may be "name" or "ddr_size".
[0135] In some embodiments of the present application, the type field is used to indicate that the data of the first data item is at least one of the following types:
[0136] An immediate number, used to indicate that the data of the first data item is final data;
[0137] Path address indication information, used to indicate that the data type of the first data item is the path of the file where the final data is located; or
[0138] The sub-data structure address indication information is used to indicate that the type of data of the first data item is address indication information pointing to a sub-data structure.
[0139] In other words, the type field may correspond to the value of a set of name / value pairs in the data structure whose name may be "type".
[0140] In some embodiments of the present application, the data type that the immediate value can indicate includes at least one of the following:
[0141] Integer int type, character type or floating point type.
[0142] In some embodiments of the present application, the data of the at least one data item includes int data or structure data aligned based on a preset number of bytes.
[0143] By byte-aligning the data in the data structure, it is equivalent to not needing to store additional data except for the bytes that need to be byte-aligned to fill in the empty bytes. Based on this, the memory space of the serialized data can be reduced.
[0144] In some embodiments of the present application, within the second memory area, storage addresses of data of the same data type as the at least one data item are continuous.
[0145] The empty bytes used to fill the data in the second memory area may waste a small amount of memory space. Storing data of the same data type together can ensure that the data of the same type is always byte-aligned and no longer needs to be filled with empty bytes, thereby reducing the memory space occupied by empty bytes and improving the utilization of memory space.
[0146] In some embodiments of the present application, the data structure is a JS object notation JSON data structure whose data type is an array.
[0147] By constructing the data structure as a JSON data structure, the data of the data structure can be clarified, which helps to define the description information of the nodes in the singly linked list based on the description information of the data structure, thereby improving system performance.
[0148] In some embodiments of the present application, the first memory area and the second memory area are continuous, and the first memory area is located before the second memory area, so that the egress node is established preferentially during the deserialization process.
[0149] Figure 4 Schematic diagram of the relationship between nodes and data provided in the embodiment of the present application. Figure 4 A rational explanation is given of the relationship between the nodes in the singly linked list and the data of the data structure in the embodiment of the present application.
[0150] like Figure 4 As shown, it is assumed that the first-level single linked list in the first memory area may include node A, node B, node C, node D, node E until the last empty node.
[0151] On the one hand, the node A is associated with the node B, and the node B is associated with the node C, until the previous node of the empty node is associated with the empty node to form the first-level single linked list.
[0152] On the other hand, if the data items corresponding to the node A, the node B, and the node C do not include a sub-data structure, the node A, the node B, and the node C may be respectively associated with the data items corresponding to the node A, the node B, and the node C stored in the second memory area. Assuming that the node D and the node E include sub-data structures, respectively, the node D and the node E are associated with the single linked lists corresponding to the node D and the node E, respectively. For example, the single linked list corresponding to the node D may include the secondary node D1, the secondary node D2, and up to the last secondary node. For example, the single linked list corresponding to the node E may include the secondary node E1, the secondary node E2, and up to the last secondary node.
[0153] In addition, the data structure of all nodes in the singly linked list is completely consistent and 4-byte aligned. The data type stored in the second memory area can be unfixed. For string data, it can be stored at any address, and for integer data, its starting address can be guaranteed to be 4-byte aligned. For example, when integer data is immediately after a string, 1-3 empty bytes can be filled.
[0154] The preferred embodiments of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the above embodiments. Within the technical concept of the present application, the technical solution of the present application can be subjected to a variety of simple modifications, and these simple modifications all belong to the protection scope of the present application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present application will not further explain various possible combinations. For another example, the various different embodiments of the present application can also be arbitrarily combined, as long as they do not violate the ideas of the present application, they should also be regarded as the contents disclosed in the present application.
[0155] It should be understood that in the embodiments of the present application, the term "and / or" is only a description of the association relationship of associated objects, indicating that three relationships may exist. Specifically, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0156] Combined with the above Figure 3 to Figure 4 The serialization method according to the embodiment of the present application is described in detail from the perspective of the data serialization device. Figures 5 and 6 , describes the deserialization method according to an embodiment of the present application from the perspective of a data deserialization device.
[0157] Figure 5 FIG. 3 shows a schematic flow chart of a deserialization method 300 according to an embodiment of the present application. The method 300 may be performed as follows: Figure 2 The deserialization system framework 120 is shown to execute. It should be understood that the method 300 is the reverse process of the serialization method, that is, the steps in the method 300 can refer to the corresponding steps in the serialization method 200, and for the sake of brevity, they are not repeated here.
[0158] like Figure 5 As shown, the method 300 may include:
[0159] S310, obtaining serialized data;
[0160] S320, mapping the data of the first-level singly linked list and at least one data item in the serialized data to the third memory area and the fourth memory area respectively; the first-level singly linked list includes a first node, the first node is used to represent the storage information of the data of the first data item in the at least one data item, or the first node is used to represent the storage information of the secondary singly linked list corresponding to the first data item;
[0161] S330: Based on the nodes in the first-level singly linked list, obtain data of the at least one data item to obtain a data structure.
[0162] During the deserialization process, the design of the storage information of the data of the at least one data item can be simplified through the first-level single linked list. Accordingly, the code size of the serialized data can be controlled and the memory occupancy or demand can be reduced, which is particularly suitable for SOC platforms where SRAM is particularly valuable.
[0163] For example, during the deserialization process, the memory requirement of the deserialization tool can be reduced, for example, only about 5K of memory is required.
[0164] In some embodiments of the present application, the first-level single linked list includes a node corresponding to each data item in the at least one data item, and the first nodes in the first-level single linked list except the last node are also used to represent the storage information of the next node adjacent to the first node.
[0165] In some embodiments of the present application, the first node includes node address indication information of the next node, and the node address indication information is: the address of the next node in the third memory area, relative to the offset of the address of the first node in the first-level single linked list in the third memory area;
[0166] The method 300 may further include:
[0167] Based on the offset indicated by the node address indication information and the address of the first node in the third memory area, the address of the next node in the third memory area is determined.
[0168] In some embodiments of the present application, the first node includes data address indication information, and the data address indication information is: the address of the data of the first data item in the fourth memory area, relative to the offset of the address of the first node in the first-level single linked list in the third memory area;
[0169] The method 300 may further include:
[0170] Based on the offset indicated by the data address indication information and the address of the first node in the third memory area, the address of the first data item in the fourth memory area is determined.
[0171] In some embodiments of the present application, the first-level singly linked list includes a first node, the first node corresponds to a first data item in the at least one data item, the first node includes linked list address indication information, and the linked list address indication information is: an address of a first secondary node in the secondary singly linked list in the third memory area, an offset of an address of a first node in the first-level singly linked list in the third memory area;
[0172] Wherein, the S330 may include:
[0173] Acquire the secondary singly linked list, wherein a secondary node in the secondary singly linked list corresponds to a sub-data item in the sub-data structure, and the secondary node is used to represent storage information of data of the sub-data item; the secondary node is associated with a next secondary node adjacent to the secondary node in the secondary nodes corresponding to the sub-data structure;
[0174] Based on the secondary nodes in the secondary singly linked list, data of the sub-data items in the sub-data structure are acquired to obtain the data structure.
[0175] In some embodiments of the present application, the secondary single linked list is located after the first single linked list, and the storage location of the secondary single linked list in the third memory area is continuous with the storage location of the first single linked list in the third memory area.
[0176] In some embodiments of the present application, the type of information included in the nodes in the first-level singly linked list is the same as the type of information included in the secondary nodes in the secondary singly linked list.
[0177] In some embodiments of the present application, the first node further includes at least one of the following:
[0178] A function field, used to indicate the function of the first data item;
[0179] A length field, used to indicate the length of the data of the first data item; or
[0180] The type field is used to indicate the type of data of the first data item.
[0181] In some embodiments of the present application, the function includes the name of the first data item and / or the length of the address of the data of the first data item.
[0182] In some embodiments of the present application, the type field is used to indicate that the data of the first data item is at least one of the following types:
[0183] An immediate number, used to indicate that the data of the first data item is final data;
[0184] Path address indication information, used to indicate that the data type of the first data item is the path of the file where the final data is located; or
[0185] The sub-data structure address indication information is used to indicate that the type of data of the first data item is address indication information pointing to a sub-data structure.
[0186] In some embodiments of the present application, the data type that the immediate value can indicate includes at least one of the following:
[0187] Integer int type, character type or floating point type.
[0188] In some embodiments of the present application, the data of the at least one data item includes int data or structure data aligned based on a preset number of bytes.
[0189] In some embodiments of the present application, within the fourth memory area, storage addresses of data of the same data type as the at least one data item are continuous.
[0190] In some embodiments of the present application, the third memory area and the fourth memory area are continuous, and the third memory area is located before the fourth memory area.
[0191] It should be noted that during the deserialization process, the description information involving the address indication information in the first node needs to determine the actual address of the data or node based on the offset value indicated by the address indication information and the address of the first node in the third memory area when the mapping is completed.
[0192] For example, the actual address can be determined based on the following formula:
[0193] P5=P4+ADDR1 formula (3).
[0194] Wherein, P5 is the actual address of the data or node, P4 is the offset value indicated by the address indication information, and ADDR1 is the address of the first node of the third memory area when mapping is completed to determine the actual address of the data or node.
[0195] Figure 6 It is a schematic flow chart of the serialization method and deserialization method provided in the embodiments of the present application.
[0196] like Figure 6 As shown, the serialization process S410 may include part or all of the following:
[0197] S411, determine the data structure.
[0198] For example, the electronic device obtains data 0 and data 1 from the application layer to determine the data structure based on the data 0 and the data 1.
[0199] S412, the serialization device parses the data structure.
[0200] S413, is the serialization device data structure parsing completed?
[0201] S414, the serialization device obtains the first memory area.
[0202] S415, the serialization device assigns a node in the first-level singly linked list based on a data item in the data structure, and stores the node in the first memory area.
[0203] S416, the serialization device obtains the second memory area.
[0204] S417: The serialization device determines whether the data in the at least one data item is aligned.
[0205] S418, the serialization device fills in empty data.
[0206] S419, the serialization device stores the data of the at least one data item into the second memory area.
[0207] S420, the serialization device traverses the data items in the data structure.
[0208] S421, the serialization device re-determines the assignment of address indication information for indicating addresses of nodes in the first-level single linked list.
[0209] For example, the serialization device modifies the assignment of the address indication information from an absolute address to a relative address.
[0210] like Figure 6 As shown, the deserialization process S430 may include:
[0211] S431, the deserialization device downloads the serialization data.
[0212] S432, the deserialization device maps the data of the first-level single linked list and at least one data item in the serialized data to the third memory area and the fourth memory area respectively.
[0213] S433, the deserialization device parses the assignment of a node in the first-level single linked list in the third memory area.
[0214] S434, has the deserialization device completed parsing the third memory area?
[0215] S435, the deserialization device parses the assignment of the next node.
[0216] S436, the deserialization device re-determines the assignment of the address indication information used to indicate the address of the node in the first-level single linked list.
[0217] For example, the deserialization device modifies the assignment of the address indication information from a relative address to an absolute address.
[0218] S437, the deserialization device obtains data of the at least one data item based on the nodes in the first-level single linked list to obtain a data structure.
[0219] It should be noted that in the various method embodiments of the present application, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0220] The present application also provides a serialization method, including:
[0221] Acquire a data structure to be serialized, the data structure comprising at least one data item; acquire a first-level singly linked list corresponding to the data structure, the first-level singly linked list comprising a second node and a third node, the second node being used to represent storage information of data of a second data item in the at least one data item, and the third node being used to represent storage information of a secondary singly linked list corresponding to a third data item in the at least one data item; and store the data of the first-level singly linked list and the at least one data item in a first memory area and a second memory area, respectively.
[0222] The present application also provides a deserialization method, including:
[0223] Acquire serialized data; map the data of a first-level single linked list and at least one data item in the serialized data to a third memory area and a fourth memory area, respectively; the first-level single linked list includes a second node and a third node, the second node is used to represent the storage information of the data of the second data item in the at least one data item, and the third node is used to represent the storage information of the secondary single linked list corresponding to the third data item in the at least one data item; based on the nodes in the first-level single linked list, acquire the data of the at least one data item to obtain a data structure.
[0224] It should be noted that, in the above, if the first node is used to represent the storage information of the data of the first data item among the at least one data item, then the function of the first node can be equivalent to the second node in the embodiment of the present application; if the first node is used to represent the storage information of the secondary single linked list corresponding to the first data item, then the function of the first node can be equivalent to the third node in the embodiment of the present application. Relevant content can refer to the description of the first node. To avoid repetition, it will not be repeated here.
[0225] Combination of the above Figures 1 to 6 , describes in detail the method embodiment of the present application, and the following is combined with Figures 7 to 10 , describe in detail the device embodiments of the present application.
[0226] Figure 7 It is a schematic block diagram of the device 500 according to an embodiment of the present application.
[0227] like Figure 7 As shown, the device 500 may include:
[0228] A first acquisition unit 510 is used to acquire a data structure to be serialized, where the data structure includes at least one data item;
[0229] The second acquisition unit 520 is used to acquire a first-level singly linked list corresponding to the data structure; the first-level singly linked list includes a first node, the first node is used to represent the storage information of the data of the first data item in the at least one data item, or the first node is used to represent the storage information of the secondary singly linked list corresponding to the first data item;
[0230] The storage unit 530 is used to store the data of the first-level single linked list and the data structure in the first memory area and the second memory area respectively.
[0231] In some embodiments of the present application, the first-level single linked list includes a node corresponding to each data item in the at least one data item, and the first nodes in the first-level single linked list except the last node are also used to represent the storage information of the next node adjacent to the first node.
[0232] In some embodiments of the present application, the first node includes node address indication information of the next node, and the node address indication information is: the address of the next node in the first memory area, and the offset of the address of the first node in the first-level single linked list in the first memory area.
[0233] In some embodiments of the present application, the first node includes data address indication information, and the data address indication information is: the address of the data of the first data item in the second memory area, and the offset of the address of the first node in the first-level single linked list in the first memory area.
[0234] In some embodiments of the present application, the first-level singly linked list includes a first node corresponding to a first data item in the at least one data item, and the first data item includes a child data structure;
[0235] The second acquiring unit 520 is further used for:
[0236] Obtaining a secondary singly linked list corresponding to the sub-data structure, wherein the first node includes linked list address indication information, wherein the linked list address indication information is: an address of the first secondary node in the secondary singly linked list in the first memory area, relative to an offset of an address of the first node in the first-level singly linked list in the first memory area; the storage unit 540 is specifically used for:
[0237] The first-level singly linked list and the secondary singly linked list are stored in the first memory area, and the data of the at least one data item and the data of the sub-data items in the sub-data structure are stored in the second memory area.
[0238] In some embodiments of the present application, the secondary singly linked list is located after the first-level singly linked list, and a storage location of the secondary singly linked list in the first memory area is continuous with a storage location of the first-level singly linked list in the first memory area.
[0239] In some embodiments of the present application, the type of information included in the nodes in the first-level singly linked list is the same as the type of information included in the secondary nodes in the secondary singly linked list.
[0240] In some embodiments of the present application, the first node further includes at least one of the following:
[0241] A function field, used to indicate the function of the first data item;
[0242] A length field, used to indicate the length of the data of the first data item; or
[0243] The type field is used to indicate the type of data of the first data item.
[0244] In some embodiments of the present application, the function includes the name of the first data item and / or the length of the address of the data of the first data item.
[0245] In some embodiments of the present application, the type field is used to indicate that the data of the first data item is at least one of the following types:
[0246] An immediate number, used to indicate that the data of the first data item is final data;
[0247] Path address indication information, used to indicate that the data type of the first data item is the path of the file where the final data is located; or
[0248] The sub-data structure address indication information is used to indicate that the type of data of the first data item is address indication information pointing to a sub-data structure.
[0249] In some embodiments of the present application, the data type that the immediate value can indicate includes at least one of the following:
[0250] Integer int type, character type or floating point type.
[0251] In some embodiments of the present application, the data of the at least one data item includes int data or structure data aligned based on a preset number of bytes.
[0252] In some embodiments of the present application, within the second memory area, storage addresses of data of the same data type as the at least one data item are continuous.
[0253] In some embodiments of the present application, the first memory area and the second memory area are continuous, and the first memory area is located before the second memory area.
[0254] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. Specifically, Figure 7 The device 500 shown may correspond to the corresponding subject in the method 200 or 400 of the embodiment of the present application, and the aforementioned and other operations and / or functions of each unit in the device 500 are respectively to implement Figure 3 or Figure 6 For the sake of brevity, the corresponding processes in each method are not repeated here.
[0255] Figure 8 It is a schematic block diagram of the device 600 according to an embodiment of the present application.
[0256] like Figure 8 As shown, the device 600 may include:
[0257] A first acquisition unit 610 is used to acquire serialized data;
[0258] A mapping unit 620 is used to map the data of the first-level singly linked list and at least one data item in the serialized data to the third memory area and the fourth memory area respectively; the first-level singly linked list includes a first node, and the first node is used to represent the storage information of the data of the first data item in the at least one data item, or the first node is used to represent the storage information of the secondary singly linked list corresponding to the first data item;
[0259] The second acquisition unit 630 is used to acquire data of the at least one data item based on the nodes in the first-level singly linked list to obtain a data structure.
[0260] In some embodiments of the present application, the first-level single linked list includes a node corresponding to each data item in the at least one data item, and the first nodes in the first-level single linked list except the last node are also used to represent the storage information of the next node adjacent to the first node.
[0261] In some embodiments of the present application, the first node includes node address indication information of the next node, and the node address indication information is: the address of the next node in the third memory area, relative to the offset of the address of the first node in the first-level single linked list in the third memory area;
[0262] The second acquiring unit 630 is further configured to:
[0263] Based on the offset indicated by the node address indication information and the address of the first node in the third memory area, the address of the next node in the third memory area is determined.
[0264] In some embodiments of the present application, the first node includes data address indication information, and the data address indication information is: the address of the data of the first data item in the fourth memory area, relative to the offset of the address of the first node in the first-level single linked list in the third memory area;
[0265] The second acquiring unit 630 is further configured to:
[0266] Based on the offset indicated by the data address indication information and the address of the first node in the third memory area, the address of the first data item in the fourth memory area is determined.
[0267] In some embodiments of the present application, the first node includes linked list address indication information, and the linked list address indication information is: the address of the first secondary node in the secondary single linked list in the third memory area, relative to the offset of the address of the first node in the first level single linked list in the third memory area;
[0268] The second acquisition unit 630 is specifically used for:
[0269] Acquire the secondary singly linked list, wherein a secondary node in the secondary singly linked list corresponds to a sub-data item in the sub-data structure, and the secondary node is used to represent storage information of data of the sub-data item; the secondary node is associated with the next secondary node adjacent to the secondary node in the secondary node corresponding to the sub-data structure; the second acquisition unit 630 is specifically used to:
[0270] Based on the secondary nodes in the secondary singly linked list, data of the sub-data items in the sub-data structure are acquired to obtain the data structure.
[0271] In some embodiments of the present application, the secondary single linked list is located after the first single linked list, and the storage location of the secondary single linked list in the third memory area is continuous with the storage location of the first single linked list in the third memory area.
[0272] In some embodiments of the present application, the type of information included in the nodes in the first-level singly linked list is the same as the type of information included in the secondary nodes in the secondary singly linked list.
[0273] In some embodiments of the present application, the first node further includes at least one of the following:
[0274] A function field, used to indicate the function of the first data item;
[0275] A length field, used to indicate the length of the data of the first data item; or
[0276] The type field is used to indicate the type of data of the first data item.
[0277] In some embodiments of the present application, the function includes the name of the first data item and / or the length of the address of the data of the first data item.
[0278] In some embodiments of the present application, the type field is used to indicate that the data of the first data item is at least one of the following types:
[0279] An immediate number, used to indicate that the data of the first data item is final data;
[0280] Path address indication information, used to indicate that the data type of the first data item is the path of the file where the final data is located; or
[0281] The sub-data structure address indication information is used to indicate that the type of data of the first data item is address indication information pointing to a sub-data structure.
[0282] In some embodiments of the present application, the data type that the immediate value can indicate includes at least one of the following:
[0283] Integer int type, character type or floating point type.
[0284] In some embodiments of the present application, the data of the at least one data item includes int data or structure data aligned based on a preset number of bytes.
[0285] In some embodiments of the present application, within the fourth memory area, storage addresses of data of the same data type as the at least one data item are continuous.
[0286] In some embodiments of the present application, the third memory area and the fourth memory area are continuous, and the third memory area is located before the fourth memory area.
[0287] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. Specifically, Figure 8 The device 600 shown may correspond to the corresponding subject in the method 300 or 400 of the embodiment of the present application, and the aforementioned and other operations and / or functions of each unit in the device 600 are respectively to implement Figure 5 or Figure 6 For the sake of brevity, the corresponding processes in each method are not repeated here.
[0288] The communication device of the embodiment of the present application is described above from the perspective of functional modules in conjunction with the accompanying drawings. It should be understood that the functional modules can be implemented in hardware form, can also be implemented by software instructions, and can also be implemented by a combination of hardware and software modules.
[0289] Specifically, each step of the method embodiment in the embodiment of the present application can be completed by the hardware integrated logic circuit and / or software instructions in the processor. The steps of the method disclosed in the embodiment of the present application can be directly reflected as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor.
[0290] Optionally, the software module may be located in a mature storage medium in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps in the above method embodiment in combination with its hardware.
[0291] For example, the acquisition unit and mapping unit mentioned above may be implemented by a processor respectively, and the storage unit may be implemented by a memory.
[0292] Fig. 9 It is a schematic structural diagram of a communication device 700 according to an embodiment of the present application.
[0293] like Fig. 9 As shown, the communication device 700 may include a processor 710 .
[0294] The processor 710 may call and run a computer program from the memory to implement the method in the embodiment of the present application.
[0295] Please continue to see Fig. 9 , the communication device 700 may further include a memory 720 .
[0296] The memory 720 may be used to store indication information, and may also be used to store codes, instructions, etc. executed by the processor 710. The processor 710 may call and run a computer program from the memory 720 to implement the method in the embodiment of the present application. The memory 720 may be a separate device independent of the processor 710, or may be integrated in the processor 710.
[0297] Please continue to see Fig. 9 , the communication device 700 may further include a transceiver 730 .
[0298] The processor 710 may control the transceiver 730 to communicate with other devices, specifically, to send information or data to other devices, or to receive information or data sent by other devices. The transceiver 730 may include a transmitter and a receiver. The transceiver 730 may further include an antenna, and the number of antennas may be one or more.
[0299] It should be understood that the various components in the communication device 700 are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.
[0300] It should also be understood that the communication device 700 may be a data serialization device of an embodiment of the present application, and the communication device 700 may implement the corresponding processes implemented by the data serialization device in each method of the embodiment of the present application, that is, the communication device 700 of the embodiment of the present application may correspond to the device 500 in the embodiment of the present application, and may correspond to the execution of the corresponding subject in the method 200 or 400 according to the embodiment of the present application, for the sake of brevity, it will not be repeated here. Similarly, the communication device 700 may be a data deserialization device of an embodiment of the present application, and the communication device 700 may implement the corresponding processes implemented by the data deserialization device in each method of the embodiment of the present application. That is to say, the communication device 700 of the embodiment of the present application may correspond to the device 600 in the embodiment of the present application, and may correspond to the execution of the corresponding subject in the method 300 or 400 according to the embodiment of the present application, for the sake of brevity, it will not be repeated here.
[0301] In addition, a chip is also provided in an embodiment of the present application.
[0302] For example, the chip may be an integrated circuit chip with signal processing capabilities, and can implement or execute the methods, steps, and logic diagrams disclosed in the embodiments of the present application. The chip may also be called a system-level chip, a system chip, a chip system, or a system-on-chip chip, etc. Optionally, the chip can be applied to various communication devices, so that the communication device equipped with the chip can execute the methods, steps, and logic diagrams disclosed in the embodiments of the present application.
[0303] Fig.10 is a schematic structural diagram of a chip 800 according to an embodiment of the present application.
[0304] like Fig.10 As shown, the chip 800 includes a processor 810 .
[0305] The processor 810 may call and run a computer program from the memory to implement the method in the embodiment of the present application.
[0306] Please continue to see Fig.10 , the chip 800 may further include a memory 820 .
[0307] The processor 810 may call and run a computer program from the memory 820 to implement the method in the embodiment of the present application. The memory 820 may be used to store indication information, and may also be used to store codes, instructions, etc. executed by the processor 810. The memory 820 may be a separate device independent of the processor 810, or may be integrated in the processor 810.
[0308] Please continue to see Fig.10 , the chip 800 may further include an input interface 830 .
[0309] The processor 810 may control the input interface 830 to communicate with other devices or chips, and specifically, may obtain information or data sent by other devices or chips.
[0310] Please continue to see Fig.10 , the chip 800 may further include an output interface 840 .
[0311] The processor 810 may control the output interface 840 to communicate with other devices or chips, and specifically, may output information or data to other devices or chips.
[0312] It should be understood that the chip 800 can be applied to the network device in the embodiments of the present application, and the chip can implement the corresponding processes implemented by the network device in the various methods of the embodiments of the present application, and can also implement the corresponding processes implemented by the terminal device in the various methods of the embodiments of the present application. For the sake of brevity, it will not be repeated here.
[0313] It should also be understood that the various components in the chip 800 are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.
[0314] The processors mentioned above may include but are not limited to:
[0315] General-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
[0316] The processor can be used to implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor, or a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0317] The memory mentioned above includes but is not limited to:
[0318] Volatile memory and / or non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).
[0319] It should be noted that the memory described herein is intended to include these and any other suitable types of memory.
[0320] In an embodiment of the present application, a computer-readable storage medium is further provided for storing computer programs. The computer-readable storage medium stores one or more programs, and the one or more programs include instructions, which, when executed by a portable electronic device including multiple application programs, enable the portable electronic device to execute the methods of the embodiments shown in methods 300 to 500.
[0321] Optionally, the computer-readable storage medium can be applied to various types of devices. For example, an access terminal, a user equipment (UE), a user unit, a user station, a mobile station, a mobile station, a remote station, a remote terminal, a mobile device, a user terminal, a terminal, a wireless communication device, a user agent or a user device. The access terminal can be a cellular phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA), a handheld device with wireless communication function, a computing device or other processing device connected to a wireless modem, a vehicle-mounted device, a wearable device.
[0322] A computer program is also provided in the embodiments of the present application. Optionally, the computer program can be applied to various types of devices. When the computer program is run on a computer, the computer executes the corresponding processes implemented by the corresponding execution subjects in the various methods of the embodiments of the present application. For the sake of brevity, it will not be repeated here.
[0323] A computer program product is also provided in an embodiment of the present application, including a computer program.
[0324] It should also be understood that the terms used in the embodiments of the present application and the appended claims are for the purpose of describing specific embodiments only and are not intended to limit the embodiments of the present application.
[0325] For example, as used in the embodiments of the present application and the appended claims, the singular forms "a", "an", "said", "above", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
[0326] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present application.
[0327] If implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in the embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk.
[0328] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0329] In several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods may be implemented in other ways.
[0330] For example, the division of units or modules or components in the device embodiment described above is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or modules or components can be combined or integrated into another system, or some units or modules or components can be ignored or not executed.
[0331] For another example, the units / modules / components described above as separation / display components may or may not be physically separated, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units / modules / components may be selected according to actual needs to achieve the purpose of the embodiments of the present application.
[0332] Finally, it should be noted that the mutual coupling or direct coupling or communication connection shown or discussed above may be an indirect coupling or communication connection through some interfaces, devices or units, which may be electrical, mechanical or other forms.
[0333] The above contents are only specific implementation methods of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the embodiments of the present application, which should be included in the protection scope of the embodiments of the present application. Therefore, the protection scope of the embodiments of the present application shall be based on the protection scope of the claims.< / xxx> < / xxx> < / xxx>
Claims
1. A serialization method, characterized in that: include: Acquire a data structure to be serialized, the data structure comprising at least one data item; Acquire a first-level singly linked list corresponding to the data structure, the first-level singly linked list comprising a first node, the first node being used to represent storage information of data of a first data item in the at least one data item, or the first node being used to represent storage information of a secondary singly linked list corresponding to the first data item; The data of the first-level single linked list and the at least one data item are stored in the first memory area and the second memory area respectively.
2. The method according to claim 1, characterized in that The first-level singly linked list includes a node corresponding to each data item in the at least one data item, and the first nodes in the first-level singly linked list except the last node are also used to represent the storage information of the next node adjacent to the first node.
3. The method according to claim 2, characterized in that The first node includes node address indication information of the next node, and the node address indication information is: the address of the next node in the first memory area, and the offset relative to the address of the first node in the first-level single linked list in the first memory area.
4. The method according to claim 1, characterized in that: The first node includes data address indication information, and the data address indication information is: the address of the data of the first data item in the second memory area, and the offset of the address of the first node in the first-level single linked list in the first memory area.
5. The method according to claim 1, characterized in that The first data item includes a sub-data structure; The step of storing the data of the first-level single linked list and the at least one data item in the first memory area and the second memory area, respectively, includes: Obtaining a secondary singly linked list corresponding to the sub-data structure, wherein the first node includes linked list address indication information, wherein the linked list address indication information is: an address of a first secondary node in the secondary singly linked list in the first memory area, relative to an offset of an address of a first node in the first-level singly linked list in the first memory area; The first-level singly linked list and the secondary singly linked list are stored in the first memory area, and the data of the at least one data item and the data of the sub-data items in the sub-data structure are stored in the second memory area.
6. The method according to claim 5, characterized in that The secondary singly linked list is located after the first-level singly linked list, and a storage position of the secondary singly linked list in the first memory area is continuous with a storage position of the first-level singly linked list in the first memory area.
7. The method according to claim 5, characterized in that The type of information included in the nodes in the first-level singly linked list is the same as the type of information included in the secondary nodes in the secondary singly linked list.
8. The method according to any one of claims 1 to 7, characterized in that The first node includes at least one of the following: A function field, used to indicate the function of the first data item; A length field, used to indicate the length of the data of the first data item; or The type field is used to indicate the type of data of the first data item.
9. The method according to claim 8, characterized in that The function comprises the name of the first data item and / or the length of the address of the data of the first data item.
10. The method according to claim 8, characterized in that The type field is used to indicate that the data of the first data item is at least one of the following types: An immediate number, used to indicate that the data of the first data item is final data; Path address indication information, used to indicate that the data type of the first data item is the path of the file where the final data is located; or The sub-data structure address indication information is used to indicate that the type of data of the first data item is address indication information pointing to a sub-data structure.
11. The method according to any one of claims 1 to 7, characterized in that The data of the at least one data item includes int data or structure data aligned based on a preset number of bytes.
12. The method according to any one of claims 1 to 7, characterized in that In the second memory area, storage addresses of data of the same data type as the at least one data item are continuous.
13. The method according to any one of claims 1 to 7, characterized in that The first memory area and the second memory area are continuous, and the first memory area is located before the second memory area.
14. A deserialization method, characterized in that: include: Get serialized data; Mapping the data of the first-level singly linked list and at least one data item in the serialized data to the third memory area and the fourth memory area respectively; the first-level singly linked list includes a first node, the first node is used to represent the storage information of the data of the first data item in the at least one data item, or the first node is used to represent the storage information of the secondary singly linked list corresponding to the first data item; Based on the nodes in the first-level singly linked list, data of the at least one data item is acquired to obtain a data structure.
15. The method according to claim 14, characterized in that The first-level singly linked list includes a node corresponding to each data item in the at least one data item, and the first nodes in the first-level singly linked list except the last node are also used to represent the storage information of the next node adjacent to the first node.
16. The method according to claim 15, characterized in that The first node includes node address indication information of the next node, and the node address indication information is: the address of the next node in the third memory area, and the offset of the address of the first node in the first-level single linked list in the third memory area; The method further comprises: Based on the offset indicated by the node address indication information and the address of the first node in the third memory area, the address of the next node in the third memory area is determined.
17. The method according to claim 14, characterized in that The first node includes data address indication information, and the data address indication information is: the address of the data of the first data item in the fourth memory area, relative to the offset of the address of the first node in the first-level single linked list in the third memory area; The method further comprises: Based on the offset indicated by the data address indication information and the address of the first node in the third memory area, the address of the first data item in the fourth memory area is determined.
18. The method according to claim 14, characterized in that The first node includes linked list address indication information, wherein the linked list address indication information is: an address of a first secondary node in a secondary single linked list in the third memory area, and an offset of an address of a first node in the first level single linked list in the third memory area; Wherein, acquiring data of the at least one data item based on the nodes in the first-level singly linked list to obtain a data structure includes: Acquire the secondary single linked list based on the linked list address indication information; Based on the secondary nodes in the secondary singly linked list, data of the sub-data items in the sub-data structure in the first data item is obtained to obtain the data structure.
19. The method according to claim 18, characterized in that The secondary singly linked list is located after the first-level singly linked list, and a storage position of the secondary singly linked list in the third memory area is continuous with a storage position of the first-level singly linked list in the third memory area.
20. The method according to claim 18, characterized in that The type of information included in the nodes in the first-level singly linked list is the same as the type of information included in the secondary nodes in the secondary singly linked list.
21. The method according to any one of claims 14 to 20, characterized in that The first node further includes at least one of the following: A function field, used to indicate the function of the first data item; A length field, used to indicate the length of the data of the first data item; or The type field is used to indicate the type of data of the first data item.
22. The method according to claim 21, characterized in that The function comprises the name of the first data item and / or the length of the address of the data of the first data item.
23. The method according to claim 21, characterized in that The type field is used to indicate that the data of the first data item is at least one of the following types: An immediate number, used to indicate that the data of the first data item is final data; Path address indication information, used to indicate that the data type of the first data item is the path of the file where the final data is located; or The sub-data structure address indication information is used to indicate that the type of data of the first data item is address indication information pointing to a sub-data structure.
24. The method according to claim 23, characterized in that The data type that the immediate value can indicate includes at least one of the following: Integer int type, character type or floating point type.
25. The method according to any one of claims 14 to 20, characterized in that The data of the at least one data item includes int data or structure data aligned based on a preset number of bytes.
26. The method according to any one of claims 14 to 20, characterized in that In the fourth memory area, storage addresses of data of the same data type as the at least one data item are continuous.
27. The method according to any one of claims 14 to 20, characterized in that The third memory area and the fourth memory area are continuous, and the third memory area is located before the fourth memory area.
28. A serialization method, characterized in that: include: Acquire a data structure to be serialized, the data structure comprising at least one data item; Acquire a first-level singly linked list corresponding to the data structure, the first-level singly linked list comprising a second node and a third node, the second node being used to represent storage information of data of a second data item in the at least one data item, and the third node being used to represent storage information of a secondary singly linked list corresponding to a third data item in the at least one data item; The data of the first-level single linked list and the at least one data item are stored in the first memory area and the second memory area respectively.
29. A deserialization method, characterized in that: include: Get serialized data; Mapping the data of the first-level singly linked list and at least one data item in the serialized data to the third memory area and the fourth memory area respectively; the first-level singly linked list includes a second node and a third node, the second node is used to represent the storage information of the data of the second data item in the at least one data item, and the third node is used to represent the storage information of the secondary singly linked list corresponding to the third data item in the at least one data item; Based on the nodes in the first-level singly linked list, data of the at least one data item is acquired to obtain a data structure.
30. A communication device, characterized in that: include: A processor, a memory and a transceiver, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory to perform the method according to any one of claims 1 to 13, the method according to any one of claims 14 to 27, the method according to claim 28 or the method according to claim 29.
31. A chip, characterized in that: include: A processor, configured to call and run a computer program from a memory so that a device equipped with the chip executes the method according to any one of claims 1 to 13, the method according to any one of claims 14 to 27, the method according to claim 28, or the method according to claim 29.
32. A computer-readable storage medium, characterized in that: Used to store a computer program, the computer program causing a computer to execute the method according to any one of claims 1 to 13, the method according to any one of claims 14 to 27, the method according to claim 28 or the method according to claim 29.
