WO2020215951A1 - 一种编解码方法、装置、计算机设备及存储介质 - Google Patents

一种编解码方法、装置、计算机设备及存储介质 Download PDF

Info

Publication number
WO2020215951A1
WO2020215951A1 PCT/CN2020/080712 CN2020080712W WO2020215951A1 WO 2020215951 A1 WO2020215951 A1 WO 2020215951A1 CN 2020080712 W CN2020080712 W CN 2020080712W WO 2020215951 A1 WO2020215951 A1 WO 2020215951A1
Authority
WO
WIPO (PCT)
Prior art keywords
sub
operation object
decoding
code
position offset
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.)
Ceased
Application number
PCT/CN2020/080712
Other languages
English (en)
French (fr)
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.)
WeBank Co Ltd
Original Assignee
WeBank 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 WeBank Co Ltd filed Critical WeBank Co Ltd
Publication of WO2020215951A1 publication Critical patent/WO2020215951A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9024Graphs; Linked lists
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/389Keeping log of transactions for guaranteeing non-repudiation of a transaction
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03MCODING; DECODING; CODE CONVERSION IN GENERAL
    • H03M7/00Conversion of a code where information is represented by a given sequence or number of digits to a code where the same, similar or subset of information is represented by a different sequence or number of digits
    • H03M7/30Compression; Expansion; Suppression of unnecessary data, e.g. redundancy reduction
    • H03M7/40Conversion to or from variable length codes, e.g. Shannon-Fano code, Huffman code, Morse code
    • H03M7/4031Fixed length to variable length coding
    • H03M7/4037Prefix coding

Definitions

  • the present invention relates to the fields of financial technology (Fintech) and blockchain (blockchain), in particular to a coding and decoding method, device, computer equipment and storage medium.
  • Financial technology Fetech
  • blockchain blockchain
  • blockchain nodes in the financial technology field need to perform encoding and decoding processing during communication and storage.
  • a data packet is sent from one blockchain node to another blockchain node, it needs to be encoded and then decoded.
  • a piece of block data is written to a blockchain node, it needs to be encoded and then written; when a piece of data is read from a blockchain node, it still needs to be decoded and then read .
  • RLP recursive length prefix
  • the blockchain node Before encoding each encoding object, the blockchain node cannot obtain the position of the encoding object after encoding in the overall RLP encoding of the block data. Therefore, before a blockchain node accesses a coded object, it must access the coded object before it in the order of coding. It can be seen that the sampling RLP coding method can only access each coded object sequentially, and does not support random access.
  • This application provides an encoding and decoding method, device, computer equipment, and storage medium to solve the technical problem that RLP encoding in the prior art can only perform sequential access to each object and does not support random access.
  • this application provides an encoding method, including:
  • the first operation is: determining M, and M is the first operation
  • M is the first operation
  • the number of sub-operation objects included in the operation object of the operation, M is a positive integer; if M is equal to 1, the only sub-operation object in the operation object is subjected to recursive length prefix RLP encoding to obtain the RLP code of the sub-operation object ; If M is greater than 1, the following steps are performed for each child operation object according to the preset sequence of the child operation objects in the operation object: the child operation object is used as the operation object of the first operation, and the child operation object Perform encoding according to the first operation to obtain the code of the sub-operation object; determine the position offset of the code of the sub-operation object relative to the start address of the code of the operation object; The coded sub-operation object is returned to the step of using the sub-operation object as the operation object of the first operation; otherwise, according to the
  • the determining the position offset of the code of the sub-operation object relative to the start address of the code of the operation object includes: if the sub-operation object that performed the first operation in the operation object Sequence, which is not the first one in the preset sequence, according to the code length of the sub-operating object code of the previous sub-operating object in the preset sequence, and the sub-operating object before the sub-operating object in the preset sequence.
  • the position offset of the code of a sub-operation object relative to the start address of the code of the operation object determines the position offset of the code of the sub-operation object relative to the start address.
  • the determining the position offset of the code of the sub-operation object relative to the start address of the code of the operation object may further include: if the sub-operation object that performs the first operation in the operation object The sequence is the first in the preset sequence, and 0 is used as the position offset of the code of the sub-operation object relative to the code start address of the operation object.
  • the determining the encoding information of the operation object according to the code of each sub-operation object in the operation object and the position offset of the sub-operation object relative to the start address includes: M.
  • the information combined in sequence of the position offset part and the encoding part is used as the encoding information of the operation object;
  • the position offset part is: the encoding of all sub-operation objects in the operation object is relative to the operation
  • the position offset of the coding start address of the object is combined according to the preset sequence;
  • the coding part is: the coding of all sub-operating objects in the operation object is combined according to the preset sequence.
  • the encoding object is used as the operation object of the first operation, and the encoding object is encoded according to the first operation.
  • M is first determined.
  • M is the operation object of the first operation.
  • the first operation is divided into two cases according to the child operation objects in the operation object. The first case is: if M is equal to 1, then the only child operation object in the operation object is prefixed with recursive length RLP encoding to obtain the RLP encoding of the sub-operating object. Obviously, this case supports random access; the second case is: if M is greater than 1, in accordance with the preset order of the sub-operating objects in the operating object, each The sub-operating objects are coded according to the first operation.
  • the position offset of the code of the sub-operating object relative to the encoding start address of the operating object is determined. Therefore, you can directly According to the position offset of the code of each sub-operation object relative to the start address of the code of the operation object, the code of the sub-operation object is located. In this case, random access is also supported.
  • this application provides a decoding method, including:
  • the first decoding object is one of at least two decoding objects in the block data; according to the first Position offset to obtain the first decoding object; if the first decoding object includes at least two sub-decoding objects, the first decoding object also includes the relative position of each sub-decoding object in the at least two sub-decoding objects The second position offset of the second start address of the first decoding object; according to the second position offset of each of the at least two sub-decoding objects relative to the second start address of the first decoding object The position offset is used to decode the first decoding object.
  • the first decoding object is decoded according to a second position offset of each of the at least two sub-decoding objects relative to the second start address of the first decoding object , Including: taking the first decoding object as the operation object of the first operation, and decoding the first decoding object according to the first operation; the first operation is: determining N, where N is the first operation The number of sub-operation objects included in the operation object of the operation, N is a positive integer; if N is equal to 1, the only sub-operation object in the operation object is subjected to recursive length prefix RLP decoding to obtain the RLP decoding of the sub-operation object ; If N is greater than 1, in accordance with the preset sequence of the sub-operating objects in the operating object, for each sub-operating object, perform the following steps: Obtain the third starting address of the sub-operating object relative to the third starting address of the operating object Position offset, and obtain the child operation object according to the third position offset; use the child operation object as the operation object of the first operation,
  • this application provides an encoding device, including:
  • Obtaining module used to obtain encoding objects
  • the encoding module is configured to use the encoding object as the operation object of the first operation, and encode the encoding object according to the first operation;
  • the first operation is: determining M, and M is the operation object of the first operation
  • M is the operation object of the first operation
  • the number of sub-operation objects included in the operation object, M is a positive integer; and if M is equal to 1, the only sub-operation object in the operation object is recursively prefixed with RLP encoding to obtain the RLP of the sub-operation object Encoding; if M is greater than 1, in accordance with the preset sequence of the sub-operation objects in the operation object, the following steps are performed for each sub-operation object: the sub-operation object is the operation object of the first operation, and the sub-operation The object is coded according to the first operation, and the code of the sub-operation object is obtained; the position offset of the code of the sub-operation object relative to the start address of the code of the operation object is determined; if it is determined that the operation object exists If the
  • the encoding module is specifically configured to: if the sequence of the sub-operation object that performed the first operation in the operation object is not the first in the preset sequence, then according to the sub-operation object The code length of the code of the previous sub-operation object in the preset sequence, and the position offset of the code of the sub-operation object of the previous sub-operation object in the preset sequence relative to the code start address of the operation object The amount of shift determines the position offset of the code of the sub-operation object relative to the start address.
  • the encoding module is further configured to: if the sequence of the sub-operation object that performed the first operation in the operation object is the first in the preset sequence, then use 0 as the sub-operation The position offset of the code of the object relative to the start address of the code of the operation object.
  • the encoding module is specifically configured to: use information combined in the order of M, a position offset part, and an encoding part as the encoding information of the operation object;
  • the position offset part is: the The position offsets of the codes of all sub-operation objects in the operation object relative to the code start address of the operation object are combined according to the preset sequence;
  • the code part is: all sub-operation objects in the operation object The codes are combined according to the preset sequence.
  • the present application provides a decoding device, including:
  • the obtaining module is configured to obtain the first position offset of the first decoding object relative to the first starting address of the block data; the first decoding object is one of at least two decoding objects in the block data; decoding Module, configured to obtain the first decoding object according to the first position offset; if the first decoding object includes at least two sub-decoding objects, the first decoding object also includes the at least two sub-decoding objects The second position offset of each sub-decoding object in the decoding object relative to the second start address of the first decoding object; The second position offset of the second start address of a decoding object is used to decode the first decoding object.
  • the decoding module is specifically configured to: use the first decoding object as the operation object of the first operation, and decode the first decoding object according to the first operation;
  • the first operation is : Determine N, N is the number of child operation objects included in the operation object of the first operation, and N is a positive integer; if N is equal to 1, perform the recursive length prefix RLP on the only child operation object in the operation object Decoding, obtain the RLP decoding of the sub-operating object; if N is greater than 1, in accordance with the preset sequence of the sub-operating objects in the operating object, perform the following steps for each sub-operating object: Obtain the sub-operating object relative to the operation The third position offset of the third start address of the object, and obtain the sub-operation object according to the third position offset; use the sub-operation object as the operation object of the first operation, and the sub-operation The object is decoded according to the first operation, and the decoding of the sub-operation object is obtained; if it is determined that there is an undecode
  • this application provides a computer device, including a program or instruction.
  • a program or instruction When the program or instruction is executed, an encoding method and an optional method or a decoding method and an optional method provided in an embodiment of the application are carried out.
  • the present application provides a storage medium, including a program or instruction.
  • the program or instruction When the program or instruction is executed, the decoding method and optional method or the decoding method and optional method provided in the embodiments of the application are carried out.
  • Figure 1 is a schematic diagram of the structure of a blockchain
  • FIG. 2 is a schematic flowchart of an encoding method provided by an embodiment of the application.
  • FIG. 3 is a schematic diagram of an encoding format in an encoding method provided by an embodiment of the application.
  • FIG. 4 is a schematic flowchart of a decoding method provided by an embodiment of this application.
  • FIG. 5 is a schematic diagram of a specific flow of an encoding method provided by an embodiment of the application.
  • FIG. 6 is a schematic diagram of a specific flow of a decoding method provided by an embodiment of this application.
  • FIG. 7 is a schematic structural diagram of an encoding device provided by an embodiment of this application.
  • FIG. 8 is a schematic structural diagram of a decoding device provided by an embodiment of this application.
  • FIG. 9 is a schematic structural diagram of a computer device provided by an embodiment of this application.
  • FIG. 1 is a schematic diagram of the structure of a blockchain.
  • a blockchain is a chain composed of a series of blocks.
  • each block will also record The hash value of the previous block, each block forms a chain through the hash value of the previous block.
  • a block can be composed of a block header and a block body.
  • the block header includes important fields such as the height of the block and the hash value of the previous block.
  • the previous block is earlier than the block in the block generation sequence.
  • the most recent block; and the block body includes transaction data.
  • There are two core concepts of the blockchain one is cryptography and the other is decentralization. These two concepts can ensure that the historical information on the blockchain is not tampered with.
  • nodes all refer to blockchain nodes.
  • a node refers to a participant with a unique identity, and the node can participate in the formation and data exchange of the blockchain network.
  • Each node in the blockchain network has a complete copy of the ledger, and can participate in the consensus and ledger maintenance of the blockchain network based on the copy of the ledger.
  • a transaction is a user's operation request on the blockchain. The transaction is initiated by the user. For example, it is sent from the user's client to a node in the blockchain. When the node in the blockchain receives the transaction, the transaction can be packaged into a block To execute. In order to complete transactions, each node in the blockchain needs to communicate and store.
  • Nodes need to be encoded and/or decoded during communication and storage.
  • a data packet When a data packet is sent from one node to another, it needs to be encoded and then decoded. For example, when a piece of block data is written to a node, it needs to be encoded and then written, and when the block data is read from a node, it needs to be decoded and then read.
  • the blockchain node can be encoded based on the RLP encoding method.
  • the RLP coding method starts with the number of coding objects, which is followed by the coding objects, and the size of each coding object is not fixed.
  • the RLP encoding method uses a combination of length prefix and recursion to encode.
  • the blockchain node cannot know the length after encoding before encoding.
  • the length of each object is uncertain, and RLP encoding only records the number of objects, not the byte length of the object. Therefore, the blockchain node can only obtain the number of encoded objects.
  • the location of the encoding object cannot be obtained.
  • the RLP encoding method when used for decoding, if you want to obtain one of the encoded objects, you must first recursively decode all the objects in its preamble. After decoding the preamble objects, you can access the bytes of the encoding object that needs to be accessed. position. Therefore, the RLP encoding method can only be accessed sequentially during decoding, and does not support random access, so the performance of encoding and decoding is low.
  • the embodiment of the present application provides an encoding method to solve the technical problem that the RLP encoding and decoding method in the prior art can only perform sequential access to each object, and does not support random access.
  • Fig. 2 is a schematic flowchart of an encoding method proposed by an embodiment of the application. As shown in Fig. 2, the method includes:
  • Step 201 Obtain an encoding object.
  • Step 202 Use the encoding object as the operation object of the first operation, and encode the encoding object according to the first operation.
  • step 202 the first operation includes:
  • Step 1 Determine M, where M is the number of sub-operation objects included in the operation object of the first operation.
  • the number of sub-operation objects included in the operation object of the first operation is at least one, therefore, M is a positive integer.
  • Step two judge whether M is equal to 1, if yes, then perform step three, if not, then perform step four.
  • Step 3 Perform recursive length prefix RLP encoding on the only sub-operation object in the operation object, and obtain the RLP code of the sub-operation object.
  • an encoding object when an encoding object includes only one sub-encoding object, the encoding of this encoding object is RLP encoding.
  • Step 4 Perform the following steps for each sub-operating object in accordance with the preset sequence of each sub-operating object in the operating object:
  • step 4 When the operation object includes more than one sub-operation object, perform step 4, until the operation object has only one sub-operation object and cannot continue to be divided to the next level, perform step 1 for RLP encoding, and I will not repeat it here. .
  • the preset order can be set according to specific scenarios. For example, according to coding habits, the order from left to right is set as the preset order.
  • the position offset of the coded start address of the sub-operation object is: the byte length of the coded start address of the sub-operation object relative to the coded start address of the operation object. If it is determined that there is an uncoded sub-operation object in the operation object, return (1); otherwise, execute (3).
  • a possible implementation is as follows: for a sub-operation object that performs the first operation in the operation object, if the sub-operation object is not the first in the preset order, then according to the sub-operation The code length of the RLP code corresponding to the object, and the position offset of the code of the previous sub-operation object of the sub-operation object relative to the start address of the code of the operation object in the preset order, determine the relative code of the sub-operation object The position offset from the start address.
  • sub-operation object A and sub-operation object B are two adjacent sub-operation objects in a preset order, and sub-operation object A performs the first operation before sub-operation object B, so sub-operation object B is The previous child operation object in the sequence is child operation object A.
  • the position offset X A of the sub-operation object A relative to the start address of the operation object, and the code length of the sub-operation object B is S B
  • the position offset of the sub-operation object B relative to the start address of the operation object X B is X A +S B.
  • the sub-operation object is the first in the preset sequence, then 0 is used as the position offset of the code of the sub-operation object relative to the start address of the code of the operation object.
  • the code when the operation object has only one sub-operation object is different from the code when the operation object has 2 or more sub-operation objects.
  • the position offset is not recorded, but when the operation object has 2 or more child operation objects, the position offset of the first child operation object is recorded as 0, which is used as The basis for determining the position offset of the subsequent sub-operation objects.
  • a possible implementation manner is: combining M, the position offset part, and the RLP coding part in the order to obtain the coding information of the operation object.
  • the position offset part is: the position offset of the code of all sub-operating objects in the operation object relative to the starting address of the operating object is combined in a preset order, such as [the code of sub-operating object 1 relative to the operating object The position offset of the starting address, the position offset of the code of the sub-operating object 2 relative to the starting address of the operating object, ...].
  • the RLP encoding part is: combining the RLP encodings of all sub-operating objects in the operation object in a preset order, such as [RLP encoding of sub-operating object 1, RLP encoding of sub-operating object 2, ...].
  • FIG. 3 is a schematic diagram of an encoding format in an operation method.
  • the encoding format in FIG. 3 is used as an example to describe the encoding and decoding process in detail.
  • the encoding format includes a position offset field to index the encoding position of each sub-encoding object.
  • Obj_num represents the number of sub-coding objects
  • Obj_x (such as Obj_0, Obj_1, Obj_2, Obj_3, ...) represents the x-th sub-coding object code
  • Off_set_x (such as Off_set_0, Off_set_1, Off_set_2, Off_set_3, 7)
  • the position offset of the codes of the x sub-coding objects relative to the starting address of the coding object For example, the numbering starts from 0.
  • Off_set_0 represents the position offset of the sub-coding object Obj_0 relative to the starting address of the coding object. Shift.
  • the coding format starts with the number field (Obj_num) of the sub-coding object, followed by the position offset part (Off_sets), and the position offset part includes the codes of all sub-operating objects relative to the operating object.
  • the position offset of the starting address of the encoding, the position offset corresponding to each sub-operation object has a fixed length and is arranged in a preset order. Therefore, if you want to read the value of a certain Off_set, you only need to directly index in Off_sets according to the sequence number of Off_set like accessing an array. For example, if you want to read Off_set_2, you directly get the third element in Off_sets. can.
  • the RLP coding part includes the RLP codes of all sub-operating objects and is arranged in a preset order. It should be noted that the sequence number in the position offset part corresponds to the sequence number in the RLP coding part, that is, the Off_set of the corresponding sequence number in the position offset part points to the starting address of the RLP code of the sub-coding object of the corresponding sequence number . For example, the sub-coding object pointed to by Off_set_0 is Obj_0.
  • steps 201 to 202 are described by taking only one coding object as an example. When there are multiple coding objects in the block data, each coding object can be coded according to steps 201 to 202.
  • Fig. 4 is a schematic flowchart of a decoding method provided by an embodiment of the application, including:
  • Step 401 Obtain the first position offset of the first decoding object relative to the first start address of the block data.
  • the first decoding object is one of at least two decoding objects in the block data
  • the decoding object is the code of the coding object
  • Step 402 Obtain the first decoding object according to the first position offset.
  • the first decoding object if the first decoding object includes at least two sub-decoding objects, the first decoding object also includes the second start of each of the at least two sub-decoding objects relative to the first decoding object. The second position offset of the start address.
  • Step 403 Decode the first decoding object according to the second position offset of each of the at least two sub-decoding objects relative to the second starting address of the decoding object.
  • the decoding process of decoding the first decoding object is: taking the first decoding object as the operation object of the first operation, and decoding the first decoding object according to the first operation.
  • the first operation is:
  • the first step is to determine N, where N is the number of sub-operation objects included in the operation object of the first operation.
  • N is a positive integer.
  • step 201 From step 201 to step 202, it can be seen that when the operation object of the first operation is the first decoding object, the first data of the first decoding object is N.
  • the second step is to perform recursive length prefix RLP decoding on the only sub-operation object in the operation object, and obtain the RLP decoding of the sub-operation object.
  • step 201 to step 202 it can be known that when the operation object of the first operation is the first decoding object, the first decoding object is RLP encoding, and the decoding can be performed directly through the RLP decoding mode.
  • the third step is to perform the following steps for each child operation object according to the preset order of the child operation objects in the operation object:
  • FIG. 5 it is a schematic diagram of a specific flow of an encoding method provided by an embodiment of this application.
  • the following steps 501 to 512 are encoding an encoding object, the input is the encoding object, the encoding object is an array Objs containing sub-encoding objects, and the output is the binary code Rlps of the encoding object.
  • Step 501 Initialize, open up the first temporary array (Off_sets), set the first element in Off_sets to 0, open up the second temporary array (cds).
  • Off_sets is used to cache the position offset of the code of each sub-code object in the code object relative to the code start address of the code object.
  • cds is used to cache the binary code of each sub-code object in the code object.
  • Step 502 Obtain the number of sub-encoding objects (Objs_num) in the encoding part Objs, and use the Objs_num encoding as the beginning of the encoding information (Rlps) of the encoding object.
  • Step 503 Determine whether Objs_num is greater than 1.
  • step 504 If yes, go to step 504, otherwise, go to step 511.
  • Step 504 Take out a sub-coding object that has not been coded from Objs according to the starting address of the sub-coding object in the coding object in descending order, as X.
  • Step 505 Use X as the operation object of the first operation in step 201 to step 202, perform the first operation on X, perform encoding, and obtain the encoding of X (Rlp_X) and the encoding length of Rlp_X (Rlp_X_Size).
  • Step 506 Determine the position offset of X (Off_set_X) according to Rlp_X_Size.
  • Off_set_X-1 is the position offset of the code of the previous sub-coding object of X relative to the start address of the coding object in the preset sequence.
  • Step 507 Append Off_set_X to the end of Off_sets, and append Rlp_X to the end of cds.
  • Step 508 Determine whether Objs has sub-coding objects that have not been coded.
  • step 504 If yes, go to step 504, otherwise, go to step 509.
  • Step 509 Append Off_sets to the end of Rlps.
  • Step 510 Append cds to the end of Rlps.
  • step 510 After step 510 is executed, the encoding process ends.
  • Step 511 Use RLP encoding to encode the unique sub-encoding object Y to obtain the encoded Rlp_Y.
  • Step 512 Append Rlp_Y to the end of Rlps.
  • step 512 After step 512 is executed, the encoding process ends.
  • FIG. 6 it is a schematic diagram of a specific flow of a decoding method provided by an embodiment of this application.
  • the following steps 601 to 606 are to decode the sub-encoding object at any position.
  • the input is the binary code Rlps and the sequence number (X_ID) of the sub-encoding object X to be accessed in the preset order of the encoding object, and the output is the decoded sub-object Code object X.
  • Step 601 Determine whether Obj_num of Rlps is greater than 1.
  • step 602 If yes, go to step 602; otherwise, go to step 606.
  • Step 602 According to X_ID, obtain the position offset (Off_set_X) corresponding to the X-ID in the Offsets of Rlps.
  • Step 603 Use the value of Off_set_X to index to the code (Rlp_X) of the sub-coding object X to be accessed.
  • Rlp_X at this time is the decoding target.
  • Step 604 Determine whether Rlp_X includes two or more sub-decoding objects.
  • step 605 If yes, go to step 605; otherwise, go to step 606.
  • Step 605 Use Rlp_X as the operation object of the first operation in step 401 to step 403, and decode Rlp_X according to the first operation.
  • step 605 it is still necessary to continue to provide the sequence number of the sub-decoding object of the next layer that needs to be accessed.
  • step 605 After step 605 is executed, the decoding process ends.
  • Step 606 Perform RLP decoding on Rlps to obtain sub-coding object X.
  • step 606 After step 606 is executed, the decoding process ends.
  • the encoding object is used as the operation object of the first operation, and the encoding object is encoded according to the first operation.
  • M M is a positive integer
  • M is all The number of sub-operation objects included in the operation object of the first operation.
  • the first operation can be divided into two cases according to the sub-operation objects in the operation object. The first case is: if M is equal to 1, then the operation object is unique
  • the sub-operating object performs recursive length prefix RLP encoding to obtain the RLP encoding of the sub-operating object.
  • this case supports random access;
  • the second case is: if M is greater than 1, follow the sub-operation of the operating object
  • the preset sequence of objects, each sub-operating object is coded according to the first operation, and after the code of the sub-operating object is obtained, the position of the code of the sub-operating object relative to the encoding start address of the operating object is determined Offset, therefore, the code of each sub-operation object can be located directly according to the position offset of the code of each sub-operation object relative to the code start address of the operation object.
  • random access is also supported.
  • an embodiment of the present invention also provides an encoding device, and the specific content of the device can be implemented with reference to the foregoing method.
  • FIG. 7 is a schematic structural diagram of an encoding device provided by an embodiment of the application, as shown in FIG. 7, including:
  • the obtaining module 701 is used to obtain an encoding object
  • the encoding module 702 is configured to use the encoding object as the operation object of the first operation, and encode the encoding object according to the first operation; the first operation is: determining M, and M is the first operation The number of sub-operation objects included in the operation object; M is a positive integer; and if M is equal to 1, the only sub-operation object in the operation object is recursively length-prefixed RLP encoding to obtain the sub-operation object RLP encoding; if M is greater than 1, in accordance with the preset sequence of sub-operating objects in the operating object, perform the following steps for each sub-operating object: use the sub-operating object as the operating object of the first operation, The operation object is coded according to the first operation, and the code of the sub-operation object is obtained; the position offset of the code of the sub-operation object relative to the start address of the code of the operation object is determined; if it is determined that the operation object is If there is an uncoded sub-operation object, return to the step of using the sub-
  • the encoding module 702 is specifically configured to:
  • the order of the child operation object that performed the first operation in the operation object is not the first one in the preset order, then according to the child operation object the previous child operation object in the preset order
  • the code length of the code and the position offset of the code of the previous sub-operation object of the sub-operation object relative to the code start address of the operation object in the preset sequence determine that the code of the sub-operation object is relative to The position offset of the start address.
  • the encoding module 702 is further configured to:
  • sequence of the sub-operation object that performed the first operation in the operation object is the first in the preset sequence, then 0 is taken as the code of the sub-operation object relative to the code of the operation object The position offset of the start address.
  • the encoding module 702 is specifically configured to:
  • the information combined in the order of M, the position offset part, and the coding part is used as the coding information of the operation object;
  • the position offset part is: the position offsets of the codes of all sub-operation objects in the operation object relative to the code start addresses of the operation objects, combined according to the preset sequence;
  • the encoding part is: the encoding of all sub-operating objects in the operating object, combined according to the preset order.
  • FIG. 8 is a schematic structural diagram of a decoding device provided by an embodiment of the application. As shown in FIG. 8, the device includes:
  • the obtaining module 801 is configured to obtain the first position offset of the first decoding object relative to the first starting address of the block data; the first decoding object is one of at least two decoding objects in the block data;
  • the decoding module 802 is configured to obtain the first decoding object according to the first position offset; if the first decoding object includes at least two sub-decoding objects, the first decoding object also includes the at least The second position offset of each of the two sub-decoding objects relative to the second start address of the first decoding object; The second position offset of the second start address of the first decoding object is used to decode the first decoding object.
  • the decoding module 802 is specifically configured to:
  • the first decoding object is used as the operation object of the first operation, and the first decoding object is decoded according to the first operation; the first operation is: determining N, where N is the operation of the first operation The number of child operation objects included in the object, where N is a positive integer;
  • N If N is equal to 1, perform recursive length prefix RLP decoding on the only sub-operation object in the operation object, and obtain the RLP decoding of the sub-operation object;
  • the operation object of an operation decodes the sub-operation object according to the first operation to obtain the decoding of the sub-operation object; if it is determined that there is an undecoded sub-operation object in the operation object, return to the obtaining The step of a third position offset of the sub-operation object relative to the third start address of the operation object.
  • an embodiment of the present application provides a computer device. As shown in FIG. 9, it includes at least one processor 901 and a memory 902 connected to the at least one processor.
  • the embodiment of the present invention does not limit the processor 901 and As the specific connection medium between the memories 902, the processor 901 and the memory 902 are connected through a bus in FIG. 9 as an example.
  • the bus can be divided into address bus, data bus, control bus, etc.
  • the memory 902 stores instructions that can be executed by at least one processor 901. By executing the instructions stored in the memory 902, the at least one processor 901 can execute the encoding method and optional methods described in any of the above steps, or Decoding method and optional method.
  • the processor 901 is the control center of the computer equipment, which can use various interfaces and lines to connect to various parts of the computer equipment, and realize data by running or executing instructions stored in the memory 902 and calling data stored in the memory 902. deal with.
  • the processor 901 may include one or more processing units, and the processor 901 may integrate an application processor and a modem processor.
  • the application processor mainly processes the operating system, user interface, and application programs.
  • the adjustment processor mainly handles issuing instructions. It can be understood that the foregoing modem processor may not be integrated into the processor 901.
  • the processor 901 and the memory 902 may be implemented on the same chip. In some embodiments, they may also be implemented on separate chips.
  • the processor 901 may be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application specific integrated circuit (ASIC), a field programmable gate array or other programmable logic devices, discrete gates or transistors Logic devices and discrete hardware components can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention.
  • the general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in combination with the coding embodiment may be directly embodied as being executed and completed by a hardware processor, or executed and completed by a combination of hardware and software modules in the processor.
  • the memory 902 as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules.
  • the memory 902 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (Random Access Memory, RAM), static random access memory (Static Random Access Memory, SRAM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), magnetic memory, disk , CD, etc.
  • the memory 902 is any other medium that can be used to carry or store desired program codes in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.
  • the memory 902 in the embodiment of the present invention may also be a circuit or any other device capable of realizing a storage function for storing program instructions and/or data.
  • an embodiment of the application provides a storage medium, including a program or instruction.
  • a program or instruction When the program or instruction is executed, an encoding method and an optional method or a decoding method and a The selected method is executed.
  • the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
  • a computer-usable storage media including but not limited to disk storage, optical storage, etc.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Accounting & Taxation (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

一种编解码方法、装置、计算机设备及存储介质,用以解决现有技术采用RLP编码无法随机访问的问题。方法包括:将编码对象作为第一操作的操作对象,确定操作对象中包括的子操作对象的个数;若子操作对象的个数大于1,则按照子操作对象的预设顺序对每个子操作对象执行预设步骤,以确定每个子操作对象的编码及编码相对于操作对象的编码起始地址的位置偏移量,得到操作对象的编码信息,如此,使用该编解码方法的区块链(Block Chain)系统能够支持对任意位置的随机解析。

Description

一种编解码方法、装置、计算机设备及存储介质
相关申请的交叉引用
本申请要求在2019年04月26日提交中国专利局、申请号为201910343404.3、申请名称为“一种编解码方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及金融科技(Fintech)和区块链(blockchain)领域,尤其涉及一种编解码方法、装置、计算机设备及存储介质。
背景技术
随着计算机技术的发展,越来越多的技术应用在金融领域,传统金融业正在逐步向金融科技(Fintech)转变。目前,金融科技领域的区块链节点在通信和存储时,都需要进行编解码处理,一个数据包从一个区块链节点发送到另一个区块链节点时,需要先编码,再解码。如此,一条区块数据在被写入一个区块链节点时,需要先编码,再写入;而一条区块数据从一个区块链节点中读取出来时,仍需要先解码,再读取。
现阶段,区块链上普遍采用的一种编码方式为递归长度前缀(recursive length prefix,RLP)编码。但RLP编码需要通过递归方式进行,在对每个编码对象进行编码之前,区块链节点无法获取编码之后的编码对象在区块数据整体RLP编码中的位置。因此,区块链节点在访问一个编码对象之前,必须按照编码的顺序访问它之前的编码对象,可知,采样RLP编码方式只能对每个编码对象进行顺序访问,而不支持随机访问。
综上,目前亟需一种编解码方法,用以解决现有技术中RLP编码只能对每个对象进行顺序访问,而不支持随机访问的技术问题。
发明内容
本申请提供一种编解码方法、装置、计算机设备及存储介质,用以解决现有技术中RLP编码只能对每个对象进行顺序访问,而不支持随机访问的技术问题。
第一方面,本申请提供一种编码方法,包括:
获取编码对象,并将所述编码对象作为第一操作的操作对象,对所述编码对象按照所述第一操作进行编码;其中,所述第一操作为:确定M,M为所述第一操作的操作对象包括的子操作对象的个数,M为正整数;若M等于1,则对所述操作对象中唯一的子操作对象进行递归长度前缀RLP编码,获取该子操作对象的RLP编码;若M大于1,则按照所述操作对象中子操作对象的预设顺序,对每个子操作对象执行以下步骤:将该子操作对象作为所述第一操作的操作对象,对该子操作对象按照所述第一操作进行编码,获取该子操作对象的编码;确定该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量;若确定所述操作对象中存在未被编码的子操作对象,则返回所述将该子操作对象作为所述第一操作的操作对象的步骤;否则,根据所述操作对象中每个子操作对象的编码,以及该子操作对象相对于所述起始地址的位置偏移量,确定所述操作对象的编码信息。
可选的,所述确定该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,包括:若所述操作对象中执行了所述第一操作的子操作对象的顺序,不为所述预设顺序中的首个,则根据该子操作对象在所述预设顺序中前一个子操作对象编码的编码长度,以及该子操作对象在所述预设顺序中前一个子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,确定该子操作对象的编码相对于所述起始地址的位置偏移量。
可选的,所述确定该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,还包括:若所述操作对象中执行了所述第一操作的子操作对象的顺序,为所述预设顺序中的首个,则将0作为该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量。
可选的,所述根据所述操作对象中每个子操作对象的编码,以及该子操作对象相对于所述起始地址的位置偏移量,确定所述操作对象的编码信息,包括:将按M、位置偏移量部分、编码部分先后顺序组合的信息,作为所述操作对象的编码信息;所述位置偏移量部分为:所述操作对象中所有子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,按照所述预设顺序的组合;所述编码部分为:所述操作对象中所有子操作对象的编码,按照所述预设顺序的组合。
本申请中,获取编码对象之后,将编码对象作为第一操作的操作对象,对编码对象按照第一操作进行编码,第一操作中,首先确定M,M为所述第一操作的操作对象包括的子操作对象个数,第一操作按操作对象中的子操作对象分两种情况,第一种情况为:若M等于1,则对所述操作对象中唯一的子操作对象进行递归长度前缀RLP编码,获取该子操作对象的RLP编码,显然,这种情况是支持随机访问的;第二种情况为:若M大于1,按照所述操作对象中子操作对象的预设顺序,对每个子操作对象按照所述第一操作进行编码,获取该子操作对象的编码之后,再确定该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,因此,可直接根据每个子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,定位到该子操作对象的编码,这种情况也是支持随机访问的。
第二方面,本申请提供一种解码方法,包括:
获取第一解码对象相对于区块数据的第一起始地址的第一位置偏移量;所述第一解码对象为所述区块数据中至少两个解码对象中的一个;根据所述第一位置偏移量,获取所述第一解码对象;若所述第一解码对象包括至少两个子解码对象,则所述第一解码对象还包括所述至少两个子解码对象中每个子解码对象相对于所述第一解码对象的第二起始地址的第二位置偏移量;根据所述至少两个子解码对象中每个子解码对象相对于所述第一解码对象的第二起始地址的第二位置偏移量,对所述第一解码对象进行解码。
可选的,所述根据所述至少两个子解码对象中每个子解码对象相对于所 述第一解码对象的第二起始地址的第二位置偏移量,对所述第一解码对象进行解码,包括:将所述第一解码对象作为第一操作的操作对象,对所述第一解码对象按照所述第一操作进行解码;所述第一操作为:确定N,N为所述第一操作的操作对象包括的子操作对象的个数,N为正整数;若N等于1,则对所述操作对象中唯一的子操作对象进行递归长度前缀RLP解码,获取该子操作对象的RLP解码;若N大于1,按照所述操作对象中子操作对象的预设顺序,对每个子操作对象,执行以下步骤:获取该子操作对象相对于所述操作对象的第三起始地址的第三位置偏移量,并根据该第三位置偏移量,获取该子操作对象;将该子操作对象作为所述第一操作的操作对象,对该子操作对象按照所述第一操作进行解码,获取该子操作对象的解码;若确定所述操作对象中存在未被解码的子操作对象,则返回所述获取该子操作对象相对于所述操作对象的所述第三起始地址的第三位置偏移量的步骤。
第三方面,本申请提供一种编码装置,包括:
获取模块,用于获取编码对象;
编码模块,用于将所述编码对象作为第一操作的操作对象,对所述编码对象按照所述第一操作进行编码;所述第一操作为:确定M,M为所述第一操作的操作对象包括的子操作对象的个数,M为正整数;以及用于若M等于1,则对所述操作对象中唯一的子操作对象进行递归长度前缀RLP编码,获取该子操作对象的RLP编码;若M大于1,按照所述操作对象中子操作对象的预设顺序,对每个子操作对象,执行以下步骤:将该子操作对象作为所述第一操作的操作对象,对该子操作对象按照所述第一操作进行编码,获取该子操作对象的编码;确定该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量;若确定所述操作对象中存在未被编码的子操作对象,则返回所述将该子操作对象作为所述第一操作的操作对象的步骤;否则,根据所述操作对象中每个子操作对象的编码,以及该子操作对象相对于所述起始地址的位置偏移量,确定所述操作对象的编码信息。
可选的,所述编码模块具体用于:若所述操作对象中执行了所述第一操 作的子操作对象的顺序,不为所述预设顺序中的首个,则根据该子操作对象在所述预设顺序中前一个子操作对象编码的编码长度,以及该子操作对象在所述预设顺序中前一个子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,确定该子操作对象的编码相对于所述起始地址的位置偏移量。
可选的,所述编码模块还用于:若所述操作对象中执行了所述第一操作的子操作对象的顺序,为所述预设顺序中的首个,则将0作为该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量。
可选的,所述编码模块具体用于:将按M、位置偏移量部分、编码部分先后顺序组合的信息,作为所述操作对象的编码信息;所述位置偏移量部分为:所述操作对象中所有子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,按照所述预设顺序的组合;所述编码部分为:所述操作对象中所有子操作对象的编码,按照所述预设顺序的组合。
第四方面,本申请提供一种解码装置,包括:
获取模块,用于获取第一解码对象相对于区块数据的第一起始地址的第一位置偏移量;所述第一解码对象为所述区块数据中至少两个解码对象中一个;解码模块,用于根据所述第一位置偏移量,获取所述第一解码对象;若所述第一解码对象包括至少两个子解码对象,则所述第一解码对象还包括所述至少两个子解码对象中每个子解码对象相对于所述第一解码对象的第二起始地址的第二位置偏移量;以及用于根据所述至少两个子解码对象中每个子解码对象相对于所述第一解码对象的第二起始地址的第二位置偏移量,对所述第一解码对象进行解码。
可选的,所述解码模块,具体用于:将所述第一解码对象作为第一操作的操作对象,对所述第一解码对象按照所述第一操作进行解码;所述第一操作为:确定N,N为所述第一操作的操作对象包括的子操作对象的个数,N为正整数;若N等于1,则对所述操作对象中唯一的子操作对象进行递归长度前缀RLP解码,获取该子操作对象的RLP解码;若N大于1,按照所述操 作对象中子操作对象的预设顺序,对每个子操作对象,执行以下步骤:获取该子操作对象相对于所述操作对象的第三起始地址的第三位置偏移量,并根据该第三位置偏移量,获取该子操作对象;将该子操作对象作为所述第一操作的操作对象,对该子操作对象按照所述第一操作进行解码,获取该子操作对象的解码;若确定所述操作对象中存在未被解码的子操作对象,则返回所述获取该子操作对象相对于所述操作对象的所述第三起始地址的第三位置偏移量的步骤。
第五方面,本申请提供一种计算机设备,包括程序或指令,当所述程序或指令被执行时,如本申请实施例提供的一种编码方法及可选方法或者解码方法及可选方法被执行。
第六方面,本申请提供一种存储介质,包括程序或指令,当所述程序或指令被执行时,如本申请实施例提供的一种解码方法及可选方法或者解码方法及可选方法被执行。
附图说明
图1为一种区块链的结构示意图;
图2为本申请实施例提供的一种编码方法的流程示意图;
图3为本申请实施例提供的一种编码方法中编码的格式示意图;
图4为本申请实施例提供的一种解码方法的流程示意图;
图5为本申请实施例提供的一种编码方法的具体流程示意图;
图6为本申请实施例提供的一种解码方法的具体流程示意图;
图7为本申请实施例提供的一种编码装置的结构示意图;
图8为本申请实施例提供的一种解码装置的结构示意图;
图9为本申请实施例提供的一种计算机设备的结构示意图。
具体实施方式
为了更好的理解上述技术方案,下面将结合说明书附图及具体的实施方 式对上述技术方案进行详细的说明,应当理解本申请实施例以及实施例中的具体特征是对本申请技术方案的详细的说明,而不是对本申请技术方案的限定,在不冲突的情况下,本申请实施例以及实施例中的技术特征可以相互结合。
图1为一种区块链的结构示意图,如图1所示,区块链是由一系列区块组成的一条链,每个区块上除了记录本区块的数据之外,还会记录上一个区块的哈希(Hash)值,各个区块通过上一区块的哈希值组成一条链。其中,一个区块可以由块头和块体组成,块头包括该区块的高度、上一个区块的哈希值等重要字段,上一区块是指在区块生成顺序中早于该区块的最近区块;而区块的块体包括交易数据。区块链的核心理念有两个,一个是密码学技术,另一个是去中心化思想,这两个理念能够保证区块链上的历史信息不被篡改。
在本发明的下列实施例中,节点均指区块链节点。
在区块链网络中,一个节点是指一个具有唯一身份的参与者,节点能够参与区块链网络的组建和数据交换。区块链网络中的每个节点都具有一份完整的账本拷贝,并能基于该账本拷贝参与区块链网络的共识和账本维护。交易是用户对区块链的操作请求,交易由用户发起,比如从用户的客户端发往区块链中的节点,当区块链中的节点收到交易后,可以将交易打包成区块去执行。为了完成交易,区块链中的各个节点之间需要进行通信和存储。
节点在通信和存储过程中,都需要进行编码和/或解码,一个数据包从一个节点发送到另一个节点时,需要先编码,再解码。比如,一条区块数据被写入一个节点时,需要先编码,再写入,而区块数据从一个节点中读取出来时,也需要先解码,再读取。
在一种可能的实现方式中,区块链节点可以基于RLP编码方式进行编码。RLP编码方式以编码对象的个数为开头,编码对象紧随其后,而每个编码对象的大小是不固定的。且,RLP编码方式通过一种长度前缀和递归结合的方式进行编码。虽然理论上可编码任意个数的对象,但由于通过递归方式编码,因此区块链节点在编码前无法获知编码后的长度。且,在RLP编码方式中, 每个对象的长度不确定,而RLP编码只记录了对象的个数,并未记录对象的字节长度,因此,区块链节点仅能获取到编码对象的个数,无法获取到编码对象所在的位置。如此,采用RLP编码方式进行解码时,若要获取其中的一个编码对象,则必须先递归解码其前序的所有对象,在解码前序的对象后,才能访问到需要访问的编码对象的字节位置。因此,RLP编码方式在解码时只能顺序访问,而不支持随机访问,从而编码和解码的性能较低。
然而,现有的区块链节点存在访问任意编码对象的需求。举例来说,在批量交易场景中,区块链节点需要访问某个特定的已经被编码的交易对象。
基于此,本申请实施例提供一种编码方式,用以解决现有技术中RLP编解码方式只能对每个对象进行顺序访问,而不支持随机访问的技术问题。
图2为本申请实施例提出的一种编码方法的流程示意图,如图2所示,该方法包括:
步骤201:获取编码对象。
步骤202:将编码对象作为第一操作的操作对象,对编码对象按照第一操作进行编码。
步骤202中,第一操作包括:
步骤一,确定M,M为第一操作的操作对象包括的子操作对象个数。
显然,第一操作的操作对象包括的子操作对象个数至少为一个,因此,M为正整数。
步骤二,判断M是否等于1,若是,则执行步骤三,若否,则执行步骤四。
步骤三,对操作对象中唯一的子操作对象进行递归长度前缀RLP编码,获取该子操作对象的RLP编码。
此处,当一个编码对象仅包括一个子编码对象时,这个编码对象的编码就是RLP编码。
步骤四,按照操作对象中各个子操作对象的预设顺序,对每个子操作对象执行以下步骤:
(1)将该子操作对象作为第一操作的操作对象,对该子操作对象按照第一操作进行编码,获取该子操作对象的编码。
当操作对象包括1个以上的子操作对象时,执行步骤四,直到操作对象的子操作对象只有1个,不可继续向下一层分割时,才执行步骤一进行RLP编码,在此不再赘述。
(2)确定该子操作对象的编码相对于操作对象的编码的起始地址的位置偏移量。
(3)根据操作对象中每个子操作对象的RLP编码,以及该子操作对象的编码相对于起始地址的位置偏移量,确定操作对象的编码信息。
需要说明的是,预设顺序可根据具体场景进行设置,举例来说,按照编码习惯,将从左到右的顺序设置为预设顺序。
上述(2)中,子操作对象的编码的起始地址的位置偏移量为:子操作对象的编码的起始地址相对于操作对象的编码的起始地址的字节长度。若确定操作对象中存在未被编码的子操作对象,则返回(1);否则,执行(3)。通过对编码对象执行(2),能够记录编码对象中每个子编码对象相对于编码对象的起始地址的位置偏移量,也就是说,通过每个子编码对象相对于编码对象的起始地址的位置偏移量,能够定位到对应的子编码对象的位置,从而直接访问到该子编码对象,实现了对编码对象中每个子编码对象的随机访问,提升访问效率。
上述(2)中,一种可能的实施方式如下:针对于操作对象中执行了第一操作的一个子操作对象,若该子操作对象不为预设顺序中的首个,则根据该子操作对象对应的RLP编码的编码长度,以及该子操作对象在预设顺序中前一个子操作对象的编码相对于操作对象的编码的起始地址的位置偏移量,确定该子操作对象的编码相对于起始地址的位置偏移量。
举例来说,子操作对象A与子操作对象B为预设顺序中相邻的两个子操作对象,且子操作对象A先于子操作对象B执行第一操作,因此子操作对象B在预设顺序中前一个子操作对象为子操作对象A。子操作对象A相对于操 作对象的起始地址的位置偏移量X A,且子操作对象B的编码长度为S B,那么子操作对象B相对于操作对象的起始地址的位置偏移量X B为X A+S B
相应地,若该子操作对象为预设顺序中的首个,则将0作为该子操作对象的编码相对于操作对象的编码的起始地址的位置偏移量。
这里需要强调的是,操作对象只有1个子操作对象时的编码,与操作对象有2个及2个以上子操作对象时的编码不同。操作对象只有1个子操作对象时,不记录位置偏移量,但操作对象有2个及2个以上子操作对象时,记录第一个子操作对象的编码的位置偏移量为0,用作确定之后的子操作对象的位置偏移量的依据。
上述(3)中,一种可能的实施方式为:按M、位置偏移量部分、RLP编码部分的顺序组合得到操作对象的编码信息。其中,位置偏移量部分为:按照预设顺序组合操作对象中所有子操作对象的编码相对于操作对象的起始地址的位置偏移量,比如[子操作对象1的编码相对于操作对象的起始地址的位置偏移量,子操作对象2的编码相对于操作对象的起始地址的位置偏移量,……]。RLP编码部分为:按照预设顺序组合操作对象中所有子操作对象的RLP编码,比如[子操作对象1的RLP编码,子操作对象2的RLP编码,……]。
基于该种实施方式,图3为一种操作方法中编码的格式示意图,下面以图3中的编码格式为例对编解码过程进行具体说明。
如图3所示,编码的格式中包括位置偏移量字段,用以索引每个子编码对象的编码的位置。其中,Obj_num表示子编码对象的个数,Obj_x(比如Obj_0、Obj_1、Obj_2、Obj_3、……)表示第x个子编码对象的编码,Off_set_x(比如Off_set_0、Off_set_1、Off_set_2、Off_set_3、……)表示第x个子编码对象的编码相对于编码对象的编码的起始地址的位置偏移量,举例来说,从0开始编号,Off_set_0表示子编码对象Obj_0相对于编码对象的编码的起始地址的位置偏移量。
在该种实施方式中,编码格式的开头为子编码对象的个数字段(Obj_num),之后是位置偏移量部分(Off_sets),位置偏移量部分包括所有子操作对象的编 码相对于操作对象的编码的起始地址的位置偏移量,每个子操作对象对应的位置偏移量有着固定的长度,且按照预设顺序排列。因此若要读取某个Off_set的值,则只需像访问数组一样,根据Off_set的序号直接在Off_sets中索引,举例来说,若要读取Off_set_2,则直接获取Off_sets中的第三个元素即可。
在位置偏移量部分后,是RLP编码部分(Objs),RLP编码部分包括所有子操作对象的RLP编码,且按照预设顺序排列。需要说明的是,位置偏移量部分中的序号与RLP编码部分中的序号一一对应,即位置偏移量部分中相应序号的Off_set,指向相应序号的子编码对象的RLP编码的起始地址。举例来说,Off_set_0指向的子编码对象为Obj_0。因此,若要解码一个子编码对象的编码,则只需要根据子编码对象的序号,找到该子编码对象的编码相对于编码对象的编码起始地址的位置偏移量,再根据该位置偏移量,就可定位到相应子编码对象的编码的起始地址。
需要说明的是,步骤201~步骤202仅以一个编码对象为例进行说明,当区块数据中存在多个编码对象时,每个编码对象均可按照步骤201~步骤202进行编码。
图4为本申请实施例提供的一种解码方法的流程示意图,包括:
步骤401:获取第一解码对象相对于区块数据的第一起始地址的第一位置偏移量。
其中,第一解码对象为区块数据中至少两个解码对象中的一个,解码对象即为编码对象的编码。
步骤402:根据所述第一位置偏移量,获取所述第一解码对象。
由步骤201~步骤202的编码过程可知,若第一解码对象包括至少两个子解码对象,则第一解码对象还包括至少两个子解码对象中每个子解码对象相对于第一解码对象的第二起始地址的第二位置偏移量。
步骤403:根据所述至少两个子解码对象中每个子解码对象相对于解码对象的第二起始地址的第二位置偏移量,对第一解码对象进行解码。
对第一解码对象进行解码的解码过程为:将第一解码对象作为第一操作 的操作对象,对第一解码对象按照第一操作进行解码。所述第一操作为:
第一步,确定N,N为所述第一操作的操作对象包括的子操作对象的个数。
此处,N为正整数。
由步骤201~步骤202可知,当第一操作的操作对象为第一解码对象时,第一解码对象的首位的数据即为N。
若N等于1,则执行第二步。
第二步,对操作对象中唯一的子操作对象进行递归长度前缀RLP解码,获取该子操作对象的RLP解码。
由步骤201~步骤202可知,当第一操作的操作对象为第一解码对象时,第一解码对象为RLP编码,可直接通过RLP解码方式进行解码。
若N大于1,则执行第三步。
第三步,按照操作对象中子操作对象的预设顺序,对每个子操作对象,执行以下步骤:
(1)、获取该子操作对象相对于所述操作对象的第三起始地址的第三位置偏移量,并根据该第三位置偏移量,获取该子操作对象。
(2)、将该子操作对象作为所述第一操作的操作对象,对该子操作对象按照所述第一操作进行解码,获取该子操作对象的解码。
(3)、若确定所述操作对象中存在未被解码的子操作对象,则返回所述获取该子操作对象相对于所述操作对象的所述第三起始地址的第三位置偏移量的步骤。
下面结合图5和图6,对本申请实施例中提供的一种编解码方法进行详细说明。
如图5所示,为本申请实施例提供的一种编码方法的具体流程示意图。
以下步骤501~步骤512为对一个编码对象进行编码,输入是编码对象,编码对象为一个包含子编码对象的数组Objs,输出是编码对象的二进制编码Rlps。
步骤501:初始化,开辟第一临时数组(Off_sets),并将Off_sets中的第一个元素置为0,开辟第二临时数组(cds)。
其中,Off_sets用于缓存编码对象中每个子编码对象的编码相对于编码对象的编码起始地址的位置偏移量。cds用于缓存编码对象中每个子编码对象的二进制编码。
步骤502:获取编码部分Objs中子编码对象的个数(Objs_num),将Objs_num编码作为编码对象的编码信息(Rlps)的开头。
步骤503:确定Objs_num是否大于1。
若是,则进入步骤504,反之,进入步骤511。
步骤504:按编码对象中子编码对象起始地址从大到小的顺序,从Objs中取出一个未被编码过的子编码对象,作为X。
步骤505:将X作为步骤201~步骤202中第一操作的操作对象,对X进行第一操作,进行编码,获取X的编码(Rlp_X)和以及Rlp_X的编码长度(Rlp_X_Size)。
步骤506:根据Rlp_X_Size,确定X的位置偏移量(Off_set_X)。
此处,当X为Objs中首个被编码的子编码对象时,Off_set_X为0;否则,Off_set_X=(Off_set_X-1)+Rlp_X_Size。Off_set_X-1为X在预设顺序中前一个子编码对象的编码相对于编码对象起始地址的位置偏移量。
步骤507:将Off_set_X追加到Off_sets末端,以及将Rlp_X追加到cds末端。
步骤508:确定Objs是否有未被编码过的子编码对象。
若是,则执行步骤504,反之,执行步骤509。
步骤509:将Off_sets追加到Rlps的末端。
步骤509之前,Rlps中仅有Objs_num。
步骤510:将cds追加到Rlps的末端。
步骤510执行完后,编码过程结束。
步骤511:用RLP编码,对唯一的子编码对象Y进行编码,得到编码Rlp_Y。
步骤512:将Rlp_Y追加到Rlps的末端。
步骤512执行完后,编码过程结束。
如图6所示,为本申请实施例提供的一种解码方法的具体流程示意图。
以下步骤601~步骤606是对任意位置的子编码对象进行解码,输入是二进制编码Rlps以及需要访问的子编码对象X在编码对象的预设顺序中的序号(X_ID),输出是解码后的子编码对象X。
步骤601:确定Rlps的Obj_num是否大于1。
若是,则进入步骤602,否则,进入步骤606。
步骤602:根据X_ID,获取X-ID在Rlps的Offsets中对应的位置偏移量(Off_set_X)。
步骤603:用Off_set_X的值索引到需要访问的子编码对象X的编码(Rlp_X)。
此时的Rlp_X即为解码对象。
步骤604:确定Rlp_X中是否包括两个及以上的子解码对象。
若是,则执行步骤605;否则,执行步骤606。
步骤605:将Rlp_X作为步骤401~步骤403中第一操作的操作对象,对Rlp_X按照第一操作进行解码。
需要说明的是,在步骤605的解码过程中,仍然需要继续提供需要访问的下一层的子解码对象的序号。
步骤605执行完后,解码过程结束。
步骤606:对Rlps进行RLP解码,获取子编码对象X。
步骤606执行完后,解码过程结束。
本申请实施例中,获取编码对象之后,将编码对象作为第一操作的操作对象,对编码对象按照第一操作进行编码,第一操作中,首先确定M(M为正整数),M为所述第一操作的操作对象包括的子操作对象个数,第一操作按操作对象中的子操作对象分两种情况,第一种情况为:若M等于1,则对所述操作对象中唯一的子操作对象进行递归长度前缀RLP编码,获取该子操作 对象的RLP编码,显然,这种情况是支持随机访问的;第二种情况为:若M大于1,按照所述操作对象中子操作对象的预设顺序,对每个子操作对象按照所述第一操作进行编码,获取该子操作对象的编码之后,再确定该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,因此,可直接根据每个子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,定位到该子操作对象的编码,这种情况也是支持随机访问的。
针对上述方法流程,本发明实施例还提供一种编码装置,该装置的具体内容可以参照上述方法实施。
图7为本申请实施例提供的一种编码装置的结构示意图,如图7所示,包括:
获取模块701,用于获取编码对象;
编码模块702,用于将所述编码对象作为第一操作的操作对象,对所述编码对象按照所述第一操作进行编码;所述第一操作为:确定M,M为所述第一操作的操作对象包括的子操作对象的个数;M为正整数;以及用于若M等于1,则对所述操作对象中唯一的子操作对象进行递归长度前缀RLP编码,获取该子操作对象的RLP编码;若M大于1,按照所述操作对象中子操作对象的预设顺序,对每个子操作对象,执行以下步骤:将该子操作对象作为所述第一操作的操作对象,对该子操作对象按照所述第一操作进行编码,获取该子操作对象的编码;确定该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量;若确定所述操作对象中存在未被编码的子操作对象,则返回所述将该子操作对象作为所述第一操作的操作对象的步骤;否则,根据所述操作对象中每个子操作对象的编码,以及该子操作对象相对于所述起始地址的位置偏移量,确定所述操作对象的编码信息。
可选的,所述编码模块702具体用于:
若所述操作对象中执行了所述第一操作的子操作对象的顺序,不为所述预设顺序中的首个,则根据该子操作对象在所述预设顺序中前一个子操作对象编码的编码长度,以及该子操作对象在所述预设顺序中前一个子操作对象 的编码相对于所述操作对象的编码起始地址的位置偏移量,确定该子操作对象的编码相对于所述起始地址的位置偏移量。
可选的,所述编码模块702还用于:
若所述操作对象中执行了所述第一操作的子操作对象的顺序,为所述预设顺序中的首个,则将0作为该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量。
可选的,所述编码模块702具体用于:
将按M、位置偏移量部分、编码部分先后顺序组合的信息,作为所述操作对象的编码信息;
其中,所述位置偏移量部分为:所述操作对象中所有子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,按照所述预设顺序的组合;
所述编码部分为:所述操作对象中所有子操作对象的编码,按照所述预设顺序的组合。
图8为本申请实施例提供的一种解码装置的结构示意图,如图8所示,该装置包括:
获取模块801,用于获取第一解码对象相对于区块数据的第一起始地址的第一位置偏移量;所述第一解码对象为所述区块数据中至少两个解码对象中一个;
解码模块802,用于根据所述第一位置偏移量,获取所述第一解码对象;若所述第一解码对象包括至少两个子解码对象,则所述第一解码对象还包括所述至少两个子解码对象中每个子解码对象相对于所述第一解码对象的第二起始地址的第二位置偏移量;以及用于根据所述至少两个子解码对象中每个子解码对象相对于所述第一解码对象的第二起始地址的第二位置偏移量,对所述第一解码对象进行解码。
可选的,所述解码模块802具体用于:
将所述第一解码对象作为第一操作的操作对象,对所述第一解码对象按 照所述第一操作进行解码;所述第一操作为:确定N,N为所述第一操作的操作对象包括的子操作对象的个数,N为正整数;
若N等于1,则对所述操作对象中唯一的子操作对象进行递归长度前缀RLP解码,获取该子操作对象的RLP解码;
若N大于1,按照所述操作对象中子操作对象的预设顺序,对每个子操作对象,执行以下步骤:
获取该子操作对象相对于所述操作对象的第三起始地址的第三位置偏移量,并根据该第三位置偏移量,获取该子操作对象;将该子操作对象作为所述第一操作的操作对象,对该子操作对象按照所述第一操作进行解码,获取该子操作对象的解码;若确定所述操作对象中存在未被解码的子操作对象,则返回所述获取该子操作对象相对于所述操作对象的所述第三起始地址的第三位置偏移量的步骤。
基于同一发明构思,本申请实施例提供一种计算机设备,如图9所示,包括至少一个处理器901,以及与至少一个处理器连接的存储器902,本发明实施例中不限定处理器901与存储器902之间的具体连接介质,图9中处理器901和存储器902之间通过总线连接为例。总线可以分为地址总线、数据总线、控制总线等。
在本发明实施例中,存储器902存储有可被至少一个处理器901执行的指令,至少一个处理器901通过执行存储器902存储的指令,可以执行上述任意步骤所述的编码方法及可选方法或者解码方法及可选方法。
其中,处理器901是计算机设备的控制中心,可以利用各种接口和线路连接计算机设备的各个部分,通过运行或执行存储在存储器902内的指令以及调用存储在存储器902内的数据,从而实现数据处理。可选的,处理器901可包括一个或多个处理单元,处理器901可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理下发指令。可以理解的是,上述调制解调处理器也可以不集成到处理器901中。在一些实施例中,处理器901和存储器902可以在同 一芯片上实现,在一些实施例中,它们也可以在独立的芯片上分别实现。
处理器901可以是通用处理器,例如中央处理器(CPU)、数字信号处理器、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件,可以实现或者执行本发明实施例中公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者任何常规的处理器等。结合编码实施例所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。
存储器902作为一种非易失性计算机可读存储介质,可用于存储非易失性软件程序、非易失性计算机可执行程序以及模块。存储器902可以包括至少一种类型的存储介质,例如可以包括闪存、硬盘、多媒体卡、卡型存储器、随机访问存储器(Random Access Memory,RAM)、静态随机访问存储器(Static Random Access Memory,SRAM)、可编程只读存储器(Programmable Read Only Memory,PROM)、只读存储器(Read Only Memory,ROM)、带电可擦除可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,EEPROM)、磁性存储器、磁盘、光盘等等。存储器902是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。本发明实施例中的存储器902还可以是电路或者其它任意能够实现存储功能的装置,用于存储程序指令和/或数据。
基于同一发明构思,本申请实施例提供一种存储介质,包括程序或指令,当所述程序或指令被执行时,如本申请实施例提供的一种编码方法及可选方法或者解码方法及可选方法被执行。
最后应说明的是:本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、光学存储器等)上实施的计算机程序产品的形 式。
本申请是参照根据本申请的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。

Claims (14)

  1. 一种编码方法,其特征在于,包括:
    获取编码对象;
    将所述编码对象作为第一操作的操作对象,对所述编码对象按照所述第一操作进行编码;所述第一操作为:
    确定M,M为所述第一操作的操作对象包括的子操作对象的个数;M为正整数;
    若M等于1,则对所述操作对象中唯一的子操作对象进行递归长度前缀RLP编码,获取该子操作对象的RLP编码;
    若M大于1,按照所述操作对象中子操作对象的预设顺序,对每个子操作对象,执行以下步骤:
    将该子操作对象作为所述第一操作的操作对象,对该子操作对象按照所述第一操作进行编码,获取该子操作对象的编码;
    确定该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量;
    若确定所述操作对象中存在未被编码的子操作对象,则返回所述将该子操作对象作为所述第一操作的操作对象的步骤;否则,根据所述操作对象中每个子操作对象的编码,以及该子操作对象相对于所述起始地址的位置偏移量,确定所述操作对象的编码信息。
  2. 如权利要求1所述的方法,其特征在于,所述确定该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,包括:
    若所述操作对象中执行了所述第一操作的子操作对象的顺序,不为所述预设顺序中的首个,则根据该子操作对象在所述预设顺序中前一个子操作对象编码的编码长度,以及该子操作对象在所述预设顺序中前一个子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,确定该子操作对象的编码相对于所述起始地址的位置偏移量。
  3. 如权利要求2所述的方法,其特征在于,所述确定该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,还包括:
    若所述操作对象中执行了所述第一操作的子操作对象的顺序,为所述预设顺序中的首个,则将0作为该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量。
  4. 如权利要求1-3任一所述的方法,其特征在于,所述根据所述操作对象中每个子操作对象的编码,以及该子操作对象相对于所述起始地址的位置偏移量,确定所述操作对象的编码信息,包括:
    将按M、位置偏移量部分、编码部分先后顺序组合的信息,作为所述操作对象的编码信息;所述位置偏移量部分为:所述操作对象中所有子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,按照所述预设顺序的组合;所述编码部分为:所述操作对象中所有子操作对象的编码,按照所述预设顺序的组合。
  5. 一种解码方法,其特征在于,包括:
    获取第一解码对象相对于区块数据的第一起始地址的第一位置偏移量;所述第一解码对象为所述区块数据中至少两个解码对象中的一个;
    根据所述第一位置偏移量,获取所述第一解码对象;若所述第一解码对象包括至少两个子解码对象,则所述第一解码对象还包括所述至少两个子解码对象中每个子解码对象相对于所述第一解码对象的第二起始地址的第二位置偏移量;
    根据所述至少两个子解码对象中每个子解码对象相对于所述第一解码对象的第二起始地址的第二位置偏移量,对所述第一解码对象进行解码。
  6. 如权利要求5所述的方法,其特征在于,所述根据所述至少两个子解码对象中每个子解码对象相对于所述第一解码对象的第二起始地址的第二位置偏移量,对所述第一解码对象进行解码,包括:
    将所述第一解码对象作为第一操作的操作对象,对所述第一解码对象按照所述第一操作进行解码;所述第一操作为:
    确定N,N为所述第一操作的操作对象包括的子操作对象的个数,N为正整数;
    若N等于1,则对所述操作对象中唯一的子操作对象进行递归长度前缀RLP解码,获取该子操作对象的RLP解码;
    若N大于1,按照所述操作对象中子操作对象的预设顺序,对每个子操作对象,执行以下步骤:
    获取该子操作对象相对于所述操作对象的第三起始地址的第三位置偏移量,并根据该第三位置偏移量,获取该子操作对象;
    将该子操作对象作为所述第一操作的操作对象,对该子操作对象按照所述第一操作进行解码,获取该子操作对象的解码;
    若确定所述操作对象中存在未被解码的子操作对象,则返回所述获取该子操作对象相对于所述操作对象的所述第三起始地址的第三位置偏移量的步骤。
  7. 一种编码装置,其特征在于,包括:
    获取模块,用于获取编码对象;
    编码模块,用于将所述编码对象作为第一操作的操作对象,对所述编码对象按照所述第一操作进行编码;所述第一操作为:确定M,M为所述第一操作的操作对象包括的子操作对象的个数,M为正整数;
    以及用于若M等于1,则对所述操作对象中唯一的子操作对象进行递归长度前缀RLP编码,获取该子操作对象的RLP编码;若M大于1,按照所述操作对象中子操作对象的预设顺序,对每个子操作对象,执行以下步骤:将该子操作对象作为所述第一操作的操作对象,对该子操作对象按照所述第一操作进行编码,获取该子操作对象的编码;确定该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量;若确定所述操作对象中存在未被编码的子操作对象,则返回所述将该子操作对象作为所述第一操作的操作对象的步骤;否则,根据所述操作对象中每个子操作对象的编码,以及该子操作对象相对于所述起始地址的位置偏移量,确定所述操作对象的编码信息。
  8. 如权利要求7所述的装置,其特征在于,所述编码模块具体用于:
    若所述操作对象中执行了所述第一操作的子操作对象的顺序,不为所述预设顺序中的首个,则根据该子操作对象在所述预设顺序中前一个子操作对象编码的编码长度,以及该子操作对象在所述预设顺序中前一个子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,确定该子操作对象的编码相对于所述起始地址的位置偏移量。
  9. 如权利要求8所述的装置,其特征在于,所述编码模块还用于:
    若所述操作对象中执行了所述第一操作的子操作对象的顺序,为所述预设顺序中的首个,则将0作为该子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量。
  10. 如权利要求7-9任一所述的装置,其特征在于,所述编码模块具体用于:
    将按M、位置偏移量部分、编码部分先后顺序组合的信息,作为所述操作对象的编码信息;所述位置偏移量部分为:所述操作对象中所有子操作对象的编码相对于所述操作对象的编码起始地址的位置偏移量,按照所述预设顺序的组合;所述编码部分为:所述操作对象中所有子操作对象的编码,按照所述预设顺序的组合。
  11. 一种解码装置,其特征在于,包括:
    获取模块,用于获取第一解码对象相对于区块数据的第一起始地址的第一位置偏移量;所述第一解码对象为所述区块数据中至少两个解码对象中的一个;
    解码模块,用于根据所述第一位置偏移量,获取所述第一解码对象;若所述第一解码对象包括至少两个子解码对象,则所述第一解码对象还包括所述至少两个子解码对象中每个子解码对象相对于所述第一解码对象的第二起始地址的第二位置偏移量;
    以及用于根据所述至少两个子解码对象中每个子解码对象相对于所述第一解码对象的第二起始地址的第二位置偏移量,对所述第一解码对象进行解 码。
  12. 如权利要求11所述的装置,其特征在于,所述解码模块具体用于:
    将所述第一解码对象作为第一操作的操作对象,对所述第一解码对象按照所述第一操作进行解码;所述第一操作为:
    确定N,N为所述第一操作的操作对象包括的子操作对象的个数,N为正整数;
    若N等于1,则对所述操作对象中唯一的子操作对象进行递归长度前缀RLP解码,获取该子操作对象的RLP解码;
    若N大于1,按照所述操作对象中子操作对象的预设顺序,对每个子操作对象,执行以下步骤:
    获取该子操作对象相对于所述操作对象的第三起始地址的第三位置偏移量,并根据该第三位置偏移量,获取该子操作对象;
    将该子操作对象作为所述第一操作的操作对象,对该子操作对象按照所述第一操作进行解码,获取该子操作对象的解码;
    若确定所述操作对象中存在未被解码的子操作对象,则返回所述获取该子操作对象相对于所述操作对象的所述第三起始地址的第三位置偏移量的步骤。
  13. 一种计算机设备,其特征在于,包括程序或指令,当所述程序或指令被执行时,如权利要求1至4,或5至6中任意一项所述的方法被执行。
  14. 一种存储介质,其特征在于,包括程序或指令,当所述程序或指令被执行时,如权利要求1至4,或5至6中任意一项所述的方法被执行。
PCT/CN2020/080712 2019-04-26 2020-03-23 一种编解码方法、装置、计算机设备及存储介质 Ceased WO2020215951A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910343404.3A CN110096624B (zh) 2019-04-26 2019-04-26 一种编解码方法、装置、计算机设备及存储介质
CN201910343404.3 2019-04-26

Publications (1)

Publication Number Publication Date
WO2020215951A1 true WO2020215951A1 (zh) 2020-10-29

Family

ID=67445881

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/080712 Ceased WO2020215951A1 (zh) 2019-04-26 2020-03-23 一种编解码方法、装置、计算机设备及存储介质

Country Status (2)

Country Link
CN (1) CN110096624B (zh)
WO (1) WO2020215951A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110096624B (zh) * 2019-04-26 2023-03-21 深圳前海微众银行股份有限公司 一种编解码方法、装置、计算机设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040139090A1 (en) * 2003-01-15 2004-07-15 Chia-Yow Yeh Method and apparatus of recording compression encoding tables in a pseudo read-only memory
CN107153588A (zh) * 2017-05-12 2017-09-12 成都优孚达信息技术有限公司 数据编码存储方法
CN109104198A (zh) * 2018-06-28 2018-12-28 郑州云海信息技术有限公司 一种数据压缩方法、解压方法、装置及电子设备
CN109582653A (zh) * 2018-11-14 2019-04-05 网易(杭州)网络有限公司 文件的压缩、解压缩方法及设备
CN110096624A (zh) * 2019-04-26 2019-08-06 深圳前海微众银行股份有限公司 一种编解码方法、装置、计算机设备及存储介质

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6232984B1 (en) * 1997-05-22 2001-05-15 Lucent Technologies, Inc. Data visualization system
JP2005159787A (ja) * 2003-11-27 2005-06-16 Sony Corp 画像処理装置、および画像処理方法、並びにコンピュータ・プログラム
CN105791833B (zh) * 2014-12-17 2018-09-04 深圳Tcl数字技术有限公司 选择视频编解码硬件平台的方法及装置
CN106716998B (zh) * 2016-12-26 2019-09-17 深圳前海达闼云端智能科技有限公司 多操作系统多媒体数据编解码方法、装置以及电子设备
WO2018119955A1 (zh) * 2016-12-29 2018-07-05 深圳前海达闼云端智能科技有限公司 跨系统多媒体数据编解码方法、装置、电子设备和计算机程序产品

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040139090A1 (en) * 2003-01-15 2004-07-15 Chia-Yow Yeh Method and apparatus of recording compression encoding tables in a pseudo read-only memory
CN107153588A (zh) * 2017-05-12 2017-09-12 成都优孚达信息技术有限公司 数据编码存储方法
CN109104198A (zh) * 2018-06-28 2018-12-28 郑州云海信息技术有限公司 一种数据压缩方法、解压方法、装置及电子设备
CN109582653A (zh) * 2018-11-14 2019-04-05 网易(杭州)网络有限公司 文件的压缩、解压缩方法及设备
CN110096624A (zh) * 2019-04-26 2019-08-06 深圳前海微众银行股份有限公司 一种编解码方法、装置、计算机设备及存储介质

Also Published As

Publication number Publication date
CN110096624A (zh) 2019-08-06
CN110096624B (zh) 2023-03-21

Similar Documents

Publication Publication Date Title
RU2629440C2 (ru) Устройство и способ для ускорения операций сжатия и распаковки
CN111249736B (zh) 代码处理方法及装置
CN111831208B (zh) 一种信息处理方法、装置、终端设备及存储介质
CN114064984B (zh) 一种基于稀疏数组链表的世界状态增量更新方法及装置
CN109542636B (zh) 一种数据更新的方法及装置
CN112433986B (zh) 数据的存储方法、电子设备以及计算机可读存储介质
CN112307138B (zh) 地域信息的存储和查询方法、系统与介质
CN114020272A (zh) 一种序列化编码、解码方法、装置及电子设备
CN112511629A (zh) 一种mpt结构的账户树的数据压缩方法及系统
CN114153848A (zh) 区块链数据存储方法及装置、电子设备
JP2003273748A (ja) 改善されたハフマンデコーディング方法及び装置
CN112491763B (zh) 一种针对曼彻斯特编码的解码方法及装置
CN114356647A (zh) 一种eps系统数据编码及存储方法
WO2020215951A1 (zh) 一种编解码方法、装置、计算机设备及存储介质
CN106293542B (zh) 一种文件解压缩的方法及装置
CN116431527A (zh) 一种地址重映射的数据读写方法、系统、设备和介质
CN116975006A (zh) 基于磁盘缓存及b树索引的数据去重方法、系统及介质
CN113093992B (zh) 一种命令的解压方法、系统及固态硬盘
CN112131202B (zh) 一种分布式文件存储和读取方法、终端设备及存储介质
CN113703873A (zh) 客户端的冷启动方法、装置、介质、设备和程序产品
CN117290332B (zh) 一种数据迁移校验方法、装置、设备及存储介质
CN114356220B (zh) 基于dna存储的编码方法、电子设备及可读存储介质
CN114385624A (zh) 编码方法、编码查找方法、装置、电子设备及存储介质
CN119759896B (zh) 状态树数据缓存方法、装置、电子设备和计算机程序产品
CN114090928B (zh) 嵌套html实体解码方法、装置、计算机设备和存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20794129

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20794129

Country of ref document: EP

Kind code of ref document: A1