Data transmission method and apparatus, device, and storage medium
By using a pre-defined memory structure to store and transfer data objects between functional modules of different programming languages and performing type conversion, the problem of low data transfer efficiency caused by differences in programming languages is solved, and efficient data transfer is achieved.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2026-03-26
AI Technical Summary
Due to differences in programming languages, functional modules developed in different languages cannot transmit data normally, resulting in low data transmission efficiency in existing methods.
The target data object is generated using a preset memory structure, including a storage unit for key-value data. The target data object is then transmitted to the second functional module, and type conversion is performed according to the data type of the second functional module to obtain the value data corresponding to the target key data.
It improves the data transfer efficiency between functional modules developed in different programming languages, avoiding full serialization and deserialization processing.
Smart Images

Figure CN2025091395_26032026_PF_FP_ABST
Abstract
Description
A data transmission method, device, apparatus and storage medium
[0001] Cross Reference to Related Applications
[0002] This application claims priority to Chinese Patent Application No. 202411320541.2, filed on September 20, 2024, the disclosure of which is incorporated herein in its entirety as part of the present application. TECHNICAL FIELD
[0003] The present disclosure relates to a data transmission method, device, apparatus and storage medium. BACKGROUND
[0004] In the data transmission of the application program developed in multiple languages, due to the difference in programming languages, the different function modules developed in different languages cannot normally transmit data. In view of the above problem, a serialization and deserialization solution is proposed. Serialization and deserialization are relative. Serialization refers to the conversion of the data type of a data object into binary data, and deserialization refers to the conversion of binary data into other data types. SUMMARY
[0005] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a data transmission method, device, apparatus and storage medium.
[0006] In a first aspect, the embodiments of the present disclosure provide a data transmission method, which comprises:
[0007] calling a first function module to generate a target data object based on a preset memory structure; wherein the target data object comprises key-value data stored based on the preset memory structure, and the preset memory structure comprises at least one storage unit, and the storage unit comprises a key field and a value field, the key field is used to store key data in the key-value data, and the value field is used to store value data corresponding to the key data;
[0008] transmitting the target data object to a second function module; wherein the second function module and the first function module are function modules generated based on different programming languages;
[0009] calling the second function module to obtain value data corresponding to target key data from the target data object, and performing type conversion processing on the value data according to the data type corresponding to the second function module to obtain converted value data corresponding to the target key data.
[0010] In an optional implementation, the calling the first function module to generate the target data object based on the preset memory structure comprises:
[0011] The first function module is called to write key data in the key-value data into a key field of a storage unit in the preset memory structure, and write value data in the key-value data into a value field of the storage unit, to obtain a target data object.
[0012] In an optional implementation, the calling of the second function module to obtain value data corresponding to the target key data from the target data object comprises:
[0013] The second function module is called to determine a storage unit corresponding to the target key data from the target data object;
[0014] The value data corresponding to the target key data is obtained based on the value field in the storage unit.
[0015] In an optional implementation, the preset memory structure further comprises a data header, and the data header comprises a data quantity field, the data quantity field being used to store a quantity of key-value pairs in the key-value data; the calling of the second function module to determine a storage unit corresponding to the target key data from the target data object comprises:
[0016] The second function module is called to obtain the quantity of key-value pairs stored in the data quantity field in the data header from the target data object;
[0017] The storage unit corresponding to the target key data is searched in the target data object based on the quantity of key-value pairs.
[0018] In an optional implementation, the storage unit further comprises a data type field, the data type field being used to store data type information of value data in the storage unit, the data type information being used to identify a storage position of the value data.
[0019] In an optional implementation, the calling of the second function module to obtain value data corresponding to the target key data from the target data object comprises:
[0020] The second function module is called to determine a storage unit corresponding to the target key data from the target data object;
[0021] Data type information is obtained from the data type field in the storage unit, and the value data corresponding to the target key data is obtained according to the storage position identified by the data type information.
[0022] In an optional implementation, the storage position identified by the data type information comprises a value field in the storage unit, and the value field in the storage unit is used to store value data of the target data type.
[0023] Alternatively,
[0024] The storage location identified by the data type information comprises a dynamic data field in the preset memory structure.
[0025] The dynamic data field in the preset memory structure is used for storing value data of a non-target data type.
[0026] In an optional implementation, the value data corresponding to the target key data is obtained according to the storage location identified by the data type information, comprising:
[0027] If the storage location indicates a value field in the storage unit, the value data corresponding to the target key data is obtained from the value field.
[0028] If the storage location indicates a dynamic data field in the preset memory structure, storage location information is obtained from the value field in the storage unit, and the value data corresponding to the target key data is obtained from the dynamic data field according to the storage location information.
[0029] In an optional implementation, the data header further comprises a start identification field, and the start identification field is used for storing a data reading start identification of the target data object.
[0030] In a second aspect, the present disclosure provides a data transmission device, comprising:
[0031] A generation module is configured to call a first function module to generate a target data object based on a preset memory structure, wherein the target data object comprises key-value data stored based on the preset memory structure, the preset memory structure comprises at least one storage unit, the storage unit comprises a key field and a value field, the key field is used for storing key data in the key-value data, and the value field is used for storing value data corresponding to the key data.
[0032] A transmission module is configured to transmit the target data object to a second function module, wherein the second function module and the first function module are function modules generated based on different programming languages.
[0033] An acquisition module is configured to call the second function module to obtain value data corresponding to target key data from the target data object, and perform type conversion processing on the value data according to a data type corresponding to the second function module, to obtain converted value data corresponding to the target key data.
[0034] In a third aspect, the embodiments of the present disclosure further provide an electronic device, comprising: a processor; a memory for storing executable instructions of the processor; and the processor is configured to read the executable instructions from the memory and execute the instructions to implement the data transmission method provided by the embodiments of the present disclosure.
[0035] In a fourth aspect, the embodiments of the present disclosure further provide a computer readable storage medium, which stores a computer program, and the computer program is used to execute the data transmission method provided by the embodiments of the present disclosure.
[0036] In a fifth aspect, the present disclosure provides a computer program product, which comprises computer programs / instructions, and the computer programs / instructions are executed by a processor to implement the method described above. BRIEF DESCRIPTION OF DRAWINGS
[0037] The above and other features, aspects, and advantages of the embodiments of the present disclosure will become more apparent from the following detailed description, taken in conjunction with the accompanying drawings. Throughout the drawings, like or similar reference numerals are used to refer to like or similar elements. It should be understood that the drawings are schematic and elements and features are not necessarily to scale.
[0038] FIG. 1 is a flow diagram of a data transmission method according to an embodiment of the present disclosure;
[0039] FIG. 2 is a schematic diagram of a data transmission process according to an embodiment of the present disclosure;
[0040] FIG. 3 is a schematic diagram of a data transmission apparatus according to an embodiment of the present disclosure;
[0041] FIG. 4 is a schematic diagram of a data transmission device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0042] Embodiments of the present disclosure will be described in more detail by referring to the drawings. Although certain embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein, but rather the embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are merely for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0043] It should be understood that the various steps in the method embodiments of the present disclosure can be performed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0044] As used herein, the term "includes" and its variants are to be read to be analogous to "comprises," or "comprising." The term "based on" is to be read as "based, at least in part, on." The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments." Related terms have corresponding meanings.
[0045] It should be noted that the terms "first", "second", etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0046] It should be noted that the modification of "one" or "multiple" mentioned in the present disclosure is illustrative and not restrictive, and those skilled in the art should understand that unless otherwise explicitly indicated in the context, it should be understood as "one or more".
[0047] The names of the messages or information exchanged between the plurality of devices in the embodiments of the present disclosure are only for illustrative purposes, and are not used to limit the scope of the messages or information.
[0048] In an application scenario, for example, module A written in Java programming language calls module B written in C++ programming language. Specifically, first, the serialization and deserialization tool is used to serialize the Java data object in module A into a byte array, and the byte array is sent to module B through network transmission. After module B receives the serialized byte array, the byte array is deserialized into a data type object that module B can recognize, and then the required data type object is obtained from the data type object to perform subsequent operations.
[0049] However, the above method needs to serialize the Java data object to be transmitted in full, and after module B receives the serialized byte array, the byte array also needs to be deserialized in full. However, since the transmission data usually includes redundant data, the above processing method results in low data transmission efficiency between module A and module B.
[0050] Therefore, in cross-language application programs, how to improve the data transmission efficiency between functional modules developed in different programming languages is a technical problem to be solved.
[0051] To this end, the embodiment of the present disclosure provides a data transmission method, specifically, a first function module is called to generate a target data object based on a preset memory structure, wherein the target data object includes key-value data stored based on the preset memory structure, the preset memory structure includes at least one storage unit, the storage unit includes a key field and a value field, the key field is used to store key data in the key-value data, and the value field is used to store value data corresponding to the key data, then the target data object is transmitted to a second function module, wherein the second function module and the first function module are function modules generated based on different programming languages, then the second function module is called to obtain value data corresponding to target key data from the target data object, and the value data is type converted according to a data type corresponding to the second function module to obtain converted value data corresponding to the target key data.
[0052] It can be seen that the embodiment of the present disclosure uses the preset memory structure common to the function modules developed by different programming languages to store and transmit data to generate a target data object, through the transmission of the target data object, the second function module can obtain the required value data corresponding to the target key data from the target data object, without the need for full serialization and deserialization processing of the transmission data, thereby improving the data transmission efficiency between the function modules developed by different programming languages as a whole.
[0053] Based on this, the embodiment of the present disclosure provides a data transmission method, which can be applied in a database system. The method will be introduced in combination with specific embodiments.
[0054] FIG. 1 is a flowchart of a data transmission method provided by the embodiment of the present disclosure, which can be executed by a data transmission device. The device can be implemented by software and / or hardware, and can be integrated in an electronic device. As shown in FIG. 1, the method includes:
[0055] S101: A first function module is called to generate a target data object based on a preset memory structure.
[0056] The target data object includes key-value data stored based on the preset memory structure, the preset memory structure includes at least one storage unit, the storage unit includes a key field and a value field, the key field is used to store key data in the key-value data, and the value field is used to store value data corresponding to the key data.
[0057] The data transmission method provided by the embodiment of the present disclosure is applied to a client, specifically, the client can be deployed on a terminal such as a smart phone, a tablet computer, a desktop computer, etc.
[0058] The first function module in the embodiments of the present disclosure can be any function unit in the cross-language application program, the function module can interact with other modules, and the function module is used to implement one or more functions in the cross-language application program.
[0059] In order to realize data transmission between function modules of different programming languages, the embodiments of the present disclosure define a memory structure in advance, that is, a preset memory structure in the embodiments of the present disclosure, which is used to store key-value data transmitted between function modules of different programming languages. The key-value data can refer to data stored in the form of key-value pairs. For example, the preset memory structure can be a byte array structure.
[0060] Specifically, the preset memory structure can be composed of at least one storage unit, each storage unit containing a key field and a value field, wherein one storage unit is used to store a pair of key-value data. Specifically, the key field in the storage unit is used to store the key data in the key-value data, and the value field is used to store the value data in the key-value data. The number of key-value pairs of the key-value data to be transmitted determines the number of storage units used by the target data object.
[0061] As shown in FIG. 2, it is a schematic diagram of a data transmission process provided by the embodiments of the present disclosure. The preset memory structure 201 contains storage unit 202 and storage unit 203, each storage unit contains a key field and a value field, such as storage unit 202 contains key field 204 and value field 205.
[0062] In actual application, since the preset memory structure is used to store key-value data, before the first function module generates the target data object based on the preset memory structure, it is also necessary to judge the type of the data to be transmitted by the first function module.
[0063] In an optional embodiment, when the first function module calls the second function module, if the data to be transmitted by the first function module to the second function module belongs to key-value data, the first function module is called to store the key-value data based on the preset memory structure to generate the target data object. Specifically, the key-value data is stored by using the storage unit in the preset memory structure.
[0064] In another optional embodiment, if it is determined that the data to be transmitted by the first function module does not belong to key-value data, other serialization and deserialization methods can be used for data transmission, which is not limited by the embodiments of the present disclosure.
[0065] Since the storage unit of the preset memory structure includes the key field and the value field, the first function module is called to generate the target data object based on the preset memory structure, which can include that the first function module writes the key data in the key-value data to be transmitted into the key field of the storage unit in the preset memory structure, and writes the value data in the key-value data into the value field of the storage unit, to obtain the target data object.
[0066] Specifically, the key data and the value data of each pair of key-value data in the key-value data to be transmitted by the first function module are respectively stored into the key field and the value field of the same storage unit in the preset memory structure.
[0067] S102: transmit the target data object to the second function module.
[0068] The second function module and the first function module are function modules generated based on different programming languages.
[0069] The second function module and the first function module are function modules implemented based on different programming languages. For example, the first function module is implemented based on Java code, and the second function module is implemented based on C++ code.
[0070] After the first function module generates the target data object, the target data object is transmitted to the second function module, and the specific transmission mode can be various. In an optional implementation, after the first function module generates the target data object based on the preset memory structure, the target data object is transmitted to the second function module through network transmission.
[0071] In another optional implementation, after the first function module generates the target data object based on the preset memory structure, the target data object is stored in a preset storage area according to a file storage mode, and the second function module can obtain the transmitted data from the preset storage area based on a file storage address.
[0072] The present embodiment does not limit the manner in which the first function module transmits the target data object to the second function module.
[0073] S103: The second function module is called to obtain the value data corresponding to the target key data pair from the target data object, and the value data is type-converted according to the data type corresponding to the second function module, to obtain the converted value data corresponding to the target key data pair.
[0074] In actual application, since the storage unit of the preset memory structure stores the key-value data, the present embodiment supports the second function module to obtain the target key-value data from the target data object. That is, the second function module does not need to obtain the full amount of the target data object.
[0075] The target key data is key data in the target key value data required to be obtained by the second function module. The target key data is used to obtain corresponding value data.
[0076] In an optional implementation, after obtaining the target data object generated by the first function module based on the preset memory structure, the second function module is called, the storage unit corresponding to the target key data in the preset memory structure is determined from the target data object based on the target key data, and then the value data corresponding to the target key data is obtained from the value field in the storage unit based on the storage unit.
[0077] In actual application, to improve the efficiency of determining the storage unit corresponding to the target key data from the target data object, the preset memory structure in the embodiment of the present disclosure further includes a data header, and the data header includes a data quantity field, which is used to store the number of key-value pairs of the key-value data.
[0078] Specifically, after obtaining the target data object generated by the first function module based on the preset memory structure, the second function module is called, the number of key-value pairs stored in the data quantity field is obtained from the target data object, and then the storage unit corresponding to the target key data is found in the storage unit of the target data object based on the number of key-value pairs.
[0079] Specifically, the storage unit corresponding to the target key data can be found in the storage unit of the target data object by using the dichotomy based on the number of key-value pairs.
[0080] As shown in the preset memory structure 201 in FIG. 2, the data header includes a data quantity field 206.
[0081] In actual application, to avoid inaccurate reading of the data stored in the target data object by starting reading from the tail of the target data object, the data header in the preset memory structure in the embodiment of the present disclosure further includes a start identifier field, which is used to store the data reading start identifier of the target data object. The start identifier field can be arranged at the first position in the data header, such as the position of the first two bytes of the data header. As shown in the preset memory structure 201 in FIG. 2, the data header includes a start identifier field 207.
[0082] In an alternative implementation, after the target data object generated by the first function module based on the preset memory structure is obtained, the second function module is called to detect whether the starting position of the data header of the target data object is the starting identification field. If it is determined that the starting position of the target data object is the starting identification field, it is indicated that the header of the target data object is currently read. Then, the second function module can be called to continue to perform subsequent operations.
[0083] In another alternative implementation, if it is determined that the starting position of the target data object is not the starting identification field, it is indicated that the tail of the target data object is currently read. Then, the second function module is called to perform subsequent operations from the other end (header) of the target data object.
[0084] The data transmission method provided by the embodiments of the present disclosure is specifically as follows. First, a first function module is called to generate a target data object based on a preset memory structure. The target data object includes key value data stored based on the preset memory structure. The preset memory structure includes at least one storage unit. The storage unit includes a key field and a value field. The key field is used to store key data in the key value data. The value field is used to store value data corresponding to the key data. Then, the target data object is transmitted to a second function module. The second function module and the first function module are function modules generated based on different programming languages. Then, the second function module is called to obtain value data corresponding to a target key data from the target data object. The value data is subjected to type conversion processing according to a data type corresponding to the second function module, to obtain converted value data corresponding to the target key data.
[0085] It can be seen that, in the embodiments of the present disclosure, the preset memory structure commonly used by function modules developed by different programming languages is used to store and transmit data to generate a target data object. Through the transmission of the target data object, the second function module can obtain the value data corresponding to the target key data required from the target data object. The full serialization and deserialization processing of the transmitted data is not required. The data transmission efficiency between function modules developed by different programming languages is improved as a whole.
[0086] In actual applications, the length of the data type of the key value data to be transmitted by the first function module is not unique. The length of the value data stored in the storage unit of the preset memory structure is preset, that is, the length of the value data stored in the storage unit of the preset memory structure is fixed and unchanged. For example, the length of the value field in the storage unit is 8 bytes.
[0087] Therefore, in a case where the length of the value data of the data type of the key-value data to be transmitted by the first function module exceeds the length of the value data stored in the storage unit of the preset memory structure, the value data can be stored in the dynamic data field, wherein the dynamic data field can be part of the preset memory structure in the embodiments of the present disclosure, and the length of the dynamic data field can change with the change of the length of the data type of the value data.
[0088] The preset memory structure 201 shown in FIG. 2 includes a dynamic data field.
[0089] In an optional embodiment, the value data of the key-value data to be transmitted by the first function module, whose data type is a target data type, can be stored in the value field of the storage unit, and the value data of the key-value data to be transmitted by the first function module, whose data type is a non-target data type, can be stored in the dynamic data field of the preset memory structure.
[0090] The length of the value data of the target data type is fixed and less than the length of the value field in the storage unit, and the target data type can include a basic data type, which can include integer types such as byte, short, int, and long, and floating-point types such as float and double. The non-target data type can be a non-basic data type, and the length of the non-target data type is not unique.
[0091] On the basis of the above embodiments, to determine the data type of the key-value data to be transmitted by the first function module, the storage unit of the preset memory in the embodiments of the present disclosure can further include a data type field. That is, each storage unit includes a key field, a value field, and a data type field, and the data type field is used to store the data type information of the value data in the storage unit of the preset memory, and the data type information is used to indicate the storage position of the value data. The preset memory structure 201 shown in FIG. 2 includes a data type field 208.
[0092] Specifically, after obtaining the target data object generated by the first function module based on the preset memory structure, the second function module is called, the storage unit corresponding to the target key data is determined from the target data object based on the target key data, then the data type information corresponding to the value data in the storage unit is obtained from the data type field in the storage unit, and then the value data corresponding to the target key data is obtained according to the storage position indicated by the data type information.
[0093] In an alternative embodiment, the storage location identified by the data type information stored in the data type field of the storage unit of the target data object can include the value field in the storage unit. If the storage location identified by the data type information stored in the data type field indicates the value field of the storage unit, it can be characterized that the value data corresponding to the target key data is currently stored in the value field of the storage unit.
[0094] In another alternative embodiment, the storage location identified by the data type information stored in the data type field of the storage unit of the target data object can also include the dynamic data field in the preset memory structure. If the storage location identified by the data type information stored in the data type field indicates the dynamic data field in the preset memory structure, it can be characterized that the value data corresponding to the target key data is not currently stored in the value field of the storage unit. At this time, the value data is stored in the dynamic data field in the preset memory structure.
[0095] In actual application, when the storage location identified by the data type information stored in the data type field of the storage unit of the target data object indicates the dynamic data field in the preset memory structure, in order to obtain the value data corresponding to the target key data in the dynamic data field, the value field in the storage unit in the preset memory structure in the embodiment of the present disclosure can also be used to store the storage location information of the value data of non-target data type in the dynamic data field.
[0096] The storage location information of the dynamic data field stored in the value field of the storage unit can include the starting position and the ending position of the value data in the dynamic data field.
[0097] In an alternative embodiment, after obtaining the target data object generated by the first function module based on the preset memory structure, the second function module is called to determine the storage unit corresponding to the target key data from the target data object based on the target key data, and then obtain the data type information corresponding to the value data in the storage unit from the data type field in the storage unit. If the storage location indicated by the data type information indicates the value field in the storage unit, the value data corresponding to the target key data is obtained from the value field of the storage unit.
[0098] In another alternative implementation, after obtaining the target data object generated by the first function module based on the preset memory structure, the second function module is invoked to determine, based on the target key data, a storage unit corresponding to the target key data from the target data object, and then obtain data type information corresponding to the value data in the storage unit from a data type field in the storage unit. If the storage location indicated by the data type information is a dynamic data field in the preset memory structure, the storage location information of the value data corresponding to the target key data is obtained from a value field in the storage unit, and the value data corresponding to the target key data is obtained from the dynamic data field according to the storage location information.
[0099] To implement the above-mentioned embodiments, the present disclosure further provides a data transmission device. FIG. 3 is a structural schematic diagram of a data transmission device provided by an embodiment of the present disclosure. The device can be implemented by software and / or hardware, and can be generally integrated in an electronic device. As shown in FIG. 3, the device includes:
[0100] The generating module 301 is configured to invoke a first function module to generate a target data object based on a preset memory structure. The target data object includes key value data stored based on the preset memory structure. The preset memory structure includes at least one storage unit. The storage unit includes a key field and a value field. The key field is configured to store key data in the key value data. The value field is configured to store value data corresponding to the key data.
[0101] The transmission module 302 is configured to transmit the target data object to a second function module. The second function module and the first function module are function modules generated based on different programming languages.
[0102] The obtaining module 303 is configured to invoke the second function module to obtain value data corresponding to target key data from the target data object, and perform type conversion processing on the value data according to a data type corresponding to the second function module, to obtain converted value data corresponding to the target key data.
[0103] In an alternative implementation, the generating module is specifically configured to:
[0104] The first function module is invoked to write key data in the key value data into a key field of a storage unit in the preset memory structure, and write value data in the key value data into a value field of the storage unit, to obtain the target data object.
[0105] In an alternative implementation, the obtaining module includes:
[0106] The first determining sub-module is configured to invoke the second function module to determine a storage unit corresponding to target key data from the target data object.
[0107] The first obtaining sub-module is configured to obtain value data corresponding to the target key data based on a value field in the storage unit.
[0108] In an optional implementation, the preset memory structure further includes a data header, and the data header includes a data quantity field, which is configured to store a number of key-value pairs in the key-value data; and the first determining module includes:
[0109] The second obtaining sub-module is configured to call the second function module to obtain the number of key-value pairs stored in the data quantity field in the data header from the target data object.
[0110] The searching sub-module is configured to search for a storage unit corresponding to the target key data in the storage unit of the target data object based on the number of key-value pairs.
[0111] In an optional implementation, the storage unit further includes a data type field, and the data type field is configured to store data type information of value data in the storage unit, and the data type information is configured to identify a storage location of the value data.
[0112] In an optional implementation, the first obtaining sub-module includes:
[0113] The second determining sub-module is configured to call the second function module to determine a storage unit corresponding to the target key data from the target data object.
[0114] The third obtaining sub-module is configured to obtain data type information from the data type field in the storage unit, and obtain value data corresponding to the target key data according to a storage location identified by the data type information.
[0115] In an optional implementation, the storage location identified by the data type information includes a value field in the storage unit, and the value field in the storage unit is configured to store value data of a target data type.
[0116] Alternatively,
[0117] The storage location identified by the data type information includes a dynamic data field in the preset memory structure.
[0118] The dynamic data field in the preset memory structure is configured to store value data of a non-target data type.
[0119] In an optional implementation, the third obtaining sub-module includes:
[0120] a fourth obtaining sub-module, configured to obtain value data corresponding to the target key data from a value field in the storage unit when the storage position indicates the value field in the storage unit;
[0121] a fifth obtaining sub-module, configured to obtain storage position information from a value field in the storage unit if the storage position indicates a dynamic data field in the preset memory structure, and obtain value data corresponding to the target key data from the dynamic data field according to the storage position information.
[0122] In an optional implementation, the data header further includes a start identifier field, which is configured to store a data reading start identifier of the target data object.
[0123] In the data transmission apparatus provided by the embodiments of the present disclosure, first, a first function module is invoked to generate a target data object based on a preset memory structure, wherein the target data object includes key-value data stored based on the preset memory structure, and the preset memory structure includes at least one storage unit, and the storage unit includes a key field and a value field, the key field is configured to store key data in the key-value data, and the value field is configured to store value data corresponding to the key data; then, the target data object is transmitted to a second function module, wherein the second function module and the first function module are function modules generated based on different programming languages; further, the second function module is invoked to obtain value data corresponding to target key data from the target data object, and the value data is subjected to type conversion processing according to a data type corresponding to the second function module, to obtain converted value data corresponding to the target key data.
[0124] It can be seen that, in the embodiments of the present disclosure, the preset memory structure commonly used by function modules developed by different programming languages is used to store and transmit data to generate a target data object, and through the transmission of the target data object, the second function module can obtain the required value data corresponding to the target key data from the target data object, without the need for full serialization and deserialization processing of the transmitted data, thereby improving the data transmission efficiency between function modules developed by different programming languages as a whole.
[0125] The data transmission apparatus provided by the embodiments of the present disclosure can execute the data transmission method provided by any of the embodiments of the present disclosure, and has the corresponding function modules and beneficial effects of executing the method.
[0126] In order to implement the above-mentioned embodiments, the present disclosure further proposes a computer program product, including computer programs / instructions, which are executed by a processor to implement the data transmission method in the above-mentioned embodiments.
[0127] In addition to the method and device described above, the embodiment of the present disclosure further provides a computer readable storage medium, which stores instructions. When the instructions are run on a terminal device, the terminal device implements the data transmission method provided by the embodiment of the present disclosure.
[0128] In addition, the embodiment of the present disclosure further provides a data transmission device, as shown in FIG. 4, which can include:
[0129] The processor 401, the memory 402, the input device 403 and the output device 404. The number of processors 401 in the data transmission device can be one or more, and one processor is taken as an example in FIG. 4. In some embodiments of the present disclosure, the processor 401, the memory 402, the input device 403 and the output device 404 can be connected through a bus or other means, and the connection through the bus is taken as an example in FIG. 4.
[0130] The memory 402 can be used to store software programs and modules, and the processor 401 executes various functions and data processing of the data transmission device by running the software programs and modules stored in the memory 402. The memory 402 can mainly include a program storage area and a data storage area, and the program storage area can store an operating system, at least one application required by a function, etc. In addition, the memory 402 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device. The input device 403 can be used to receive input digital or character information, and generate signal input related to the user settings and function control of the data transmission device.
[0131] Specifically in the present embodiment, the processor 401 loads the executable file corresponding to the process of one or more application programs into the memory 402 according to the following instructions, and runs the application program stored in the memory 402 by the processor 401, thereby realizing the various functions of the data transmission device described above.
[0132] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0133] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data transmission method, comprising: calling a first function module to generate a target data object based on a preset memory structure; wherein the target data object comprises key-value data stored based on the preset memory structure, and the preset memory structure comprises at least one storage unit, and the storage unit comprises a key field and a value field, the key field is used to store key data in the key-value data, and the value field is used to store value data corresponding to the key data; transmitting the target data object to a second function module; wherein the second function module and the first function module are function modules generated based on different programming languages; calling the second function module to obtain value data corresponding to target key data from the target data object, and performing type conversion processing on the value data according to a data type corresponding to the second function module to obtain converted value data corresponding to the target key data.
2. The method of claim 1, wherein, The calling of the first function module to generate the target data object based on the preset memory structure comprises: calling the first function module to write key data in the key-value data into the key field of the storage unit in the preset memory structure, and write value data in the key-value data into the value field of the storage unit to obtain the target data object.
3. The method of claim 1 or 2, wherein, The calling of the second function module to obtain value data corresponding to target key data from the target data object comprises: calling the second function module to determine the storage unit corresponding to the target key data from the target data object; based on the value field in the storage unit, obtaining value data corresponding to the target key data.
4. The method of claim 3, wherein, The preset memory structure further comprises a data header, and the data header comprises a data quantity field, and the data quantity field is used to store the number of key-value pairs in the key-value data; the calling of the second function module to determine the storage unit corresponding to the target key data from the target data object comprises: calling the second function module to obtain the number of key-value pairs stored in the data quantity field in the data header from the target data object; based on the number of key-value pairs, searching for the storage unit corresponding to the target key data in the storage unit of the target data object.
5. The method of claim 1 or 2, wherein, The storage unit further comprises a data type field, and the data type field is used to store data type information of the value data in the storage unit, and the data type information is used to identify the storage position of the value data.
6. The method of claim 5, wherein, The calling of the second function module to obtain value data corresponding to target key data from the target data object comprises: calling the second function module to determine the storage unit corresponding to the target key data from the target data object; obtaining data type information from the data type field in the storage unit, and obtaining value data corresponding to the target key data according to the storage position identified by the data type information.
7. The method of claim 6, wherein, The storage position identified by the data type information comprises the value field in the storage unit, and the value field in the storage unit is used to store value data of a target data type; or, the storage position identified by the data type information comprises a dynamic data field in the preset memory structure. The dynamic data field in the preset memory structure is used for storing value data of a non-target data type.
8. The method of claim 7, wherein, The value data corresponding to the target key data is obtained according to the storage location indicated by the data type information. If the storage location indicates the value field in the storage unit, the value data corresponding to the target key data is obtained from the value field. If the storage location indicates the dynamic data field in the preset memory structure, storage location information is obtained from the value field in the storage unit, and the value data corresponding to the target key data is obtained from the dynamic data field according to the storage location information.
9. The method of claim 4, wherein, The data header further includes a start identification field, which is used for storing a data reading start identification of the target data object.
10. A data transmission apparatus, comprising: a generating module configured to call a first function module to generate a target data object based on a preset memory structure; wherein the target data object includes key-value data stored based on the preset memory structure, and the preset memory structure includes at least one storage unit, and the storage unit includes a key field and a value field, the key field is used for storing key data in the key-value data, and the value field is used for storing value data corresponding to the key data; a transmission module configured to transmit the target data object to a second function module; wherein the second function module and the first function module are function modules generated based on different programming languages; an obtaining module configured to call the second function module to obtain value data corresponding to target key data from the target data object, and perform type conversion processing on the value data according to a data type corresponding to the second function module, to obtain converted value data corresponding to the target key data.
11. An electronic device, comprising: a processor; a memory configured to store executable instructions of the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the data transmission method of any one of claims 1-9.
12. A computer readable storage medium storing a computer program, wherein, The computer program is used for executing the data transmission method of any one of claims 1-9.
13. A computer program product comprising computer programs / instructions, wherein, The computer program / instructions are executed by the processor to implement the method of any one of claims 1-9.
Citation Information
Patent Citations
Data transmission method and device, computer and storage medium
CN108491283A
Data storage method and device and computer readable storage medium
CN110069452A
Data storage method, data storage device, electronic equipment and storage medium
CN110399104A
Data storage method and device, computer equipment and storage medium
CN115203159A
Data storage method and device
CN117149100A