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

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

Info

Publication number
CN112783974A
CN112783974A CN202011636181.9A CN202011636181A CN112783974A CN 112783974 A CN112783974 A CN 112783974A CN 202011636181 A CN202011636181 A CN 202011636181A CN 112783974 A CN112783974 A CN 112783974A
Authority
CN
China
Prior art keywords
field
sub
type
intelligent contract
byte stream
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
CN202011636181.9A
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.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian Technology 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 Hangzhou Qulian Technology Co Ltd filed Critical Hangzhou Qulian Technology Co Ltd
Priority to CN202011636181.9A priority Critical patent/CN112783974A/en
Publication of CN112783974A publication Critical patent/CN112783974A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems

Abstract

The application discloses a data conversion method, a device, equipment and a storage medium, wherein the method comprises the steps of obtaining an intelligent contract object; determining the field type of each field of the intelligent contract object; calling a preset coding method according to the field type of each field of the intelligent contract object, and respectively carrying out serialization processing on each field of the intelligent contract object to obtain a plurality of sub byte streams; and splicing the plurality of sub byte streams to obtain byte stream data corresponding to the intelligent contract object so as to complete data conversion of the intelligent contract object. The intelligent contract object is converted into binary byte stream data, so that the data transmission efficiency is improved, and the storage space occupied by byte stream data storage is reduced; the serialization conversion efficiency is improved, the time required by conversion is reduced, the execution speed is high, and convenience is further provided for data interaction between the intelligent contract and the block chain account book.

Description

Data conversion method, device, equipment and storage medium
Technical Field
The present application relates to the field of block chain technology, and in particular, to a data conversion method, apparatus, device, and storage medium.
Background
The block chain technology is a novel decentralized protocol, can safely store digital currency transactions or other data, and can not forge and falsify information. The intelligent contract is a piece of code which can be deployed and executed in a blockchain network environment, the deployment and execution of the code can be presented in a transaction form in the blockchain network, and the deployment and execution results can be commonly known by the whole network along with the transaction.
At present, the execution of an intelligent contract depends on an execution engine, and there are many data interactions between the intelligent contract and a blockchain ledger, but a data type adopted by an intelligent contract object is different from a data type adopted by the blockchain ledger, and therefore, data type conversion is required in the interaction process of the intelligent contract and the blockchain ledger.
In the prior art, two conversion methods are mainly adopted for data type conversion, wherein the method comprises the following steps: serializing Java intelligent contract objects into Json character strings through a Json class library Gson of Java, and realizing data interaction between the Java intelligent contracts and a block chain account book through the Json character strings; the second method comprises the following steps: and deserializing the json character strings into Java intelligent contract objects to realize data interaction between the block chain ledger and the Java intelligent contracts.
However, in the above two conversion methods, the character string formed after conversion is large, which causes inconvenience in data transmission and storage, or the conversion efficiency is low and the time consumption is long.
Disclosure of Invention
The application provides a data conversion method, a data conversion device, equipment and a storage medium, and aims to solve the technical problems that when an existing intelligent contract is interacted with a block chain account book, the conversion efficiency of an intelligent contract object is low, the data volume of a character string formed by conversion is large, and transmission and storage are inconvenient.
In a first aspect, the present application provides a data conversion method, including:
acquiring an intelligent contract object;
determining the field type of each field of the intelligent contract object;
calling a preset coding method according to the field type of each field of the intelligent contract object, and respectively carrying out serialization processing on each field of the intelligent contract object to obtain a plurality of corresponding sub-byte streams;
and splicing the plurality of sub byte streams to obtain byte stream data corresponding to the intelligent contract object so as to complete data conversion of the intelligent contract object.
In a possible implementation manner of the present application, the field type includes a first type and a second type, the encoding method includes a first encoding method and a second encoding method, the plurality of sub-byte streams include a first sub-byte stream and a second sub-byte stream, a preset encoding method is invoked according to the field type of each field of the intelligent contract object, and each field of the intelligent contract object is respectively serialized to obtain a plurality of corresponding sub-byte streams, including:
if the field type of the field is the first type, calling a first coding method to carry out serialization processing on the field to obtain a first sub byte stream;
and if the field type of the field is the second type, calling a second encoding method to carry out serialization processing on the field to obtain a second sub byte stream.
In one possible implementation manner of the present application, the first encoding method includes:
acquiring a field name, a field value and a first coded value of a field, wherein the first coded value is a preset first type coded value;
determining the byte number of the field according to the field type of the field;
and obtaining a first sub-byte stream according to the field name, the first coding value, the byte number and the field value.
In one possible implementation manner of the present application, the first type includes integer, and after acquiring a field name, a field value, and a first encoded value of a field, the method further includes:
and judging whether the field type of the field is integer, and if the field type is integer, obtaining a first sub-byte stream according to the field name, the first coded value and the field value.
In one possible implementation manner of the present application, the second encoding method includes:
acquiring a field name, a field value and a second coded value of the field, wherein the second coded value is a preset coded value of a second type;
performing recursion processing on the field to obtain a first recursion byte stream;
and obtaining a second sub-byte stream according to the field name, the second coding value and the first recursive byte stream.
In a possible implementation manner of the present application, after the splicing processing is performed on the plurality of sub byte streams to obtain byte stream data corresponding to the intelligent contract object, the method further includes:
acquiring byte stream data and determining type identifications carried by a plurality of sub-byte streams respectively;
calling a preset decoding method according to the type identifiers carried by the sub-byte streams respectively, and performing deserialization processing on the sub-byte streams to obtain each field of the intelligent contract object;
and splicing each field of the intelligent contract object to obtain the intelligent contract object corresponding to the byte stream data so as to complete the data conversion of the byte stream data.
In a possible implementation manner of the present application, the type identifier includes a first identifier and a second identifier, the decoding method includes a first decoding method and a second decoding method, the intelligent contract object includes a first field and a second field, a preset decoding method is called according to the type identifiers carried by the plurality of sub-byte streams, and the plurality of sub-byte streams are deserialized respectively to obtain fields of the intelligent contract object, including:
if the type identifier carried by the sub byte stream is a first identifier, calling a first decoding method to perform deserialization processing on the sub byte stream to obtain a first field;
and if the type identifier carried by the sub byte stream is a second coding value, calling a second decoding method to perform deserialization processing on the sub byte stream to obtain a second field.
In a second aspect, the present application further provides a data conversion apparatus, including:
the acquisition module is used for acquiring the intelligent contract object;
the processing module is used for determining the field type of each field of the intelligent contract object;
calling a preset coding method according to the field type of each field of the intelligent contract object, and respectively carrying out serialization processing on each field of the intelligent contract object to obtain a plurality of corresponding sub-byte streams;
and the output module is used for splicing the plurality of sub byte streams to obtain byte stream data corresponding to the intelligent contract object so as to complete data conversion of the intelligent contract object.
In a possible implementation manner of the present application, the field type includes a first type and a second type, the encoding method includes a first encoding method and a second encoding method, the plurality of sub-byte streams include a first sub-byte stream and a second sub-byte stream, and the processing module is specifically configured to:
if the field type of the field is the first type, calling a first coding method to carry out serialization processing on the field to obtain a first sub byte stream;
and if the field type of the field is the second type, calling a second encoding method to carry out serialization processing on the field to obtain a second sub byte stream.
In one possible implementation manner of the present application, the processing module is further specifically configured to:
acquiring a field name, a field value and a first coded value of a field, wherein the first coded value is a preset first type coded value;
determining the byte number of the field according to the field type of the field;
and obtaining a first sub-byte stream according to the field name, the first coding value, the byte number and the field value.
In one possible implementation manner of the present application, the first type includes an integer, and the processing module is further specifically configured to:
and judging whether the field type of the field is integer, and if the field type is integer, obtaining a first sub-byte stream according to the field name, the first coded value and the field value.
In one possible implementation manner of the present application, the processing module is further specifically configured to:
acquiring a field name, a field value and a second coded value of the field, wherein the second coded value is a preset coded value of a second type;
performing recursion processing on the field to obtain a first recursion byte stream;
and obtaining a second sub-byte stream according to the field name, the second coding value and the first recursive byte stream.
In a possible implementation manner of the present application, the obtaining module is specifically further configured to obtain byte stream data and determine type identifiers carried by a plurality of sub-byte streams respectively;
the processing module is specifically used for calling a preset decoding method according to the type identifiers carried by the plurality of sub-byte streams respectively, and performing deserialization processing on the plurality of sub-byte streams respectively to obtain each field of the intelligent contract object;
and the output module is specifically used for splicing each field of the intelligent contract object to obtain the intelligent contract object corresponding to the byte stream data so as to complete data conversion of byte stream data.
In one possible implementation manner of the present application, the type identifier includes a first identifier and a second identifier, the decoding method includes a first decoding method and a second decoding method, the smart contract object includes a first field and a second field, and the processing module is further specifically configured to:
if the type identifier carried by the sub byte stream is a first identifier, calling a first decoding method to perform deserialization processing on the sub byte stream to obtain a first field;
and if the type identifier carried by the sub byte stream is a second identifier, calling a second decoding method to perform deserialization processing on the sub byte stream to obtain a second field.
In a third aspect, the present application further provides a data conversion apparatus, including:
one or more processors;
a memory; and
one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the data conversion method of the first aspect.
In a fourth aspect, the present application also provides a computer-readable storage medium, on which a computer program is stored, the computer program being loaded by a processor to perform the steps in the data conversion method of the first aspect.
In the application, each field of the intelligent contract object is converted into the sub byte stream respectively, and then all the sub byte streams are spliced to obtain byte stream data, namely the intelligent contract object is converted into binary byte stream data; meanwhile, the corresponding coding method is called according to the field type of each field of the intelligent contract object, all intelligent contracts do not need to be converted, and the conversion content is less, so that the serialization conversion efficiency is improved, the conversion time is reduced, the execution speed is high, and convenience is further provided for data interaction between the intelligent contracts and the block chain account book.
Drawings
In order to more clearly illustrate the technical solutions in the present application, the drawings that are needed to be used in the description of the present application will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without inventive effort.
FIG. 1 is a schematic diagram of a scenario of an embodiment of a data conversion system provided in the present application;
FIG. 2 is a schematic flow chart diagram illustrating one embodiment of a data transformation method provided herein;
FIG. 3 is a flow diagram illustrating one embodiment of generating a first sub-byte stream;
FIG. 4 is a flow diagram illustrating one embodiment of generating a second sub-byte stream;
FIG. 5 is a schematic flow chart diagram illustrating another embodiment of a data conversion method provided herein;
FIG. 6 is a schematic block diagram of an embodiment of a data conversion device provided in the present application;
fig. 7 is a schematic structural diagram of an embodiment of a data conversion device provided in the present application.
Detailed Description
The technical solutions in the present application will be described clearly and completely with reference to the accompanying drawings in the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the description of the present application, it is to be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", and the like indicate orientations or positional relationships based on those shown in the drawings, and are used merely for convenience of description and for simplicity of description, and do not indicate or imply that the referenced device or element must have a particular orientation, be constructed in a particular orientation, and be operated, and thus should not be considered as limiting the present application. Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more features. In the description of the present application, "a plurality" means two or more unless specifically limited otherwise.
In this application, the word "exemplary" is used to mean "serving as an example, instance, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments. The following description is presented to enable any person skilled in the art to make and use the application. In the following description, details are set forth for the purpose of explanation. It will be apparent to one of ordinary skill in the art that the present application may be practiced without these specific details. In other instances, well-known structures and processes are not set forth in detail in order to avoid obscuring the description of the present application with unnecessary detail. Thus, the present application is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed herein.
The present application provides a data conversion method, apparatus, device and storage medium, which are described in detail below.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a data conversion system according to an embodiment of the present application, where the data conversion system may include a blockchain platform 100 and a terminal device 200 communicatively connected to the blockchain platform 100, a Java intelligent contract and a blockchain ledger for data interaction with the Java intelligent contract are deployed on the blockchain platform 100, and the blockchain ledger stores immutable and ordered records in a block. The execution of the Java intelligent contract depends on a Java Virtual Machine (JVM), that is, an execution engine of the Java intelligent contract is a JVM, and in the data conversion system, data conversion between the Java intelligent contract and a blockchain ledger is realized through the JVM.
In the present application, the blockchain platform 100 may be a blockchain platform based on a multi-chain architecture, or may be a blockchain platform based on a historically proven high performance underlying blockchain protocol, such as the blockchain platform 100 described herein, which includes but is not limited to a wakapoliot blockchain platform, a Hedera Hashgraph blockchain platform, a tiffany Dfinity blockchain platform, or a soranna Solana blockchain platform.
In this application, the network communication between the blockchain platform 100 and the terminal device 200 may be implemented by any communication method, including but not limited to mobile communication based on the third Generation Partnership Project (3 GPP), Long Term Evolution (LTE), Worldwide Interoperability for Microwave Access (WiMAX), or computer network communication based on the TCP/IP Protocol Suite (TCP/IP), User Datagram Protocol (UDP), and the like. The terminal device 200 may upload data to the blockchain platform 100 through the above communication manner to trigger the JVM to implement execution of the Java smart contract.
In this application, the terminal device 200 may be a general-purpose computer device or a special-purpose computer device. In a specific implementation, the terminal device 200 may be a palm computer, a Personal Digital Assistant (PDA), a mobile phone, a tablet computer, a wireless terminal device, and the like, and the application does not limit the type of the terminal device 200.
Those skilled in the art can understand that the application environment shown in fig. 1 is only one application scenario adapted to the present application scheme, and does not constitute a limitation of the application scenario of the present application scheme, and that other application scenarios may further include more or fewer terminal devices 200 than those shown in fig. 1, for example, only 2 terminal devices 200 are shown in fig. 1, and it can be understood that the data conversion system may further include other terminal devices communicatively connected to the blockchain platform 100, which is not limited herein.
It should be noted that the scenario diagram of the data conversion system shown in fig. 1 is merely an example, the data conversion system and the scenario described in this application are for more clearly illustrating the technical solution of this application, and do not constitute a limitation to the technical solution provided in this application, and as a person having ordinary skill in the art knows, the technical solution provided in this application is also applicable to similar technical problems with the evolution of the data conversion system and the appearance of new service scenarios.
Firstly, the present application provides a data conversion method, the data conversion method is applied to a Java intelligent contract execution engine JVM, the JVM is located in a data conversion system, the data conversion method includes: acquiring an intelligent contract object; determining the field type of each field of the intelligent contract object; calling a preset coding method according to the field type of each field of the intelligent contract object, and respectively carrying out serialization processing on each field of the intelligent contract object to obtain a plurality of corresponding sub-byte streams; and splicing the plurality of sub byte streams to obtain byte stream data corresponding to the intelligent contract object so as to complete data conversion of the intelligent contract object.
Fig. 2 is a schematic flow chart illustrating an embodiment of a data conversion method provided in the present application. It should be noted that while a logical order is shown in the flow diagram, in some cases, the steps shown or described may be performed in an order different than presented herein. The data conversion method is applied to a Java intelligent contract execution engine JVM which is positioned in a data conversion system, and comprises the following steps:
s201, obtaining the intelligent contract object.
In the embodiment of the application, when an intelligent contract is called or data modification exists, the JVM needs to transmit an intelligent contract object to a blockchain ledger for storing the JVM to obtain the intelligent contract object, which may be actively obtained from the intelligent contract, for example, by periodically accessing the intelligent contract, if the intelligent contract is called or modified, a new intelligent contract object may exist, and the JVM may actively obtain the new intelligent contract object; in addition, the manner in which the JVM obtains the smart contract object may also be passively obtained from the smart contract, for example, after the smart contract is called or modified, a new smart contract object is formed, and the smart contract sends the new smart contract object to the JVM, so that the JVM converts the received smart contract object so as to facilitate transmission and storage between the smart contract and the blockchain ledger.
In addition, in this embodiment of the application, the smart contract object may include a plurality of fields, each field being used to represent a part of the smart contract object, and after the smart contract object is obtained, the data type and the number of the plurality of fields of the smart contract object may be determined. For example, a smart contract object (e.g., "DATA 01") includes 4 fields, respectively, a field "Z1", a field "Z2", a field "Z3", and a field "Z4", then the smart contract object "DATA 01" may be represented as "Z1Z 2Z3Z 4".
S202, determining the field type of each field of the intelligent contract object.
In the embodiment of the application, the intelligent contract object may include a plurality of fields, each of the fields may have a corresponding field type, and in addition, a field name and a field value of each field may also be obtained at the same time, and each of the fields may have different field types, field names and field values, and since each field needs to be distinguished, each field may be uniquely identified by a field name, so that the field names of each field in the intelligent contract object are all different, and the field types and field values of each field may be the same or different; in addition, the field type of each field may be the same as the data type of the smart contract object or different from the data type of the smart contract object.
For example, the smart contract object "DATA 01" may include 4 fields, such as a field "Z1", a field "Z2", a field "Z3", and a field "Z4", where the field type of the field "Z1" is a first type, the field name is 001, and the field value is x 1; the field type of the field "Z2" is a first type, the field name is 002, and the field value is x 2; the field type of the field "Z3" is a first type, the field name is 003, the field value is x 3; the field type of the field "Z4" is a second type, the field name is 004, and the field value is x 4.
And S203, calling a preset coding method according to the field type of each field of the intelligent contract object, and respectively carrying out serialization processing on each field of the intelligent contract object to obtain a plurality of corresponding sub-byte streams.
In the embodiment of the present application, each field of the intelligent contract object may be serialized by calling a preset encoding method, and since the field types of each field may be the same or different, in this embodiment of the present application, a corresponding encoding method may be preset for different field types, and the corresponding field is encoded by an encoding method matched with the field type, so as to implement serialization of the field into a sub-byte stream. For example, for a field whose field type is a second type, it may be recursively serialized to generate a corresponding sub-byte stream; for fields whose field type is the first type, they can be directly serialized to generate the corresponding sub-byte stream.
For example, the field "Z4" with the field type of the second type is recursively serialized to obtain a sub-byte stream "004L 4", and the field "Z1" with the field type of the first type is recursively serialized to obtain a sub-byte stream "001L 1".
In addition, when the fields of the intelligent contract object are serialized, each field can be serialized one by one according to the sequence of each field to obtain the corresponding sub byte stream. It should be noted that, in this embodiment of the present application, the fields may not be serialized according to the sequence of the fields, as long as the sequence of the fields is recorded before serialization, so as to subsequently splice the multiple sub-byte streams according to the recorded sequence, in short, as long as the splicing sequence of the multiple sub-byte streams is ensured to be consistent with the sequence of the fields, any sequence may be used to serialize the multiple fields, specifically which sequence is used to serialize the multiple fields, which may be set or selected according to an actual application scenario, and this is not limited herein.
For example, when serializing the field "Z1", the field "Z2", the field "Z3" and the field "Z4" of the smart contract object "DATA 01", the field "Z1", the field "Z2", the field "Z3" and the field "Z4" may be serialized one by one, that is, the field "Z1" is serialized first, then the field "Z2", the field "Z3" is serialized last, and the field "Z4"; or the field "Z1", the field "Z2", the field "Z3" and the field "Z4" may be serialized in reverse order, i.e., the field "Z4" is serialized first, then the field "Z3", the field "Z2" is serialized, and finally the field "Z1"; in addition, the field "Z1", the field "Z2", the field "Z3" and the field "Z4" may be serialized in a chaotic manner, i.e., the field "Z2" may be serialized first, the field "Z3", the field "Z4" may be serialized first, and the field "Z1" may be serialized last.
And S204, splicing the plurality of sub byte streams to obtain byte stream data corresponding to the intelligent contract object so as to complete data conversion of the intelligent contract object.
In this embodiment of the application, in S203, each field of the intelligent contract object is respectively serialized, and after the corresponding sub-byte stream is obtained, the multiple sub-byte streams need to be spliced, and a splicing sequence of the splicing process needs to be consistent with an arrangement sequence of the multiple fields, that is, according to the arrangement sequence of the multiple fields, the corresponding sub-byte streams are spliced, so as to obtain byte stream data corresponding to the intelligent contract object.
For example, when the field "Z1", the field "Z2", the field "Z3" and the field "Z4" of the smart contract object "DATA 01" are serialized, one by one, the field "Z1", the field "Z2", the field "Z3" and the field "Z4" are serialized according to the field arrangement order, that is, the field "Z1" is serialized to obtain the sub-byte stream "001L 1", the field "Z2" is serialized to obtain the sub-byte stream "002L 2", the field "Z3" is serialized to obtain the sub-byte stream "003L 3", and the field "Z4" is serialized to obtain the sub-byte stream "004L 4"; when a plurality of sub-byte streams are spliced, the sub-byte Stream should also be spliced in the order of sub-byte Stream "001L 1", sub-byte Stream "002L 2", sub-byte Stream "003L 3" and sub-byte Stream "004L 4", and the obtained byte Stream data (such as "Stream 01") is "001L 1002L2003L3004L 4".
In the embodiment of the application, each field of the intelligent contract object is respectively converted into the sub byte stream, and then all the sub byte streams are spliced to obtain byte stream data, namely the intelligent contract object is converted into binary byte stream data; meanwhile, the corresponding coding method is called according to the field type of each field of the intelligent contract object, all intelligent contracts do not need to be converted, and the conversion content is less, so that the serialization conversion efficiency is improved, the conversion time is reduced, the execution speed is high, and convenience is further provided for data interaction between the intelligent contracts and the block chain account book.
In some embodiments of the present application, the field type may include a first type and a second type, the encoding method may include a first encoding method and a second encoding method, the plurality of sub-byte streams may include a first sub-byte stream and a second sub-byte stream, a preset encoding method is called according to the field type of each field of the intelligent contract object, and each field of the intelligent contract object is respectively serialized to obtain a plurality of corresponding sub-byte streams, and the method may further include:
and if the field type of the field is the first type, calling a first encoding method to carry out serialization processing on the field to obtain a first sub byte stream.
In this embodiment of the present application, the first encoding method may be used to encode a field whose field type is a first type, specifically, as shown in fig. 3, which is a flowchart illustrating an embodiment of generating a first sub-byte stream in this application, the first encoding method may further include:
s301, acquiring a field name, a field value and a first encoding value of the field, wherein the first encoding value is a preset first type of encoding value.
In the embodiment of the present application, the first type may be a basic data type, a package type of the basic data type, and the like, wherein, the basic data type can be Integer int, the packaging type corresponding to Integer int is Integer Inter, the basic data type can also be Double-precision floating point Double, the packaging type corresponding to Double-precision floating point Double is Double-precision floating point Double, in addition, the basic data type can also be short integer short, long integer long, floating point float, character char, Boolean bolean, etc., the basic data type Short integer Short, Long integer Long, floating point Float, character type Char and Boolean type Boolean have their corresponding package type Short integer Short, Long integer Long, floating point Float, character type Char and Boolean respectively, in the embodiment of the present application, a corresponding code value, i.e., a first code value, is preset for each of the basic data types and the encapsulation types thereof. In addition, please refer to S202 for description of the field name and the field value, which is not described herein again.
If the field type of the field "Z1" of the smart contract object "DATA 01" is integer int, its corresponding first code value may be 0x 49; the field type of the field "Z2" is double precision floating point type double, and the corresponding first encoded value may be 0x 44; the field type of the field "Z3" is integer int, which corresponds to a first code value identical to the field "Z1" and is 0x 49.
S302, determining the byte number of the field according to the field type of the field.
In Java, the memories occupied by different data types are different, and a basic data type is described below as an example, for integer int, the data type is used to store an integer, and occupies 32 bits in the memory, that is, 4 bytes, that is, if the field type of a field is integer int in a non-reference type, the byte number of the field is 4; for double precision floating point type double, the data type is used for storing the number with decimal point, and it takes 64 bits in the memory, that is, 8 bytes, that is, if the field type of the field is double precision floating point type double in the non-reference type, the byte number of the field is 8.
For example, for the field "Z1" of the smart contract object "DATA 01," the field type is integer int, the number of bytes of the field "Z1" is 4, the field type of the field "Z2" is double-precision floating-point double, the number of bytes of the field "Z2" is 8, the field type of the field "Z3" is integer int, and the number of bytes of the field "Z3" is 4.
S303, obtaining a first sub-byte stream according to the field name, the first coding value, the byte number and the field value.
In this embodiment of the present application, the first encoding method may be a Type Length Value (TLV) encoding method, that is, a TLV encoding method may be used to obtain the first sub-byte stream by serializing a field, specifically, a field name, a first encoded Value, a byte number, and a field Value may be spliced to obtain the first sub-byte stream of a corresponding field, and since the field name of each field is different, in this embodiment of the present application, the first sub-byte stream corresponding to each field is also different. In addition, the splicing sequence may be selected according to a specific application scenario, and in addition to splicing according to the field name, the first encoded value, the byte number and the field value, splicing according to the field name, the byte number, the first encoded value and the field value, and so on may also be performed. It should be noted that the TLV encoding method is only an example of the first encoding method, and other encoding methods in the Java field are also applicable to the embodiments of the present application, and are not limited herein.
If the field "Z1" of the smart contract object "DATA 01" has a field name of 001, a field value of x1, and a field type of int, the first encoding value is 0x49, the byte number is 4, and the corresponding first sub-byte stream is "0010 x494x 1"; a field "Z2", whose field name is 002, field value is x2, and field type is double precision floating point double, then its first code value is 0x44, byte number is 8, and its corresponding first sub-byte stream is "0020 x448x 2"; the field "Z3" has a field name of 003, a field value of x3, and a field type of int, and thus has a first code value of 0x49 and a byte number of 4, and corresponds to a first sub-byte stream of "0030 x494x 3".
In addition, since the first type of the field types may include integer, after the field name, the field value, and the first encoding value of the field are obtained in S301, the method may further include:
and judging whether the field type of the field is integer, and if the field type is integer, obtaining a first sub-byte stream according to the field name, the first coded value and the field value.
In this embodiment of the present application, for a field with an integer field type, a variant variants coding may be used to reduce bytes required for storing the first sub-byte stream, specifically, a field name, a first coding value, and a field value corresponding to the field with the integer field type may be spliced to obtain the corresponding first sub-byte stream.
Then, for the field "Z1" of the smart contract object "DATA 01", since the field type is integer int, the field name 001, the first encoded value 0x49, and the field value x1 may be spliced, and the obtained first sub-byte stream is "0010 x49x 1"; and since the field type of the field "Z3" is integer int, the field name 003, the first encoded value 0x49, and the field value x3 can be similarly concatenated, and the obtained first sub-byte stream is "0030 x49x 3".
In the embodiment of the present application, if the field type of the field is the second type, a second encoding method is called to perform serialization processing on the field, so as to obtain a second sub-byte stream.
In this embodiment of the application, the second encoding method may be used to encode a field whose field type is the second type, specifically, as shown in fig. 4, which is a flowchart illustrating an embodiment of generating the second sub-byte stream in this application, the second encoding method may further include:
s401, acquiring a field name, a field value and a second encoding value of the field, wherein the second encoding value is a preset second type encoding value.
Similarly, please refer to S202 for the description of the field name and the field value, which is not repeated herein. In this embodiment of the present application, the second type may be a reference type, and it should be noted that, although the encapsulation type of the basic data type belongs to the reference type in the Java field, in this embodiment of the present application, the encapsulation type of the basic data type belongs to the first type, and the reference type referred in this embodiment is a reference type other than the encapsulation type of the basic data type, in Java, unlike the data of the basic data type that is allocated on a stack, the data of the reference type is stored by using a memory heap and a memory stack, specifically, the object of the reference type is stored on an ordered memory stack, and the value of the object itself is stored on the memory heap, that is, the data of the reference type is allocated on the heap, and points to the address of the referenced object, that is, its field value is an address, and the reference type may be a class, a reference type, or a, Interface, array, etc. In the embodiment of the present application, the second encoding value may be a preset second type encoding value, for example, for the field "Z4" of the smart contract object "DATA 01", the field type thereof is a reference type, and the second encoding value thereof may be 0x 50.
S402, carrying out recursion processing on the field to obtain a first recursion byte stream.
In the embodiment of the present application, since the field value of the field of the reference type is not a specific numerical value, but an address of the object referred to by the field value, the field of the field type as the reference type may be recursively processed, and if the address pointed to by the field is stored in an object of a reference type, the object needs to be recursively serialized to obtain the first recursive byte stream.
For example, if the field type of the field "Z4" of the smart contract object is a reference type, and the field value x4 of the smart contract object is an address, and the address stores one reference object a, the first recursive byte stream corresponding to the field "Z4" is a byte stream aa obtained by recursively serializing the reference object a.
And S403, obtaining a second sub byte stream according to the field name, the second coding value and the first recursive byte stream.
In this embodiment of the present application, the field name, the second encoded value, and the first recursive byte stream of each field whose field type is the reference type may be spliced to obtain the second sub-byte stream of the corresponding field, and similarly, since the field names of each field are different, in this embodiment of the present application, the second sub-byte stream corresponding to each field is also different. In addition, the splicing sequence may be selected according to a specific application scenario, and may be spliced according to a field name, a second encoding value, and a first recursive byte stream, or according to a field name, a first recursive byte stream, and a second encoding value, which is not limited herein.
For example, for a field "Z4" of an intelligent contract object, the field name is 004, the field type is a reference type, the second encoded value is 0x50, the field value is x4, the field value x4 is an address, the address stores a reference object a, the first recursive byte stream corresponding to the field "Z4" is aa, the field name 004, the second encoded value 0x50, and the first recursive byte stream aa are spliced, and the obtained second sub byte stream is "0040 x50 aa".
As shown in fig. 5, which is a schematic flow chart of another embodiment of the data conversion method provided in the present application, in some embodiments of the present application, after the multiple sub-byte streams are spliced to obtain byte stream data corresponding to an intelligent contract object, the method may further include:
s501, byte stream data is obtained, and type identifications carried by a plurality of sub byte streams are determined.
In this embodiment of the present application, the JVM may further convert byte stream data recorded in a blockchain ledger book into an intelligent contract object, specifically, the JVM may obtain byte stream data from the blockchain ledger book, where the byte stream data is obtained by splicing a plurality of sub-byte streams, and each sub-byte stream of the byte stream data carries a corresponding type identifier, and the type identifier may include a first identifier and a second identifier, and the type identifier may be used to identify a type of a field corresponding to each sub-byte stream, so in this embodiment of the present application, the first identifier may be equal to a first encoded value, the second identifier may be equal to a second encoded value, and since the field type corresponding to the first encoded value is a first type, the field type corresponding to the second encoded value is a second type, and the first type may include a basic data type and an encapsulation type, therefore, in the embodiment of the present application, the first encoded value may have a plurality of different values.
For example, the byte Stream data "Stream 01" is "001L 1002L2003L3004L 4", which includes 4 sub-byte streams, respectively, sub-byte Stream "001L 1", sub-byte Stream "002L 2", sub-byte Stream "003L 3", and sub-byte Stream "004L 4", wherein the type identifier carried by sub-byte Stream "001L 1" is a first identifier, i.e., a first encoded value, and the first encoded value is 0x 49; the type identifier carried by the sub byte stream "002L 2" is a first identifier, i.e. a first encoded value, and the first encoded value is 0x 44; the type identifier carried by the sub byte stream "003L 3" is a first identifier, i.e., a first encoded value, and the first encoded value is 0x 49; the type identifier carried by the sub byte stream "004L 4" is a second identifier, i.e., a second encoded value, which is 0x 50.
And S502, calling a preset decoding method according to the type identifiers carried by the plurality of sub-byte streams respectively, and performing deserialization processing on the plurality of sub-byte streams to obtain each field of the intelligent contract object.
In this embodiment of the present application, the decoding method may include a first decoding method and a second decoding method, the intelligent contract object may include a first field and a second field, the first field corresponds to the first sub-byte stream, and the second field corresponds to the second sub-byte stream, specifically, if the type identifier carried in the sub-byte stream is the first identifier, the first decoding method is invoked to perform deserialization processing on the sub-byte stream, so as to obtain the first field.
The first decoding method is used for decoding a first sub-byte stream converted from a first type of field, and the first sub-byte stream is obtained by splicing according to a field name, a first coded value, byte number and a field value, so that the first sub-byte stream is subjected to deserialization, the first sub-byte stream is deserialized according to the splicing sequence of the field name, the first coded value, the byte number and the field value during serialization, and the field name, the first coded value, the byte number and the field value are further obtained from the first sub-byte stream to obtain a corresponding first field.
For example, for byte Stream data "Stream 01", whose sub-byte Stream "001L 1" is the first sub-byte Stream "0010 x494x 1", after deserialization, a field name 001 may be obtained, the first encoded value is 0x49, the number of bytes is 4, and the field value is x1, and since the field type corresponding to the first encoded value 0x49 is integer int, the field name of the first field corresponding to the sub-byte Stream "001L 1" may be obtained as 001, the field type is integer int, the number of bytes is 4, and the field value is x 1; the sub-byte stream "002L 2" is a first sub-byte stream "0020 x448x 2", after deserialization, a field name of 002 can be obtained, the first coded value is 0x44, the byte number is 8, and the field value is x2, and because the field type corresponding to the first coded value 0x44 is a double-precision floating-point type double, the field name of the first field corresponding to the sub-byte stream "002L 2" can be obtained, the field type is a double-precision floating-point type double, the byte number is 8, and the field value is x 2; the sub-byte stream "003L 3" is a first sub-byte stream "0030 x494x 3", after deserialization, a field name 003, a first code value 0x49, a byte number 4, and a field value x3 can be obtained, and since a field type corresponding to the first code value 0x49 is integer int, a field name 003, a field type int, a byte number 4, and a field value x3 of a first field corresponding to the sub-byte stream "003L 3" can be obtained.
Further, according to the method for serializing a first sub-byte stream described above, if the field type is integer, the first sub-byte stream can be obtained from the field name, the first encoded value, and the field value, and the first sub-byte stream can also be obtained by concatenating the field name, the first encoded value, and the field value.
In this embodiment of the present application, the second decoding method is used to decode the second sub byte stream converted from the field of the second type, and the second sub byte stream is obtained by splicing the field name, the second encoded value, and the first recursive byte stream, so that the second sub byte stream is deserialized according to the second decoding method according to the splicing order of the field name, the second encoded value, and the first recursive byte stream during serialization, and the field name, the second encoded value, and the first recursive byte stream is further obtained from the second sub byte stream to obtain the corresponding second field.
For example, for the byte Stream data "Stream 01", the sub byte Stream "004L 4" is the second sub byte Stream "0040 x50 aa", after deserialization, the field name is 004, the second encoded value is 0x50, the first recursive byte Stream is aa, and then deserialization is performed on the first recursive byte Stream to obtain the corresponding reference object a, and further obtain the address x4 of the reference object a, and since the field type corresponding to the second encoded value 0x50 is the second type, the field name of the second field corresponding to the sub byte Stream "004L 4" is 004, the field type is the reference type, and the field value is x 4.
And S503, splicing each field of the intelligent contract object to obtain the intelligent contract object corresponding to the byte stream data so as to complete data conversion of the byte stream data.
In the embodiment of the application, the splicing sequence of splicing the fields of the intelligent contract object needs to be consistent with the arrangement sequence of the sub-byte streams, that is, the corresponding fields are spliced according to the arrangement sequence of the sub-byte streams, so as to obtain the intelligent contract object corresponding to the byte stream data.
For example, when deserializing the sub-byte Stream "001L 1", the sub-byte Stream "002L 2", the sub-byte Stream "003L 3" and the sub-byte Stream "004L 4" of the byte Stream data "Stream 01", the sub-byte Stream "001L 1", the sub-byte Stream "002L 2", the sub-byte Stream "003L 3" and the sub-byte Stream "004L 4" are performed one by one according to the arrangement order of the sub-byte streams, that is, the sub-byte Stream "001L 1" is deserialized first to obtain the field "Z1", the sub-byte Stream "002L 2" is deserialized to obtain the field "Z2", the sub-byte Stream "003L 3" is deserialized to obtain the field "Z3", and the sub-byte Stream "004L 4" is deserialized to obtain the field "Z4"; when the multiple fields are spliced, the fields are spliced according to the sequence of the field "Z1", the field "Z2", the field "Z3" and the field "Z4", and the obtained smart contract object (such as "DATA 01") is "Z1Z 2Z3Z 4".
In order to better implement the data conversion method in the present application, the present application further provides a data conversion apparatus, as shown in fig. 6, which is a schematic structural diagram of an embodiment of the data conversion apparatus provided in the present application, and the data conversion apparatus includes:
an obtaining module 601, configured to obtain an intelligent contract object;
a processing module 602, configured to determine field types of fields of the smart contract object;
calling a preset coding method according to the field type of each field of the intelligent contract object, and respectively carrying out serialization processing on each field of the intelligent contract object to obtain a plurality of corresponding sub-byte streams;
and the output module 603 is configured to splice the multiple sub-byte streams to obtain byte stream data corresponding to the intelligent contract object, so as to complete data conversion of the intelligent contract object.
In the application, each field of an intelligent contract object is respectively converted into the sub byte stream by the processing module, all the sub byte streams are spliced by the output module to obtain byte stream data, namely, the intelligent contract object is converted into binary byte stream data, and compared with the prior art that Java intelligent contract objects are serialized into json character strings through Gson, the data volume of byte stream data is smaller than that of the json character strings, so that the data transmission efficiency is improved, and the storage space occupied by byte stream data storage is reduced; meanwhile, the corresponding coding method is called according to the field type of each field of the intelligent contract object, all intelligent contracts do not need to be converted, and the conversion content is less, so that the serialization conversion efficiency is improved, the conversion time is reduced, the execution speed is high, and convenience is further provided for data interaction between the intelligent contracts and the block chain account book.
In some embodiments of the present application, the field type includes a first type and a second type, the encoding method includes a first encoding method and a second encoding method, the plurality of sub-bytes include a first sub-byte stream and a second sub-byte stream, and the processing module 602 may be specifically configured to:
if the field type of the field is the first type, calling a first coding method to carry out serialization processing on the field to obtain a first sub byte stream;
and if the field type of the field is the second type, calling a second encoding method to carry out serialization processing on the field to obtain a second sub byte stream.
In some embodiments of the present application, the processing module 602 may further be specifically configured to:
acquiring a field name, a field value and a first coded value of a field, wherein the first coded value is a preset first type coded value;
determining the byte number of the field according to the field type of the field;
and obtaining a first sub-byte stream according to the field name, the first coding value, the byte number and the field value.
In some embodiments of the present application, the first type includes an integer, and the processing module 602 may further be specifically configured to:
and judging whether the field type of the field is integer, and if the field type is integer, obtaining a first sub-byte stream according to the field name, the first coded value and the field value.
In some embodiments of the present application, the processing module 602 may further be specifically configured to:
acquiring a field name, a field value and a second coded value of the field, wherein the second coded value is a preset coded value of a second type;
performing recursion processing on the field to obtain a first recursion byte stream;
and obtaining a second sub-byte stream according to the field name, the second coding value and the first recursive byte stream.
In some embodiments of the present application, the obtaining module 601 may be further specifically configured to: acquiring byte stream data and determining type identifications carried by a plurality of sub-byte streams respectively;
the processing module 602 may further be specifically configured to: calling a preset decoding method according to the type identifiers carried by the plurality of sub-byte streams respectively, and performing deserialization processing on the plurality of sub-byte streams respectively to obtain each field of the intelligent contract object;
the output module 603 may be specifically configured to: and splicing each field of the intelligent contract object to obtain the intelligent contract object corresponding to the byte stream data so as to complete the data conversion of the byte stream data.
In some embodiments of the present application, the type identifier includes a first identifier and a second identifier, the decoding method includes a first decoding method and a second decoding method, the smart contract object includes a first field and a second field, and the processing module 602 may further be specifically configured to:
if the type identifier carried by the sub byte stream is a first identifier, calling a first decoding method to perform deserialization processing on the sub byte stream to obtain a first field;
and if the type identifier carried by the sub byte stream is a second identifier, calling a second decoding method to perform deserialization processing on the sub byte stream to obtain a second field.
It should be noted that, in the present application, the relevant contents of the obtaining module 601, the processing module 602, and the output module 603 correspond to the above one to one, and it can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working process of the data conversion apparatus and the corresponding modules described above may refer to the description of the data conversion method in any embodiment corresponding to fig. 2 to fig. 5, and details are not repeated herein.
In order to better implement the data conversion method of the present application, on the basis of the data conversion method, the present application further provides a data conversion device, which integrates any one of the data conversion apparatuses provided by the present application, and the device includes:
one or more processors 701;
a memory 702; and
one or more application programs, wherein the one or more application programs are stored in the memory 702 and configured to be executed by the processor 701 for performing the steps of the data conversion method of any of the embodiments of the data conversion method described above.
Fig. 7 is a schematic diagram showing a structure of an embodiment of the data conversion device according to the present application, specifically:
the apparatus may include components such as a processor 701 of one or more processing cores, memory 702 of one or more computer-readable storage media, a power supply 703, and an input unit 704. Those skilled in the art will appreciate that the configuration of the apparatus shown in fig. 7 is not intended to be limiting of the apparatus and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the processor 701 is a control center of the apparatus, connects various parts of the entire apparatus using various interfaces and lines, and performs various functions of the apparatus and processes data by running or executing software programs and/or modules stored in the memory 702 and calling data stored in the memory 702, thereby performing overall monitoring of the apparatus. Optionally, processor 701 may include one or more processing cores; the Processor 701 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, preferably the processor 701 may integrate an application processor, which handles primarily the operating system, user interfaces, application programs, etc., and a modem processor, which handles primarily wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 701.
The memory 702 may be used to store software programs and modules, and the processor 701 executes various functional applications and data processing by operating the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to use of the device, and the like. Further, the memory 702 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 702 may also include a memory controller to provide the processor 701 with access to the memory 702.
The device further includes a power supply 703 for supplying power to the various components, and preferably, the power supply 703 is logically connected to the processor 701 through a power management system, so that functions of managing charging, discharging, and power consumption are implemented through the power management system. The power supply 703 may also include any component including one or more of a dc or ac power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
The device may further comprise an input unit 704 and an output unit 705, the input unit 704 being operable to receive entered numerical or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
Although not shown, the apparatus may further include a display unit and the like, which will not be described in detail herein. Specifically, in the present application, the processor 701 in the device loads the executable file corresponding to the process of one or more application programs into the memory 702 according to the following instructions, and the processor 701 runs the application program stored in the memory 702, thereby implementing various functions as follows:
acquiring an intelligent contract object;
determining the field type of each field of the intelligent contract object;
calling a preset coding method according to the field type of each field of the intelligent contract object, and respectively carrying out serialization processing on each field of the intelligent contract object to obtain a plurality of corresponding sub-byte streams;
and splicing the plurality of sub byte streams to obtain byte stream data corresponding to the intelligent contract object so as to complete data conversion of the intelligent contract object.
It will be understood by those skilled in the art that all or part of the steps of the above methods may be performed by instructions or by instructions controlling associated hardware, and the instructions may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, the present application provides a computer-readable storage medium, which may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like. Stored thereon, a computer program is loaded by a processor to perform the steps of any of the data conversion methods provided herein. For example, the computer program may be loaded by a processor to perform the steps of:
acquiring an intelligent contract object;
determining the field type of each field of the intelligent contract object;
calling a preset coding method according to the field type of each field of the intelligent contract object, and respectively carrying out serialization processing on each field of the intelligent contract object to obtain a plurality of corresponding sub-byte streams;
and splicing the plurality of sub byte streams to obtain byte stream data corresponding to the intelligent contract object so as to complete data conversion of the intelligent contract object.
Since the instructions stored in the computer-readable storage medium can execute the steps in the data conversion method in any embodiment corresponding to fig. 2 to 5 in the present application, the beneficial effects that can be achieved by the data conversion method in any embodiment corresponding to fig. 2 to 5 in the present application can be achieved, for details, see the foregoing description, and are not repeated herein.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and parts that are not described in detail in a certain embodiment may refer to the above detailed descriptions of other embodiments, and are not described herein again.
In a specific implementation, each unit or structure may be implemented as an independent entity, or may be combined arbitrarily to be implemented as one or several entities, and the specific implementation of each unit or structure may refer to the foregoing embodiments, which are not described herein again.
The data conversion method, apparatus, device and storage medium provided by the present application are described in detail above, and the principles and embodiments of the present application are explained herein by applying specific examples, and the above description is only used to help understand the method and core ideas of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method of data conversion, the method comprising:
acquiring an intelligent contract object;
determining the field type of each field of the intelligent contract object;
calling a preset coding method according to the field type of each field of the intelligent contract object, and respectively carrying out serialization processing on each field of the intelligent contract object to obtain a plurality of corresponding sub-byte streams;
and splicing the plurality of sub byte streams to obtain byte stream data corresponding to the intelligent contract object so as to complete data conversion of the intelligent contract object.
2. The method according to claim 1, wherein the field types include a first type and a second type, the encoding method includes a first encoding method and a second encoding method, the plurality of sub-byte streams include a first sub-byte stream and a second sub-byte stream, a preset encoding method is called according to the field types of the fields of the intelligent contract object, and the fields of the intelligent contract object are respectively serialized to obtain a plurality of corresponding sub-byte streams, including:
if the field type of the field is the first type, calling the first coding method to carry out serialization processing on the field to obtain the first sub byte stream;
and if the field type of the field is the second type, calling the second encoding method to carry out serialization processing on the field to obtain the second sub byte stream.
3. The method of claim 2, wherein the first encoding method comprises:
acquiring a field name, a field value and a first coded value of the field, wherein the first coded value is a preset coded value of the first type;
determining the number of bytes of the field according to the field type of the field;
and obtaining the first sub-byte stream according to the field name, the first coding value, the byte number and the field value.
4. The method of claim 3, wherein the first type comprises an integer, and wherein after obtaining the field name, the field value, and the first encoded value of the field, the method further comprises:
and judging whether the field type of the field is the integer, if so, obtaining the first sub-byte stream according to the field name, the first coded value and the field value.
5. The method of claim 2, wherein the second encoding method comprises:
acquiring a field name, a field value and a second coded value of the field, wherein the second coded value is a preset coded value of the second type;
performing recursion processing on the field to obtain a first recursion byte stream;
and obtaining the second sub byte stream according to the field name, the second coding value and the first recursive byte stream.
6. The method according to any one of claims 1-5, wherein after the splicing the plurality of sub-byte streams to obtain byte stream data corresponding to the smart contract object, the method further comprises:
acquiring the byte stream data and determining type identifications carried by the plurality of sub-byte streams respectively;
calling a preset decoding method according to the type identifiers carried by the sub-byte streams respectively, and performing deserialization processing on the sub-byte streams respectively to obtain each field of the intelligent contract object;
and splicing all fields of the intelligent contract object to obtain the intelligent contract object corresponding to the byte stream data so as to complete data conversion of the byte stream data.
7. The method according to claim 6, wherein the type identifier includes a first identifier and a second identifier, the decoding method includes a first decoding method and a second decoding method, the intelligent contract object includes a first field and a second field, the method calls a preset decoding method according to the type identifiers carried in the plurality of sub-byte streams, and deserializes the plurality of sub-byte streams to obtain fields of the intelligent contract object, and the method includes:
if the type identifier carried by the sub-byte stream is the first identifier, calling the first decoding method to perform deserialization processing on the sub-byte stream to obtain the first field;
and if the type identifier carried by the sub-byte stream is the second identifier, calling the second decoding method to perform deserialization processing on the sub-byte stream to obtain the second field.
8. A data conversion apparatus, characterized in that the apparatus comprises:
the acquisition module is used for acquiring the intelligent contract object;
the processing module is used for determining the field type of each field of the intelligent contract object;
calling a preset coding method according to the field type of each field of the intelligent contract object, and respectively carrying out serialization processing on each field of the intelligent contract object to obtain a plurality of corresponding sub-byte streams;
and the output module is used for splicing the plurality of sub byte streams to obtain byte stream data corresponding to the intelligent contract object so as to complete data conversion of the intelligent contract object.
9. A data conversion apparatus, characterized in that the apparatus comprises:
one or more processors;
a memory; and
one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the data conversion method of any of claims 1 to 7.
10. A computer-readable storage medium, having stored thereon a computer program which is loaded by a processor to perform the steps of the data conversion method of any one of claims 1 to 7.
CN202011636181.9A 2020-12-31 2020-12-31 Data conversion method, device, equipment and storage medium Pending CN112783974A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011636181.9A CN112783974A (en) 2020-12-31 2020-12-31 Data conversion method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011636181.9A CN112783974A (en) 2020-12-31 2020-12-31 Data conversion method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112783974A true CN112783974A (en) 2021-05-11

Family

ID=75754906

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011636181.9A Pending CN112783974A (en) 2020-12-31 2020-12-31 Data conversion method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112783974A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113204683A (en) * 2021-06-04 2021-08-03 腾讯科技(成都)有限公司 Information reconstruction method and device, storage medium and electronic equipment
CN113282814A (en) * 2021-05-19 2021-08-20 北京三快在线科技有限公司 Characteristic data processing method, device, server and storage medium
CN113821005A (en) * 2021-09-26 2021-12-21 北京北方华创微电子装备有限公司 Data acquisition system and method for semiconductor process equipment
CN113905093A (en) * 2021-08-20 2022-01-07 微梦创科网络科技(中国)有限公司 Serialization and deserialization methods and devices and electronic equipment
CN115334169A (en) * 2022-04-28 2022-11-11 深圳证券通信有限公司 Communication protocol coding method for saving network bandwidth
CN116915368A (en) * 2023-09-14 2023-10-20 深圳华云信息系统科技股份有限公司 Encoding and decoding method and device for data stream conforming to futures transaction data exchange protocol

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120144405A1 (en) * 2010-12-06 2012-06-07 Ibm Corporation Efficient Serialization of Mutable Objects
CN102750268A (en) * 2012-06-19 2012-10-24 山东中创软件商用中间件股份有限公司 Object serializing method as well as object de-serializing method, device and system
CN106777292A (en) * 2016-12-29 2017-05-31 北京神州绿盟信息安全科技股份有限公司 A kind of Data Serialization method and device
CN110060158A (en) * 2019-03-07 2019-07-26 阿里巴巴集团控股有限公司 Intelligent contract based on variable-length encoding executes method and apparatus

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120144405A1 (en) * 2010-12-06 2012-06-07 Ibm Corporation Efficient Serialization of Mutable Objects
CN102750268A (en) * 2012-06-19 2012-10-24 山东中创软件商用中间件股份有限公司 Object serializing method as well as object de-serializing method, device and system
CN106777292A (en) * 2016-12-29 2017-05-31 北京神州绿盟信息安全科技股份有限公司 A kind of Data Serialization method and device
CN110060158A (en) * 2019-03-07 2019-07-26 阿里巴巴集团控股有限公司 Intelligent contract based on variable-length encoding executes method and apparatus

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113282814A (en) * 2021-05-19 2021-08-20 北京三快在线科技有限公司 Characteristic data processing method, device, server and storage medium
CN113204683A (en) * 2021-06-04 2021-08-03 腾讯科技(成都)有限公司 Information reconstruction method and device, storage medium and electronic equipment
CN113204683B (en) * 2021-06-04 2022-07-01 腾讯科技(成都)有限公司 Information reconstruction method and device, storage medium and electronic equipment
CN113905093A (en) * 2021-08-20 2022-01-07 微梦创科网络科技(中国)有限公司 Serialization and deserialization methods and devices and electronic equipment
CN113821005A (en) * 2021-09-26 2021-12-21 北京北方华创微电子装备有限公司 Data acquisition system and method for semiconductor process equipment
CN115334169A (en) * 2022-04-28 2022-11-11 深圳证券通信有限公司 Communication protocol coding method for saving network bandwidth
CN115334169B (en) * 2022-04-28 2023-06-06 深圳证券通信有限公司 Communication protocol coding method capable of saving network bandwidth
CN116915368A (en) * 2023-09-14 2023-10-20 深圳华云信息系统科技股份有限公司 Encoding and decoding method and device for data stream conforming to futures transaction data exchange protocol
CN116915368B (en) * 2023-09-14 2024-03-29 深圳华云信息系统科技股份有限公司 Encoding and decoding method and device for data stream conforming to futures transaction data exchange protocol

Similar Documents

Publication Publication Date Title
CN112783974A (en) Data conversion method, device, equipment and storage medium
WO2022105805A1 (en) Data processing method and in-memory computing chip
CN107027036A (en) A kind of FPGA isomeries accelerate decompression method, the apparatus and system of platform
CN104077335A (en) Methods, devices and system for serializing and deserializing structured data
CN113468090B (en) PCIe communication method and device, electronic equipment and readable storage medium
CN106598674A (en) Relocatable ELF file-based software quick loading method
CN112114933A (en) Application program protection method, electronic device and storage medium
CN115880132A (en) Graphics processor, matrix multiplication task processing method, device and storage medium
CN114331416A (en) Data processing method and device, electronic equipment and storage medium
CN109213745B (en) Distributed file storage method, device, processor and storage medium
CN109656567B (en) Dynamic method and system for heterogeneous service data processing logic
CN114117992A (en) Serialization and deserialization method and device and electronic equipment
CN104850516A (en) DDR frequency conversion design method and device
US20230342419A1 (en) Matrix calculation apparatus, method, system, circuit, and device, and chip
CN110458285B (en) Data processing method, data processing device, computer equipment and storage medium
CN117236236A (en) Chip design data management method and device, electronic equipment and storage medium
CN112765269B (en) Data processing method, device, equipment and storage medium
CN110555522A (en) Data processing method, data processing device, computer equipment and storage medium
US8140488B2 (en) Reducing memory required for prediction by partial matching models
CN116227599A (en) Inference model optimization method and device, electronic equipment and storage medium
CN113377295B (en) Data storage and reading method, device and equipment for multi-producer single-consumer
CN107483399B (en) Information packaging method and device in remote procedure call
CN112565474A (en) Batch data transmission method facing distributed shared SPM
CN115022312A (en) Method and device for realizing multiple intelligent contract engines, electronic equipment and storage medium
WO2020236360A1 (en) Remote operations application programming interface

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210511