Data type conversion method, apparatus, device, and storage medium

By directly retrieving key-value pairs from the stored data table and performing encoding conversion, the PB dataset is constructed, solving the problem of cumbersome PB data type conversion, improving development efficiency, and reducing the size of the APP package.

CN114385186BActive Publication Date: 2026-01-06PINGAN YIQIANBAO E COMMERCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210032397.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-12
Publication Date
2026-01-06
Estimated Expiration
2042-01-12

AI Technical Summary

Technical Problem

PB data type conversion is cumbersome, and the proto file needs to be manually updated frequently during project iterations, resulting in tedious maintenance work and an increase in the size of the APP package.

Method used

By obtaining the storage data table of the target data object, traversing the key-value pairs, encoding the key fields and converting them into value fields, and combining them into PB field information and data information, a PB dataset is constructed, eliminating the need for proto file conversion steps.

Benefits of technology

It reduces the number of compiled files, simplifies PB data maintenance, improves development efficiency, and reduces the size of the APP package.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114385186B_ABST
    Figure CN114385186B_ABST
Patent Text Reader

Abstract

The present application relates to the field of big data, and discloses a data type conversion method, device, equipment and storage medium.The method comprises the following steps: obtaining a first storage data table corresponding to a target data object, and traversing the first storage data table to obtain a plurality of key-value pairs; encoding the key field in each key-value pair to obtain first PB field information corresponding to each key-value pair, and converting the value field in each key-value pair according to the key field to obtain first PB data information corresponding to each key-value pair; and combining the first PB field information and the first PB data information to obtain a first PB data set corresponding to the target data object.The present application realizes automatic conversion of PB data, reduces the number of compiled files, and reduces the complexity of PB data maintenance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of big data, and in particular to a data type conversion method, apparatus, device, and storage medium. Background Technology

[0002] Protocol Buffers (PB) is an open-source serialization protocol framework developed by Google. Similar to XML (Extensible Markup Language) and JSON, it uses protocol serialization for data storage and retrieval. Compared to XML, it defines simpler data formats, and data access interfaces can be automatically generated, accelerating development speed. It supports multiple commonly used languages. In practical applications, a common use case for PB is the serialization and deserialization of data from network requests. PB uses proto files to store the definitions of data types and attributes. During the process of converting PB data into data types supported by various programming languages, the proto file is accessed to obtain the specific data's attribute and type information.

[0003] The PowerBuilder (PB) framework supports multiple languages. The original proto files are parsed using PB's built-in scripts to generate corresponding language files, facilitating integration into projects using different languages. However, despite the framework's built-in conversion tools, developers still need to manually run these tools to generate the corresponding language files and import them into their projects. For stable projects, periodic iterations frequently add, delete, and modify API data, requiring frequent conversions of the original proto files and updates to the converted proto files within the project. This increases the complexity of data type conversions in PB. Furthermore, if new APIs are added in subsequent project iterations, the number of proto files increases accordingly. Each new API requires a new file, increasing the app package size and complicating maintenance. Summary of the Invention

[0004] The main purpose of this invention is to solve the problem of cumbersome data type conversion for PB data.

[0005] The first aspect of the present invention provides a data type conversion method, comprising: obtaining a first storage data table corresponding to a target data object, and traversing the first storage data table to obtain multiple key-value pairs; encoding the key field in each key-value pair to obtain first PB field information corresponding to each key-value pair, and converting the value field in each key-value pair according to the key field to obtain first PB data information corresponding to each key-value pair; and combining the first PB field information and the first PB data information to obtain a first PB dataset corresponding to the target data object.

[0006] Optionally, in a first implementation of the first aspect of the present invention, the step of encoding the key field in each key-value pair to obtain the first PB field information corresponding to each key-value pair includes: performing hash encoding on the key field in each key-value pair to obtain multiple PB fields with a preset number of bits; and combining each PB field in the order of hash encoding to obtain the first field information corresponding to each key-value pair.

[0007] Optionally, in a second implementation of the first aspect of the present invention, the step of combining the first PB field information and the first PB data information to obtain the first PB dataset corresponding to the target data object includes: extracting each PB field from the first PB field information and extracting each PB data from the first PB data information; and sequentially adding each PB field and each PB data to a preset base output stream in the order of extraction to obtain the first PB dataset corresponding to the target data object.

[0008] Optionally, in a third implementation of the first aspect of the present invention, the step of sequentially adding each PB field and each PB data to a preset base output stream according to the extraction order to obtain the first PB dataset corresponding to the target data object includes: determining the addition position of the nth PB field as 2n-1 and the addition position of the mth PB data as 2m according to the extraction order, where n and m are positive integers; and sequentially adding the corresponding PB fields and PB data to the preset base output stream according to the addition positions of 2n-1 and 2m to obtain the first PB dataset corresponding to the target data object.

[0009] Optionally, in a fourth implementation of the first aspect of the present invention, the data type conversion method further includes: obtaining a second storage data table corresponding to the second PB dataset, and parsing the second storage data table to obtain second PB field information and second PB data information corresponding to the second PB field information; searching for attribute information corresponding to the second PB field information from a preset lookup table, and converting the second PB data information into attribute values ​​of corresponding attribute types according to the attribute information; and generating a data object corresponding to the second PB data based on the attribute values ​​and the attribute information.

[0010] Optionally, in a fifth implementation of the first aspect of the present invention, before obtaining the second storage data table corresponding to the second PB dataset, the method further includes: obtaining an attribute list of multiple data objects, traversing the attribute list to obtain attribute information corresponding to the multiple data objects; encoding the attribute information to obtain third PB field information, and storing the third PB field information and the attribute information corresponding to the multiple data objects as a lookup table.

[0011] A second aspect of the present invention provides a data type conversion apparatus, comprising: a traversal module, configured to obtain a first storage data table corresponding to a target data object, and traverse the first storage data table to obtain multiple key-value pairs; a conversion module, configured to encode the key field in each key-value pair to obtain first PB field information corresponding to each key-value pair, and convert the value field in each key-value pair according to the key field to obtain first PB data information corresponding to each key-value pair; and a combination module, configured to combine the first PB field information and the first PB data information to obtain a first PB dataset corresponding to the target data object.

[0012] Optionally, in a first implementation of the second aspect of the present invention, the conversion module includes: an encoding unit, configured to perform hash encoding on the key field of each key-value pair to obtain multiple PB fields with a preset number of bits; and a combination unit, configured to combine each PB field in the order of hash encoding to obtain first field information corresponding to each key-value pair.

[0013] Optionally, in a second implementation of the second aspect of the present invention, the combination module includes: an extraction unit, used to extract each PB field from the first PB field information and each PB data from the first PB data information; and an addition unit, used to sequentially add each PB field and each PB data to a preset base output stream in the order of extraction to obtain the first PB dataset corresponding to the target data object.

[0014] Optionally, in a third implementation of the second aspect of the present invention, the adding unit is further configured to: determine the adding position of the nth PB field as 2n-1 according to the extraction order, and determine the adding position of the mth PB data as 2m, where n and m are positive integers; according to the adding positions of 2n-1 and 2m, sequentially add the corresponding PB fields and PB data to the preset base output stream to obtain the first PB dataset corresponding to the target data object.

[0015] Optionally, in a fourth implementation of the second aspect of the present invention, the data type conversion device further includes a deserialization module, configured to: obtain a second storage data table corresponding to the second PB dataset, and parse the second storage data table to obtain second PB field information and second PB data information corresponding to the second PB field information; search for attribute information corresponding to the second PB field information from a preset lookup table, and convert the second PB data information into attribute values ​​of corresponding attribute types according to the attribute information; and generate a data object corresponding to the second PB data based on the attribute values ​​and the attribute information.

[0016] Optionally, in a fifth implementation of the second aspect of the present invention, the data type conversion device further includes an attribute comparison module, configured to: obtain an attribute list of multiple data objects, traverse the attribute list to obtain attribute information corresponding to the multiple data objects; encode the attribute information to obtain third PB field information, and store the third PB field information and the attribute information corresponding to the multiple data objects as a comparison table.

[0017] A third aspect of the present invention provides a data type conversion device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor invokes the instructions in the memory to cause the data type conversion device to perform the data type conversion method described above.

[0018] A fourth aspect of the present invention provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the above-described data type conversion method.

[0019] In the technical solution provided by this invention, the data type conversion of PB data no longer relies on proto files. It directly converts the first storage data table corresponding to the target data object into corresponding PB field information and PB data information according to the key and value fields, thereby constructing a PB dataset. This eliminates the need to convert the original proto file into an Objective-C language file and maintain the conversion script, significantly saving development costs in terms of manpower and time. Simultaneously, the reduced number of files required for project compilation speeds up the compilation process, improves development efficiency, and reduces the size of the compiled APP package. Attached Figure Description

[0020] Figure 1 This is a schematic diagram of the first embodiment of the data type conversion method in this invention;

[0021] Figure 2 This is a schematic diagram of a second embodiment of the data type conversion method in this invention;

[0022] Figure 3 This is a schematic diagram of the third embodiment of the data type conversion method in this invention;

[0023] Figure 4 This is a schematic diagram of one embodiment of the data type conversion device in this invention;

[0024] Figure 5 This is a schematic diagram of another embodiment of the data type conversion device in this invention;

[0025] Figure 6This is a schematic diagram of one embodiment of the data type conversion device in this invention. Detailed Implementation

[0026] This invention provides a data type conversion method, apparatus, device, and storage medium. The method involves obtaining a first storage data table corresponding to a target data object, traversing the first storage data table to obtain multiple key-value pairs, encoding the key field in each key-value pair to obtain first PB field information corresponding to each key-value pair, and converting the value field in each key-value pair according to the key field to obtain first PB data information corresponding to each key-value pair. Finally, the first PB field information and the first PB data information are combined to obtain a first PB dataset corresponding to the target data object. This invention achieves automated PB data conversion, reduces the number of compiled files, and lowers the complexity of PB data maintenance.

[0027] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” or “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0028] For ease of understanding, the specific process of the embodiments of the present invention is described below. Please refer to [link / reference]. Figure 1 The first embodiment of the data type conversion method in this invention includes:

[0029] 101. Obtain the first storage data table corresponding to the target data object, and traverse the first storage data table to obtain multiple key-value pairs;

[0030] It is understood that the executing entity of this invention can be a data type conversion device, a terminal, or a server; no specific limitation is made here. This embodiment of the invention will be described using a server as an example.

[0031] In this embodiment, the target data object can be a dynamic Objective-C (OC) object. Serialization of PB data involves converting the data of the target data object into PB data, such as a data stream in Proto format. The dynamism of OC objects allows the App to add target data objects at runtime and obtain the attribute names and types contained in the target data object to achieve self-parsing of Proto format data.

[0032] In this embodiment, the transformation data corresponding to the target data object is stored in a data table, such as a data dictionary, specifically a params dictionary. The data is stored in key-value pairs. By traversing and reading each key-value pair in the data table, the key-value pairs of the transformation data corresponding to the target data object can be obtained. The specific traversal method can be the for key in dictobj method.

[0033] 102. Encode the key field in each key-value pair to obtain the first PB field information corresponding to each key-value pair, and convert the value field in each key-value pair according to the key field to obtain the first PB data information corresponding to each key-value pair;

[0034] In this embodiment, the key-value pair contains a key field and a value field. The key field contains the attribute name and attribute type of the value field. The attribute name and attribute type of the corresponding value field can be determined based on the key field. First, the key field is encoded, converting it into field content suitable for PB data retrieval, specifically the first PB field information, which can be field_num. Then, based on the key field, the attribute type of the corresponding value field is determined, such as integer, boolean, string, number type, image type, floating-point type, date type, etc. Based on the determined data type of the value field, each value field is converted to obtain the first PB data information.

[0035] 103. Combine the first PB field information and the first PB data information to obtain the first PB dataset corresponding to the target data object.

[0036] In this embodiment, the first PB field information includes PB fields encoded by multiple key fields, and the first PB data information includes PB data converted from multiple value fields. Multiple pairs of PB fields and PB data can be obtained based on key-value pairs. Each PB field (pbfield_num) corresponds to one PB data (pbdata) based on its key-value pair, and these are combined to obtain the first PB dataset, for example, {pbfield_num1, pbdata1; pbfield_num2, pbdata2; ...; pbfield_num...} k pbdata k}

[0037] In this embodiment of the invention, the data type conversion of PB data no longer relies on proto files. It directly converts the first storage data table corresponding to the target data object into corresponding PB field information and PB data information according to the key and value fields, thereby constructing the PB dataset. This eliminates the need to convert the original proto file into an Objective-C language file and maintain the conversion script, significantly saving development costs in terms of manpower and time. Simultaneously, the reduced number of files required for project compilation speeds up the compilation process, improves development efficiency, and reduces the size of the compiled APP package.

[0038] Please see Figure 2 The second embodiment of the data type conversion method in this invention includes:

[0039] 201. Obtain the first storage data table corresponding to the target data object, and traverse the first storage data table to obtain multiple key-value pairs;

[0040] 202. Hash-encode the key field in each key-value pair to obtain multiple PB fields with preset bit lengths;

[0041] 203. Combine each of the PB fields in the order of hash encoding to obtain the first field information corresponding to each key-value pair, and transform the value field in each key-value pair according to the key field to obtain the first PB data information corresponding to each key-value pair;

[0042] In this embodiment, hash encoding is performed based on the data types of the key field and the represented value field to generate a PB field of a preset number of bits. For example, all key fields are converted into a 32-bit PB field pbfield_num as an index for the PB data. Then, each PB field pbfield_num is sequentially combined, such as {pbfield_num1; pbfield_num2; ...; pbfield_num...} kBy doing so, we can obtain the first field information corresponding to each key value, which can be used as an index for the corresponding PB data information.

[0043] 204. Extract each PB field from the first PB field information, and extract each PB data from the first PB data information;

[0044] 205. Following the extraction order, each PB field and each PB data is sequentially added to the preset base output stream to obtain the first PB dataset corresponding to the target data object.

[0045] In this embodiment, each PB field {pbfield_num1; pbfield_num2; ...; pbfield_num} in the first PB field information is extracted. k}, and extract each PB data {pbdata1; pbdata2; ...; pbdata} from the first PB data information. k The data is then added sequentially and interleaved to a preset radix output stream, such as a binary output stream, according to the corresponding key-value pairs. This unifies the radix of the PB dataset, resulting in the first PB dataset: {pbfield_num1, pbdata1; pbfield_num2, pbdata2; ...; pbfield_num...}. k pbdata k The specific method for adding it is as follows:

[0046] 1) Determine the insertion position of the nth PB field as 2n-1 according to the extraction order, and determine the insertion position of the mth PB data as 2m, where n and m are positive integers;

[0047] 2) Based on the addition positions of 2n-1 and 2m, add the corresponding PB fields and PB data to the preset base output stream in sequence to obtain the first PB dataset corresponding to the target data object.

[0048] In this embodiment of the invention, when converting PB data types, the key-value pairs can be hashed directly through the first storage data table corresponding to the target data object to be converted, to obtain pbfield_nm and pbdata of the binary data stream corresponding to the PB dataset, without the need for manual conversion of the proto file, thus reducing the cumbersomeness of PB data type conversion and improving the efficiency of data type conversion.

[0049] Please see Figure 3 The third embodiment of the data type conversion method in this invention includes:

[0050] 301. Obtain the first storage data table corresponding to the target data object, and traverse the first storage data table to obtain multiple key-value pairs;

[0051] 302. Encode the key field in each key-value pair to obtain the first PB field information corresponding to each key-value pair, and convert the value field in each key-value pair according to the key field to obtain the first PB data information corresponding to each key-value pair;

[0052] 303. Combine the first PB field information and the first PB data information to obtain the first PB dataset corresponding to the target data object;

[0053] 304. Obtain the attribute list of multiple data objects, and traverse the attribute list to obtain the attribute information corresponding to the multiple data objects;

[0054] 305. Encode the attribute information to obtain the third PB field information, and store the third PB field information and the attribute information corresponding to the multiple data objects as a lookup table;

[0055] In this embodiment, the target data object, such as the attribute list of a class object, is dynamically obtained. Then, the attribute list is traversed to obtain the attribute information of each piece of data in the target data object. Next, the attribute name and attribute type in each attribute information are encoded, such as by hash encoding, to generate the third PB field information. Taking pbfield_num as an example, pbfield_num is used as the key field, and the attribute information before encoding is cached as the value field in a lookup table for subsequent querying when converting PB data into data objects. The lookup table can be a data dictionary.

[0056] 306. Obtain the second storage data table corresponding to the second PB dataset, and parse the second storage data table to obtain the second PB field information and the second PB data information corresponding to the second PB field information;

[0057] 307. Find the attribute information corresponding to the second PB field information from the preset lookup table, and convert the second PB data information into attribute values ​​of the corresponding attribute type according to the attribute information;

[0058] 308. Generate a data object corresponding to the second PB data based on the attribute value and the attribute information.

[0059] In this embodiment, the PB data is deserialized, that is, the PB format data, such as the Proto format data stream, is converted into a data object, such as an Objective-C object. Then, according to the format of the second PB dataset Proto data stream, the second PB field information, with a preset bit length, such as 32 bits, is read as pbfield_num, and the second PB data information pbdata is read. Here, pbfield_num is used as the key field to find the corresponding attribute information value in the previously constructed lookup table. Then, according to the attribute type in the attribute information, the second PB dataset read from the Proto data stream is converted into the attribute value of the corresponding data type. Specifically, for example, if the attribute type is long, it is converted into a 64-bit attribute value; if it is a character type, it is converted into the corresponding String attribute value; if it is a byte type, it is converted into the corresponding Bytes attribute value, and so on.

[0060] In this embodiment of the invention, a method for converting PB data into corresponding data objects is also provided. First, by constructing key-value pairs of attribute information and pbfield_num for attribute lists of different types of data objects, the corresponding attribute information can be retrieved directly based on the pbfield_num contained in the second PB dataset when converting PB data. Then, by using the attribute information and attribute values ​​in the second PB dataset, the data object corresponding to the second PB dataset is generated, thereby realizing the dynamic generation of data pairs from PB data and the conversion of PB data types.

[0061] The data type conversion method in the embodiments of the present invention has been described above. The data type conversion apparatus in the embodiments of the present invention will be described below. Please refer to [link / reference]. Figure 4 One embodiment of the data type conversion device in this invention includes:

[0062] The traversal module 401 is used to obtain the first storage data table corresponding to the target data object, and traverse the first storage data table to obtain multiple key-value pairs;

[0063] The conversion module 402 is used to encode the key field in each key-value pair to obtain the first PB field information corresponding to each key-value pair, and to convert the value field in each key-value pair according to the key field to obtain the first PB data information corresponding to each key-value pair.

[0064] The combination module 403 is used to combine the first PB field information and the first PB data information to obtain the first PB dataset corresponding to the target data object.

[0065] In this embodiment of the invention, the data type conversion of PB data no longer relies on proto files. It directly converts the first storage data table corresponding to the target data object into corresponding PB field information and PB data information according to the key and value fields, thereby constructing the PB dataset. This eliminates the need to convert the original proto file into an Objective-C language file and maintain the conversion script, significantly saving development costs in terms of manpower and time. Simultaneously, the reduced number of files required for project compilation speeds up the compilation process, improves development efficiency, and reduces the size of the compiled APP package.

[0066] Please see Figure 5 Another embodiment of the data type conversion device in this invention includes:

[0067] The traversal module 401 is used to obtain the first storage data table corresponding to the target data object, and traverse the first storage data table to obtain multiple key-value pairs;

[0068] The conversion module 402 is used to encode the key field in each key-value pair to obtain the first PB field information corresponding to each key-value pair, and to convert the value field in each key-value pair according to the key field to obtain the first PB data information corresponding to each key-value pair.

[0069] The combination module 403 is used to combine the first PB field information and the first PB data information to obtain the first PB dataset corresponding to the target data object.

[0070] Specifically, the conversion module 402 includes:

[0071] Encoding unit 4021 is used to perform hash encoding on the key field of each key-value pair to obtain multiple PB fields with preset bit lengths;

[0072] The combination unit 4022 is used to combine each of the PB fields in the order of hash encoding to obtain the first field information corresponding to each key-value pair.

[0073] Specifically, the combination module 403 includes:

[0074] Extraction unit 4031 is used to extract each PB field from the first PB field information and extract each PB data from the first PB data information;

[0075] Adding unit 4032 is used to sequentially add each PB field and each PB data to a preset base output stream in the order of extraction to obtain the first PB dataset corresponding to the target data object.

[0076] Specifically, the adding unit 4032 is also used for:

[0077] The positions for adding the nth PB field are determined as 2n-1 according to the extraction order, and the positions for adding the mth PB data are determined as 2m, where n and m are positive integers;

[0078] Based on the addition positions of 2n-1 and 2m, the corresponding PB fields and PB data are added to the preset base output stream in sequence to obtain the first PB dataset corresponding to the target data object.

[0079] Specifically, the data type conversion device further includes a deserialization module 404, used for:

[0080] Obtain the second storage data table corresponding to the second PB dataset, and parse the second storage data table to obtain the second PB field information and the second PB data information corresponding to the second PB field information;

[0081] The system searches for the attribute information corresponding to the second PB field information in a preset lookup table, and converts the second PB data information into attribute values ​​of the corresponding attribute type based on the attribute information.

[0082] A data object corresponding to the second PB data is generated based on the attribute values ​​and the attribute information.

[0083] Specifically, the data type conversion device further includes an attribute mapping module 405, used for:

[0084] Obtain a list of attributes for multiple data objects, and iterate through the list of attributes to obtain the attribute information corresponding to the multiple data objects;

[0085] The attribute information is encoded to obtain the third PB field information, and the third PB field information and the attribute information corresponding to the multiple data objects are stored as a lookup table.

[0086] In this embodiment of the invention, when converting PB data types, the key-value pairs can be hashed directly through the first storage data table corresponding to the target data object to be converted, to obtain pbfield_nm and pbdata of the binary data stream corresponding to the PB dataset, without the need for manual conversion of the proto file. This reduces the cumbersomeness of PB data type conversion and improves the efficiency of data type conversion. Furthermore, it provides a method to convert PB data into corresponding data objects. First, by constructing key-value pairs of attribute information and pbfield_num for attribute lists of different types of data objects, the corresponding attribute information can be retrieved directly based on pbfield_num contained in the second PB dataset during subsequent PB data conversion. Then, the data object corresponding to the second PB dataset is generated using the attribute information and attribute values ​​in the second PB dataset, realizing the dynamic generation of data pairs from PB data and achieving PB data type conversion.

[0087] above Figure 4 and Figure 5 The data type conversion device in the embodiments of the present invention will be described in detail from the perspective of modular functional entities. The data type conversion device in the embodiments of the present invention will be described in detail from the perspective of hardware processing.

[0088] Figure 6 This is a schematic diagram of a data type conversion device 600 provided in an embodiment of the present invention. The data type conversion device 600 can vary significantly due to different configurations or performance characteristics. It may include one or more central processing units (CPUs) 610 (e.g., one or more processors) and a memory 620, and one or more storage media 630 (e.g., one or more mass storage devices) storing application programs 633 or data 632. The memory 620 and storage media 630 can be temporary or persistent storage. The program stored in the storage media 630 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the data type conversion device 600. Furthermore, the processor 610 may be configured to communicate with the storage media 630 and execute the series of instruction operations in the storage media 630 on the data type conversion device 600.

[0089] The data type conversion device 600 may also include one or more power supplies 640, one or more wired or wireless network interfaces 650, one or more input / output interfaces 660, and / or one or more operating systems 631, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will understand that... Figure 6The data type conversion device structure shown does not constitute a limitation on the data type conversion device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0090] The present invention also provides a data type conversion device, wherein the computer device includes a memory and a processor, the memory storing computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor performs the steps of the data type conversion method described in the above embodiments.

[0091] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, wherein the computer-readable storage medium stores instructions that, when the instructions are executed on a computer, cause the computer to perform the steps of the data type conversion method.

[0092] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0093] If the integrated unit is implemented as 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 present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0094] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A data type conversion method, characterized by, The data type conversion method comprises: Obtaining a first storage data table corresponding to a target data object, and traversing the first storage data table to obtain a plurality of key-value pairs; the target data object is a dynamic OC object, the dynamic nature of the OC object causes the App to add the target data object at runtime, the attribute name and the type of the attribute contained in the target data object are obtained, the data of the target data object is converted into PB data, and the converted data corresponding to the target data object is saved in a storage data table; Encoding the key field in each of the key-value pairs to obtain first PB field information corresponding to each of the key-value pairs, and converting the value field in each of the key-value pairs according to the key field to obtain first PB data information corresponding to each of the key-value pairs; Combining the first PB field information and the first PB data information to obtain a first PB data set corresponding to the target data object; The data type conversion method further comprises: Obtaining a second storage data table corresponding to a second PB data set, and parsing the second storage data table to obtain second PB field information and second PB data information corresponding to the second PB field information; Finding attribute information corresponding to the second PB field information from a preset reference table, and converting the second PB data information into an attribute value of a corresponding attribute type according to the attribute information; Generating a data object corresponding to the second PB data based on the attribute value and the attribute information; Before obtaining the second storage data table corresponding to the second PB data set, further comprising: Obtaining an attribute list of a plurality of data objects, and traversing the attribute list to obtain attribute information corresponding to the plurality of data objects; Encoding the attribute information to obtain third PB field information, and storing the third PB field information and the attribute information corresponding to the plurality of data objects as a reference table.

2. The data type conversion method of claim 1, wherein, The encoding of the key field in each of the key-value pairs to obtain first PB field information corresponding to each of the key-value pairs comprises: Hash encoding the key field in each of the key-value pairs to obtain a plurality of PB fields with a preset bit number; Combining the PB fields in the order of hash encoding to obtain first field information corresponding to each of the key-value pairs.

3. The data type conversion method of claim 1, wherein, The combining of the first PB field information and the first PB data information to obtain the first PB data set corresponding to the target data object comprises: Extracting each PB field in the first PB field information and each PB data in the first PB data information; According to the extraction order, the each PB field and the each PB data are added to a preset base output stream in a cross manner to obtain the first PB data set corresponding to the target data object.

4. The data type conversion method of claim 3, wherein, The adding of the each PB field and the each PB data to the preset base output stream in the cross manner according to the extraction order to obtain the first PB data set corresponding to the target data object comprises: According to the extraction order, the adding position of the nth PB field is determined as 2n-1, and the adding position of the mth PB data is determined as 2m, wherein n and m are positive integers; According to the adding positions of the 2n-1 and the 2m, corresponding PB fields and PB data are sequentially added to the preset progress output stream to obtain a first PB data set corresponding to the target data object.

5. A data type conversion apparatus, characterized by comprising: The data type conversion device comprises: The traversal module is configured to obtain a first storage data table corresponding to a target data object, and traverse the first storage data table to obtain a plurality of key-value pairs; the target data object is a dynamic OC object, the dynamic nature of the OC object enables an App to add the target data object at runtime, obtain attribute names and attribute types contained in the target data object, convert data of the target data object into PB data, and save converted data corresponding to the target data object in a storage data table; The conversion module is configured to encode key fields in each of the key-value pairs to obtain first PB field information corresponding to each of the key-value pairs, and convert value fields in each of the key-value pairs according to the key fields to obtain first PB data information corresponding to each of the key-value pairs; The combination module is configured to combine the first PB field information and the first PB data information to obtain a first PB data set corresponding to the target data object. The data type conversion device further comprises a deserialization module configured to: obtain a second storage data table corresponding to a second PB data set, and parse the second storage data table to obtain second PB field information and second PB data information corresponding to the second PB field information; find attribute information corresponding to the second PB field information from a preset comparison table, and convert the second PB data information into attribute values of corresponding attribute types according to the attribute information; generate a data object corresponding to the second PB data based on the attribute values and the attribute information; The storage module is configured to obtain an attribute list of a plurality of data objects, and traverse the attribute list to obtain attribute information corresponding to the plurality of data objects; encode the attribute information to obtain third PB field information, and store the third PB field information and the attribute information corresponding to the plurality of data objects as a comparison table.

6. A data type conversion device, characterized by, The data type conversion device comprises a memory and at least one processor, and the memory stores instructions; The at least one processor invokes the instructions in the memory to enable the data type conversion device to perform the steps of the data type conversion method according to any one of claims 1-4.

7. A computer-readable storage medium having stored thereon instructions, the computer-readable storage medium comprising: The instructions are executed by the processor to implement the steps of the data type conversion method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Method for converting data table plaintext into binary ciphertext convenient for program to read

    CN112651214A