CN114385186A - Data type conversion method, device, equipment and storage medium - Google Patents

Data type conversion method, device, equipment and storage medium Download PDF

Info

Publication number
CN114385186A
CN114385186A CN202210032397.7A CN202210032397A CN114385186A CN 114385186 A CN114385186 A CN 114385186A CN 202210032397 A CN202210032397 A CN 202210032397A CN 114385186 A CN114385186 A CN 114385186A
Authority
CN
China
Prior art keywords
data
information
attribute
field
key
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210032397.7A
Other languages
Chinese (zh)
Inventor
吕嘉慧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An E Wallet Electronic Commerce Co Ltd
Original Assignee
Ping An E Wallet Electronic Commerce Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An E Wallet Electronic Commerce Co Ltd filed Critical Ping An E Wallet Electronic Commerce Co Ltd
Priority to CN202210032397.7A priority Critical patent/CN114385186A/en
Publication of CN114385186A publication Critical patent/CN114385186A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to the field of big data and discloses a data type conversion method, a device, equipment and a storage medium. The method comprises the following steps: acquiring 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; respectively coding the key fields in the key value pairs to obtain first PB field information corresponding to the key values, and converting the value fields in the key value pairs according to the key fields to obtain first PB data information corresponding to the key values; 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 invention realizes the automatic conversion of the PB data, reduces the number of compiled files and reduces the complexity of the maintenance of the PB data.

Description

Data type conversion method, device, equipment and storage medium
Technical Field
The present invention relates to the field of big data, and in particular, to a data type conversion method, apparatus, device, and storage medium.
Background
Pb (protocol buffer) is a set of open source serialization protocol framework developed by Google, similar to XML (Extensible Markup Language) and JSON, and adopts protocol serialization for data storage and reading. In practical application, a common usage scenario of the PB is serialization and deserialization of data requested by a network. The PB uses the definitions of the types and the attributes of the saved data of the proto file, and accesses the proto file to acquire the attributes and the type information of specific data in the process of converting PB data into data of data types supported by various development languages.
The PB framework supports multiple languages, the original proto file generates a file of a corresponding language through the self-contained script analysis of the PB framework, and the introduction and integration of all language items are facilitated. However, despite the framework's own conversion tool, developers still need to manually run the tool to generate the corresponding language file and introduce it into their own project. For some stable projects, the interface data is frequently added and deleted in periodic iteration, the original proto file needs to be frequently converted correspondingly, the converted proto file in the project is updated, the complexity of PB data type conversion is increased, the number of proto files is correspondingly increased if an interface is added in the iteration of the project subsequently, and a file needs to be correspondingly added every time an interface is added, so that the volume of the app bag is increased, and the problem of complex maintenance is solved.
Disclosure of Invention
The invention mainly aims to solve the problem that the data type conversion of PB data is complex.
The invention provides a data type conversion method in a first aspect, which comprises the following steps: acquiring 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; respectively coding key fields in the key value pairs to obtain first PB field information corresponding to the key value pairs, and converting the value fields in the key value pairs according to the key fields to obtain first PB data information corresponding to the key value pairs; 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.
Optionally, in a first implementation manner of the first aspect of the present invention, the respectively encoding the key fields in the key value pairs to obtain the first PB field information corresponding to each key value pair includes: respectively carrying out Hash coding on the key fields in the key value pairs to obtain PB fields with a plurality of preset digits; and combining the PB fields according to the Hash coding sequence to obtain first field information corresponding to the key value pairs.
Optionally, in a second implementation manner of the first aspect of the present invention, the 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 includes: extracting each PB field in the first PB field information and each PB data in the first PB data information; and sequentially and crossly adding each PB field and each PB data into a preset system output stream according to the extraction sequence to obtain a first PB data set corresponding to the target data object.
Optionally, in a third implementation manner of the first aspect of the present invention, the sequentially and cross-adding the PB fields and the PB data into a preset binary output stream according to the extraction order to obtain the first PB data set corresponding to the target data object includes: sequentially determining the adding position of the nth PB field as 2n-1 and the adding position of the mth PB data as 2m according to the extraction sequence, wherein n and m are positive integers; and sequentially adding the corresponding PB fields and PB data to a preset system output stream according to the adding positions of the 2n-1 and the 2m to obtain a first PB data set corresponding to the target data object.
Optionally, in a fourth implementation manner of the first aspect of the present invention, the data type conversion method further includes: acquiring a second storage data table corresponding to a second PB data set, and analyzing the second storage data table to obtain second PB field information and second PB data information corresponding to the second PB field information; searching attribute information corresponding to the second PB field information from a preset comparison table, and converting the second PB data information into an attribute value corresponding to an attribute type according to the attribute information; and generating a data object corresponding to the second PB data based on the attribute value and the attribute information.
Optionally, in a fifth implementation manner of the first aspect of the present invention, before the acquiring the second storage data table corresponding to the second PB data set, the method further includes: acquiring attribute lists of a plurality of data objects, and traversing the attribute lists to obtain attribute information corresponding to the plurality of data objects; and coding 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 comparison table.
A second aspect of the present invention provides a data type conversion apparatus, including: the traversal module is used for acquiring 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 conversion module is used for respectively coding the key fields in the key value pairs to obtain first PB field information corresponding to the key value pairs, and converting the value fields in the key value pairs according to the key fields to obtain first PB data information corresponding to the key value pairs; and the combination module is used for 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.
Optionally, in a first implementation manner of the second aspect of the present invention, the conversion module includes: the encoding unit is used for respectively carrying out Hash encoding on the key fields in the key value pairs to obtain PB fields with a plurality of preset digits; and the combination unit is used for combining the PB fields according to the Hash coding sequence to obtain first field information corresponding to the key value pairs.
Optionally, in a second implementation manner of the second aspect of the present invention, the combining module includes: an extracting unit, configured to extract each PB field in the first PB field information, and extract each PB data in the first PB data information; and the adding unit is used for sequentially and crossly adding each PB field and each PB data into a preset system output stream according to the extraction sequence to obtain a first PB data set corresponding to the target data object.
Optionally, in a third implementation manner of the second aspect of the present invention, the adding unit is further configured to: sequentially determining the adding position of the nth PB field as 2n-1 and the adding position of the mth PB data as 2m according to the extraction sequence, wherein n and m are positive integers; and sequentially adding the corresponding PB fields and PB data to a preset system output stream according to the adding positions of the 2n-1 and the 2m to obtain a first PB data set corresponding to the target data object.
Optionally, in a fourth implementation manner of the second aspect of the present invention, the data type conversion apparatus further includes an deserialization module, configured to: acquiring a second storage data table corresponding to a second PB data set, and analyzing the second storage data table to obtain second PB field information and second PB data information corresponding to the second PB field information; searching attribute information corresponding to the second PB field information from a preset comparison table, and converting the second PB data information into an attribute value corresponding to an attribute type according to the attribute information; and generating a data object corresponding to the second PB data based on the attribute value and the attribute information.
Optionally, in a fifth implementation manner of the second aspect of the present invention, the data type conversion apparatus further includes an attribute comparison module, configured to: acquiring attribute lists of a plurality of data objects, and traversing the attribute lists to obtain attribute information corresponding to the plurality of data objects; and coding 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 comparison table.
A third aspect of the present invention provides a data type conversion apparatus comprising: a memory and at least one processor, the memory having instructions stored therein; 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.
A fourth aspect of the present invention provides a computer-readable storage medium having stored therein instructions, which, when run on a computer, cause the computer to execute the above-described data type conversion method.
In the technical scheme provided by the invention, the data type of the PB data is converted, because the PB data does not depend on the proto file any more, the first storage data table corresponding to the target data object is directly converted into the corresponding PB field information and PB data information according to the key field and the value field, so that a PB data set is constructed, the work of converting the original proto file into the Objective-C language file is omitted, a script used for conversion does not need to be maintained, and the development cost of manpower, time and the like is greatly saved. Meanwhile, the compiling speed of the project can be increased by reducing the number of files needing to be compiled in the project compiling process, the development efficiency is improved, and the volume of the compiled APP package is reduced.
Drawings
FIG. 1 is a diagram of a first embodiment of a data type conversion method according to an embodiment of the present invention;
FIG. 2 is a diagram of a second embodiment of a data type conversion method according to an embodiment of the present invention;
FIG. 3 is a diagram of a third embodiment of a data type conversion method according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of an embodiment of a data type conversion apparatus according to the embodiment of the present invention;
FIG. 5 is a schematic diagram of another embodiment of a data type conversion apparatus according to an embodiment of the present invention;
fig. 6 is a schematic diagram of an embodiment of a data type conversion device in the embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a data type conversion method, a device, equipment and a storage medium, wherein a first storage data table corresponding to a target data object is obtained, and the first storage data table is traversed to obtain a plurality of key value pairs; respectively coding the key fields in the key value pairs to obtain first PB field information corresponding to the key values, and converting the value fields in the key value pairs according to the key fields to obtain first PB data information corresponding to the key values; 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 invention realizes the automatic conversion of the PB data, reduces the number of compiled files and reduces the complexity of the maintenance of the PB data.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," or "having," and any variations thereof, are intended to cover non-exclusive inclusions, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For convenience of understanding, a specific flow of an embodiment of the present invention is described below, and referring to fig. 1, a first embodiment of a data type conversion method in an embodiment of the present invention includes:
101. acquiring 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;
it is to be understood that the execution subject of the present invention may be a data type conversion device, and may also be a terminal or a server, which is not limited herein. The embodiment of the present invention is described by taking a server as an execution subject.
In this embodiment, the target data object may be a dynamic OC (objective c) object, and PB data is serialized, that is, data of the target data object is converted into PB data, such as a data stream in a Proto format, and the dynamics of the OC object enables the App to add a new target data object during running, and obtain an attribute name and a type of an attribute included in the target data object, so as to implement self-analysis of the Proto format data.
In this embodiment, the conversion Data corresponding to the target Data object is stored in a storage Data table, for example, a Data dictionary (Data dictionary), which may specifically be a Params dictionary, and the storage form of the conversion Data is a key-value pair (key-value), where each key-value pair in the storage Data table is traversed and read, so that the key-value pair of the conversion Data corresponding to the target Data object can be obtained, and a specific traversal manner may adopt a method for key in dictobj.
102. Respectively coding key fields in the key value pairs to obtain first PB field information corresponding to the key value pairs, and converting the value fields in the key value pairs according to the key fields to obtain first PB data information corresponding to the key value pairs;
in this embodiment, the key value pair includes a key field (key) and a value field (value), where the key field includes an attribute name and an attribute type of the value field, and the attribute name and the attribute type of the corresponding value field may be determined according to the key field. And then determining attribute types of corresponding value fields according to the key fields, such as an integer type, a Boolean type, a character string type, a binary data type, a number type, a picture type, a floating point type, a date type and the like, and converting each value field according to the determined data type of the value field to obtain first PB data information.
103. 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.
In this embodiment, the first PB field information includes a PB field obtained by encoding a plurality of key fields, the first PB data information includes PB data obtained by converting a plurality of value fields, a plurality of corresponding pairs of PB field-PB data can be obtained according to a key-value pair (key-value), each PB field (pbfield _ num) corresponds to one PB data (pbdata) according to the key-value pair, and the PB fields are combined to obtain a first PB data set, for example, { pbfield _ num1,pbdata1;pbfield_num2,pbdata2;……;pbfield_numk,pbdatak}。
In the embodiment of the invention, the data type of the PB data is converted, because the PB data does not depend on the proto file any more, the first storage data table corresponding to the target data object is directly converted into the corresponding PB field information and PB data information according to the key field and the value field, so that a PB data set is constructed, the work of converting the original proto file into the Objective-C language file is omitted, a script used by conversion does not need to be maintained, and the development cost of manpower, time and the like is greatly saved. Meanwhile, the compiling speed of the project can be increased by reducing the number of files needing to be compiled in the project compiling process, the development efficiency is improved, and the volume of the compiled APP package is reduced.
Referring to fig. 2, a second embodiment of the data type conversion method according to the embodiment of the present invention includes:
201. acquiring 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;
202. respectively carrying out Hash coding on the key fields in the key value pairs to obtain PB fields with a plurality of preset digits;
203. combining the PB fields according to a Hash coding sequence to obtain first field information corresponding to the key value pairs, and converting the value fields in the key value pairs according to the key fields to obtain first PB data information corresponding to the key value pairs;
in this embodiment, the key field and the expressed value field are hash-coded according to their data types to generate a PB field with a preset number of bits, for example, the key field is completely converted into a PB field pbfield _ num with 32 bits as an index of PB data, and then each PB field pbfield _ num is sequentially combined, for example, { pbfield _ num }1;pbfield_num2;……;pbfield_numkAnd obtaining first field information corresponding to each key value as an index of the corresponding PB data information.
204. Extracting each PB field in the first PB field information and each PB data in the first PB data information;
205. and sequentially and crossly adding each PB field and each PB data into a preset system output stream according to the extraction sequence to obtain a first PB data set corresponding to the target data object.
In this embodiment, each PB field { pbfield _ num "in the first PB field information is extracted1;pbfield_num2;……;pbfield_numkAnd extracting each PB data { pbdata data ] in the first PB data information1;pbdata2;……;pbdatakSequentially and alternately adding the data into a preset binary output stream, such as a binary output stream, according to a key-value corresponding mode, unifying the data systems of the PB data set, and thus obtaining a first PB data set { pbfield _ num }1,pbdata1;pbfield_num2,pbdata2;……;pbfield_numk,pbdatak}. The specific addition mode is as follows:
1) sequentially determining the adding position of the nth PB field as 2n-1 and the adding position of the mth PB data as 2m according to the extraction sequence, wherein n and m are positive integers;
2) and sequentially adding the corresponding PB fields and PB data to a preset system output stream according to the adding positions of the 2n-1 and the 2m to obtain a first PB data set corresponding to the target data object.
In the embodiment of the invention, when the PB data type is converted, the key value pair can be directly subjected to Hash coding through the first storage data table corresponding to the target data object to be converted, so that the pbfield _ nm and the pbdata of the binary data stream corresponding to the PB data set are obtained, manual conversion of a proto file is not needed, the complexity of PB data type conversion is reduced, and the data type conversion efficiency is improved.
Referring to fig. 3, a third embodiment of the data type conversion method according to the embodiment of the present invention includes:
301. acquiring 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;
302. respectively coding key fields in the key value pairs to obtain first PB field information corresponding to the key value pairs, and converting the value fields in the key value pairs according to the key fields to obtain first PB data information corresponding to the key value pairs;
303. 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;
304. acquiring attribute lists of a plurality of data objects, and traversing the attribute lists to obtain attribute information corresponding to the plurality of data objects;
305. coding 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 comparison table;
in this embodiment, the attribute list of the target data object, for example, the 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, and then the attribute name and the attribute type in each piece of attribute information are encoded, for example, hash-coded, to generate the third PB field information, or, taking pbfield _ num as a key field key, and the attribute information before being encoded as a value field value is cached in the comparison table for subsequent query when the PB data is converted into the data object, where the comparison table may be a data dictionary.
306. Acquiring a second storage data table corresponding to a second PB data set, and analyzing the second storage data table to obtain second PB field information and second PB data information corresponding to the second PB field information;
307. searching attribute information corresponding to the second PB field information from a preset comparison table, and converting the second PB data information into an attribute value corresponding to an attribute type according to the attribute information;
308. and generating a data object corresponding to the second PB data based on the attribute value and the attribute information.
In this embodiment, the PB data is deserialized, that is, PB format data, such as a Proto format data stream, is converted into a data object, such as an OC object. Then, according to the format of the Proto data stream of the second PB data set, reading second PB field information of a preset number of bits, such as 32-bit data, as pbfield _ num, and reading second PB data information pbdata, wherein the corresponding attribute information value can be found in a previously constructed comparison table by taking the pbfield _ num as a key field key; then, according to the attribute type in the attribute information, the second PB data set read from the Proto data stream may be converted into an attribute value of a corresponding data type, specifically, for example, if the attribute type is long, the attribute value is converted into a 64-bit attribute value, if the attribute type is a character type, the attribute value is converted into an attribute value corresponding to String, if the attribute type is a byte type, the attribute value is converted into an attribute value corresponding to Bytes, and so on.
In the embodiment of the present invention, a method for converting PB data into corresponding data objects is further provided, where attribute information and key value pairs of pbfield _ num are first constructed through attribute lists of different types of data objects, and subsequently, when PB data is converted, corresponding attribute information can be directly retrieved according to pbfield _ num included in the second PB data set, and a data object corresponding to the second PB data set is generated through the attribute information and the attribute values in the second PB data set, so as to implement dynamic generation of data pairs for PB data and implement conversion of PB data types.
With reference to fig. 4, the data type conversion method in the embodiment of the present invention is described above, and a data type conversion apparatus in the embodiment of the present invention is described below, where an embodiment of the data type conversion apparatus in the embodiment of the present invention includes:
a traversal module 401, 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 402, configured to encode the key field in each key value pair respectively 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;
a combining module 403, 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.
In the embodiment of the invention, the data type of the PB data is converted, because the PB data does not depend on the proto file any more, the first storage data table corresponding to the target data object is directly converted into the corresponding PB field information and PB data information according to the key field and the value field, so that a PB data set is constructed, the work of converting the original proto file into the Objective-C language file is omitted, a script used by conversion does not need to be maintained, and the development cost of manpower, time and the like is greatly saved. Meanwhile, the compiling speed of the project can be increased by reducing the number of files needing to be compiled in the project compiling process, the development efficiency is improved, and the volume of the compiled APP package is reduced.
Referring to fig. 5, another embodiment of the data type conversion apparatus according to the embodiment of the present invention includes:
a traversal module 401, 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 402, configured to encode the key field in each key value pair respectively 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;
a combining module 403, 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.
Specifically, the conversion module 402 includes:
the encoding unit 4021 is configured to perform hash encoding on the key fields in the key value pairs respectively to obtain PB fields with multiple preset digits;
a combining unit 4022, configured to combine the PB fields according to a hash coding order to obtain first field information corresponding to each key value pair.
Specifically, the combining module 403 includes:
an extracting unit 4031, configured to extract each PB field in the first PB field information, and extract each PB data in the first PB data information;
an adding unit 4032, configured to add the PB fields and the PB data to a preset output stream in an intersecting manner in sequence according to the extraction order, so as to obtain a first PB data set corresponding to the target data object.
Specifically, the adding unit 4032 is further configured to:
sequentially determining the adding position of the nth PB field as 2n-1 and the adding position of the mth PB data as 2m according to the extraction sequence, wherein n and m are positive integers;
and sequentially adding the corresponding PB fields and PB data to a preset system output stream according to the adding positions of the 2n-1 and the 2m to obtain a first PB data set corresponding to the target data object.
Specifically, the data type converting apparatus further includes an deserializing module 404, configured to:
acquiring a second storage data table corresponding to a second PB data set, and analyzing the second storage data table to obtain second PB field information and second PB data information corresponding to the second PB field information;
searching attribute information corresponding to the second PB field information from a preset comparison table, and converting the second PB data information into an attribute value corresponding to an attribute type according to the attribute information;
and generating a data object corresponding to the second PB data based on the attribute value and the attribute information.
Specifically, the data type conversion apparatus further includes an attribute comparison module 405, configured to:
acquiring attribute lists of a plurality of data objects, and traversing the attribute lists to obtain attribute information corresponding to the plurality of data objects;
and coding 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 comparison table.
In the embodiment of the invention, when the PB data type is converted, the key value pair can be directly subjected to Hash coding through the first storage data table corresponding to the target data object to be converted, so that the pbfield _ nm and the pbdata of the binary data stream corresponding to the PB data set are obtained, manual conversion of a proto file is not needed, the complexity of PB data type conversion is reduced, and the data type conversion efficiency is improved; the method also provides the steps of converting PB data into corresponding data objects, firstly constructing key value pairs of attribute information and pbfield _ num through attribute lists of different types of data objects, subsequently retrieving the corresponding attribute information directly according to the pbfield _ num contained in the second PB data set when the PB data are converted, generating the data objects corresponding to the second PB data set through the attribute information and the attribute values in the second PB data set, realizing dynamic generation of data pairs of the PB data, and realizing conversion of PB data types.
Fig. 4 and 5 describe the data type conversion apparatus in the embodiment of the present invention in detail from the perspective of the modular functional entity, and the data type conversion device in the embodiment of the present invention is described in detail from the perspective of hardware processing.
Fig. 6 is a schematic structural diagram of a data type conversion device 600 according to an embodiment of the present invention, which may have a relatively large difference due to different configurations or performances, and may include one or more processors (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) for storing applications 633 or data 632. Memory 620 and storage medium 630 may be, among other things, transient or persistent storage. The program stored in the storage medium 630 may include one or more modules (not shown), each of which may include a series of instructions operating on the data type conversion apparatus 600. Further, the processor 610 may be configured to communicate with the storage medium 630 and execute a series of instruction operations in the storage medium 630 on the data type conversion apparatus 600.
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, and the like. Those skilled in the art will appreciate that the data type conversion device configuration shown in fig. 6 does not constitute a limitation of the data type conversion device, and may include more or less components than those shown, or combine certain components, or a different arrangement of components.
The present invention also provides a data type conversion device, which includes a memory and a processor, wherein the memory stores computer readable instructions, and the computer readable instructions, when executed by the processor, cause the processor to execute the steps of the data type conversion method in the above embodiments.
The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium, and which may also be a volatile computer-readable storage medium, having stored therein instructions, which, when run on a computer, cause the computer to perform the steps of the data type conversion method.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A data type conversion method, characterized in that the data type conversion method comprises:
acquiring 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;
respectively coding key fields in the key value pairs to obtain first PB field information corresponding to the key value pairs, and converting the value fields in the key value pairs according to the key fields to obtain first PB data information corresponding to the key value pairs;
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.
2. The data type conversion method according to claim 1, wherein said encoding the key field in each of the key value pairs respectively to obtain the first PB field information corresponding to each of the key value pairs comprises:
respectively carrying out Hash coding on the key fields in the key value pairs to obtain PB fields with a plurality of preset digits;
and combining the PB fields according to the Hash coding sequence to obtain first field information corresponding to the key value pairs.
3. The data type conversion method according to claim 1, wherein the combining 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;
and sequentially and crossly adding each PB field and each PB data into a preset system output stream according to the extraction sequence to obtain a first PB data set corresponding to the target data object.
4. The data type conversion method according to claim 3, wherein the cross-adding each PB field and each PB data into a preset binary output stream in sequence according to the extraction order to obtain the first PB data set corresponding to the target data object comprises:
sequentially determining the adding position of the nth PB field as 2n-1 and the adding position of the mth PB data as 2m according to the extraction sequence, wherein n and m are positive integers;
and sequentially adding the corresponding PB fields and PB data to a preset system output stream according to the adding positions of the 2n-1 and the 2m to obtain a first PB data set corresponding to the target data object.
5. The data type conversion method according to claim 1, further comprising:
acquiring a second storage data table corresponding to a second PB data set, and analyzing the second storage data table to obtain second PB field information and second PB data information corresponding to the second PB field information;
searching attribute information corresponding to the second PB field information from a preset comparison table, and converting the second PB data information into an attribute value corresponding to an attribute type according to the attribute information;
and generating a data object corresponding to the second PB data based on the attribute value and the attribute information.
6. The data type conversion method according to claim 5, further comprising, before the obtaining of the second storage data table corresponding to the second PB data set:
acquiring attribute lists of a plurality of data objects, and traversing the attribute lists to obtain attribute information corresponding to the plurality of data objects;
and coding 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 comparison table.
7. A data type conversion apparatus, characterized in that the data type conversion apparatus comprises:
the traversal module is used for acquiring 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 conversion module is used for respectively coding the key fields in the key value pairs to obtain first PB field information corresponding to the key value pairs, and converting the value fields in the key value pairs according to the key fields to obtain first PB data information corresponding to the key value pairs;
and the combination module is used for 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.
8. The data type conversion apparatus according to claim 7, further comprising an deserialization module configured to:
acquiring a second storage data table corresponding to a second PB data set, and analyzing the second storage data table to obtain second PB field information and second PB data information corresponding to the second PB field information;
searching attribute information corresponding to the second PB field information from a preset comparison table, and converting the second PB data information into an attribute value corresponding to an attribute type according to the attribute information;
and generating a data object corresponding to the second PB data based on the attribute value and the attribute information.
9. A data type conversion apparatus characterized by comprising: a memory and at least one processor, the memory having instructions stored therein;
the at least one processor invoking the instructions in the memory to cause the data type conversion device to perform the steps of the data type conversion method of any of claims 1-6.
10. A computer-readable storage medium having instructions stored thereon, wherein the instructions, when executed by a processor, implement the steps of the data type conversion method according to any one of claims 1 to 6.
CN202210032397.7A 2022-01-12 2022-01-12 Data type conversion method, device, equipment and storage medium Pending CN114385186A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210032397.7A CN114385186A (en) 2022-01-12 2022-01-12 Data type conversion method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210032397.7A CN114385186A (en) 2022-01-12 2022-01-12 Data type conversion method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114385186A true CN114385186A (en) 2022-04-22

Family

ID=81202073

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210032397.7A Pending CN114385186A (en) 2022-01-12 2022-01-12 Data type conversion method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114385186A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112230934A (en) * 2020-10-27 2021-01-15 北京人大金仓信息技术股份有限公司 Method and device for converting code language
CN116028434A (en) * 2023-03-23 2023-04-28 中科星图测控技术股份有限公司 File coding method and system for describing space analysis scene

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112230934A (en) * 2020-10-27 2021-01-15 北京人大金仓信息技术股份有限公司 Method and device for converting code language
CN112230934B (en) * 2020-10-27 2023-08-29 北京人大金仓信息技术股份有限公司 Method and device for converting code language
CN116028434A (en) * 2023-03-23 2023-04-28 中科星图测控技术股份有限公司 File coding method and system for describing space analysis scene

Similar Documents

Publication Publication Date Title
US11146286B2 (en) Compression of JavaScript object notation data using structure information
Head et al. A benchmark suite for soap-based communication in grid web services
CN114385186A (en) Data type conversion method, device, equipment and storage medium
JP6427592B2 (en) Manage data profiling operations related to data types
CN110597500A (en) Method and device for serialization and deserialization of message structure
US20070234199A1 (en) Apparatus and method for compact representation of XML documents
US20190213007A1 (en) Method and device for executing the distributed computation task
CN110688118A (en) Webpage optimization method and device
CN111443901A (en) Business expansion method and device based on Java reflection
Viotti et al. A survey of JSON-compatible binary serialization specifications
De Luca et al. Distributed genomic compression in MapReduce paradigm
Viotti et al. A Benchmark of JSON-compatible Binary Serialization Specifications
CN115202663A (en) Data processing method, device and storage medium
CN110941655B (en) Data format conversion method and device
CN116628066A (en) Data transmission method, device, computer equipment and storage medium
US20100293283A1 (en) On-demand marshalling and de-marshalling of network messages
CN113138767B (en) Code language conversion method, device, electronic equipment and storage medium
Zhang et al. Optimizing random access to hierarchically-compressed data on GPU
WO2021259290A1 (en) Stored procedure conversion method and apparatus, and device and storage medium
WO2022099459A1 (en) Webassembly loading method and apparatus, and storage medium
US8301726B2 (en) Method and system for bit streaming for data centric applications
CN109992293B (en) Method and device for assembling Android system component version information
CN114063943A (en) Data transmission system, method, device, medium, and apparatus
Ching et al. RcppMsgPack: MessagePack Headers and Interface Functions for R.
EP3750078A1 (en) System and methods for loading objects from hash chains

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination