Method, device and electronic device for determining directed acyclic graph
By introducing read set and write set dictionaries and a location dictionary, direct conflicts of transactions within blockchain blocks are directly determined, solving the problem of inefficiency in existing technologies and achieving more efficient DAG construction.
Patent Information
- Application Number
- CN202210458041.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-27
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2042-04-27
AI Technical Summary
Existing technologies are inefficient in determining the directed acyclic graph of transactions within a blockchain block, especially when the collision rate is low, as they require traversing all transactions, increasing unnecessary workload.
By introducing a read set dictionary, a write set dictionary, a read set key position dictionary, and a write set key position dictionary for the transaction set, transactions that directly conflict with the current transaction can be identified directly. This avoids the need to construct read set bitmaps and write set bitmaps and traverse all transactions, thus improving the efficiency of determining the DAG.
It improves the efficiency of determining the DAG, reduces the complexity, and avoids unnecessary traversal operations, especially when the collision rate is low.
Smart Images

Figure CN117011034B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain technology, and more specifically, to methods, apparatus, and electronic devices for determining directed acyclic graphs. Background Art
[0002] For transactions within a block on the Chang'an Chain, a Directed Acyclic Graph (DAG) can be constructed for the block. The DAG is used to express the dependencies between transactions within the block, so that the validator nodes in the consensus nodes can execute transactions in the same order as the proposer nodes according to the DAG of the packaged block sent by the proposer nodes, thereby achieving consensus.
[0003] Currently, determining the DAG of a block typically involves first determining the read set bitmap and write set bitmap for the current transaction within the block according to the actual transaction execution order. Then, a traversal process is used to determine the cumulative read and write bitmaps representing transactions that conflict with the current transaction. Finally, based on the current transaction's read set bitmap, write set bitmap, cumulative read bitmap, and cumulative write bitmap, all transactions are traversed using a slower bitmap comparison method to identify transactions that directly conflict with the current transaction. Therefore, this method of determining the DAG requires traversing all transactions for conflict checks when determining the cumulative read and write bitmaps of the current transaction and when searching for transactions that directly conflict with the current transaction, thus reducing the efficiency of DAG determination.
[0004] In particular, when the conflict rate is low, the need to traverse most transactions to find conflicting transactions increases unnecessary workload and reduces the efficiency of determining the DAG. Summary of the Invention
[0005] This application provides a method, apparatus, and electronic device for determining a directed acyclic graph (DAG), which can improve the efficiency of DAG determination.
[0006] In a first aspect, embodiments of this application provide a method for determining a directed acyclic graph, including:
[0007] Get the transaction order of transactions in a transaction set;
[0008] Based on the transaction order, determine the read set dictionary, the write set dictionary, the read set keyword position dictionary, and the write set keyword position dictionary for the transaction set.
[0009] The key of the read set dictionary includes: the read set key of the transaction in the transaction set, and the value of each read set key in the read set dictionary includes: the number of the transaction that depends on each read set key;
[0010] The key of the write set dictionary includes: the write set key of the transaction in the transaction set, and the value of each write set key in the write set dictionary includes: the number of the transaction that depends on each write set key;
[0011] The keywords of the read set keyword position dictionary include: a two-dimensional read set keyword formed by the transaction number in the transaction set and the read set keyword of the transaction in the transaction set; the value of each two-dimensional read set keyword in the read set keyword position dictionary is used to indicate: the position of the transaction number in each two-dimensional read set keyword in the read set dictionary, which is the position of the transaction number included by the value of the read set keyword in each two-dimensional read set keyword;
[0012] The keywords of the write set keyword position dictionary include: a two-dimensional write set keyword formed by the transaction number in the transaction set and the write set keyword of the transaction in the transaction set; the value of each two-dimensional write set keyword in the write set keyword position dictionary is used to indicate: the position of the transaction number in each two-dimensional write set keyword in the write set dictionary within the transaction number included by the value of the write set keyword in each two-dimensional write set keyword.
[0013] Based on the read set keyword location dictionary and the write set keyword location dictionary, determine the number of the transaction that directly conflicts with the current transaction in the transaction set in the read set dictionary and the write set dictionary;
[0014] Based on the transaction numbers that directly conflict with the current transaction, a directed acyclic graph is determined for the transaction set.
[0015] Secondly, embodiments of this application provide an apparatus for determining a directed acyclic graph, comprising:
[0016] The acquisition unit is used to retrieve the transaction order of transactions in the transaction set;
[0017] The determining unit is used to determine, based on the transaction order, the read set dictionary, the write set dictionary, the read set keyword position dictionary, and the write set keyword position dictionary of the transaction set;
[0018] The key of the read set dictionary includes: the read set key of the transaction in the transaction set, and the value of each read set key in the read set dictionary includes: the number of the transaction that depends on each read set key;
[0019] The key of the write set dictionary includes: the write set key of the transaction in the transaction set, and the value of each write set key in the write set dictionary includes: the number of the transaction that depends on each write set key;
[0020] The keywords of the read set keyword position dictionary include: a two-dimensional read set keyword formed by the transaction number in the transaction set and the read set keyword of the transaction in the transaction set; the value of each two-dimensional read set keyword in the read set keyword position dictionary is used to indicate: the position of the transaction number in each two-dimensional read set keyword in the read set dictionary, which is the position of the transaction number included by the value of the read set keyword in each two-dimensional read set keyword;
[0021] The keywords of the write set keyword position dictionary include: a two-dimensional write set keyword formed by the transaction number in the transaction set and the write set keyword of the transaction in the transaction set; the value of each two-dimensional write set keyword in the write set keyword position dictionary is used to indicate: the position of the transaction number in each two-dimensional write set keyword in the write set dictionary within the transaction number included by the value of the write set keyword in each two-dimensional write set keyword.
[0022] The determining unit is also used to: based on the read set keyword location dictionary and the write set keyword location dictionary, determine the number of the transaction that directly conflicts with the current transaction in the transaction set in the read set dictionary and the write set dictionary;
[0023] The determining unit is also used to: determine the directed acyclic graph of the transaction set based on the transaction numbers that directly conflict with the current transaction.
[0024] Thirdly, this application provides an electronic device, comprising:
[0025] Processor, adapted to implement computer instructions; and,
[0026] A computer-readable storage medium storing computer instructions adapted to be loaded by a processor and to execute the method of the first aspect described above.
[0027] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer instructions that, when read and executed by a processor of a computer device, cause the computer device to perform the method described in the first aspect.
[0028] Fifthly, embodiments of this application provide a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method described in the first aspect.
[0029] Based on the above technical solutions, this application introduces a read set dictionary, a write set dictionary, a read set keyword position dictionary, and a write set keyword position dictionary for the transaction set when determining transactions that directly conflict with the current transaction in the transaction set. Through the design of these dictionaries, this application can determine the numbers of transactions that directly conflict with the current transaction in the transaction set based on the read set keyword position dictionary and the write set keyword position dictionary. That is, it directly determines transactions that directly conflict with the current transaction from the perspective of read set keywords and write set keywords. This not only eliminates the need to construct read set bitmaps and write set bitmaps for the current transaction but also avoids the slow bitmap comparison method and the method of traversing all transactions to determine transactions that directly conflict with the current transaction, thus improving the efficiency of determining the DAG.
[0030] Taking the read set dictionary and the read set keyword position dictionary as examples, this application designs the keywords of the read set dictionary to include: read set keywords of transactions in the transaction set, and designs the value of each read set keyword in the read set dictionary to include: the transaction number that depends on each read set keyword; equivalently, the values of the keywords that enable the read set keyword in the read set dictionary to be the keyword of the current transaction include: transactions that directly conflict with the current transaction; furthermore, this application designs the keywords of the read set keyword position dictionary to include: a two-dimensional read set keyword formed by the transaction number and the read set keyword of the transaction in the transaction set, and designs each read set keyword position dictionary to include: The value of the two-dimensional key is designed to indicate the position of the transaction number in each read set's two-dimensional key within the read set dictionary, where the read set key is the value of the read set key in each read set's two-dimensional key. In other words, given that the key of the current transaction is determined, the transaction that directly conflicts with the current transaction can be identified from the transaction numbers in the read set dictionary whose key is the value of the current key, based on the position indicated by the value of the read set's two-dimensional key that includes the key of the current transaction. This avoids identifying the transaction that directly conflicts with the current transaction by traversing all transactions, thus improving the efficiency of determining the DAG.
[0031] Taking the write set dictionary and the write set keyword position dictionary as examples, this application designs the keywords of the write set dictionary to include: the write set keywords of transactions in the transaction set, and designs the value of each write set keyword in the write set dictionary to include: the transaction number that depends on each write set keyword; equivalently, the values that enable the write set keyword in the write set dictionary to be the keyword of the current transaction include: transactions that directly conflict with the current transaction; furthermore, this application designs the keywords of the write set keyword position dictionary to include: a two-dimensional write set keyword formed by the transaction number and the write set keyword of the transaction in the transaction set, and designs each write set keyword position dictionary to include: the write set keyword that depends on each write set keyword. The value of the two-dimensional key is designed to indicate the position of the transaction number in each write set two-dimensional key within the write set dictionary of transaction numbers whose write set key is the value of the write set key in each write set two-dimensional key. In other words, given that the key of the current transaction is determined, the transaction that directly conflicts with the current transaction can be identified from the transaction numbers in the write set dictionary whose key is the value of the current key, based on the position indicated by the value of the write set two-dimensional key that includes the key of the current transaction in the write set key position dictionary. This avoids identifying the transaction that directly conflicts with the current transaction by traversing all transactions, thus improving the efficiency of determining the DAG. Attached Figure Description
[0032] Figure 1 This is a schematic diagram of the structure of the blockchain system provided in the embodiments of this application.
[0033] Figure 2 This is a schematic diagram of the block structure provided in the embodiments of this application.
[0034] Figure 3 This is a schematic flowchart of a method for determining a directed acyclic graph provided in an embodiment of this application.
[0035] Figure 4 This is an example of a read set dictionary provided in the embodiments of this application.
[0036] Figure 5 This is an example of a write set dictionary provided in the embodiments of this application.
[0037] Figure 6 This is an example of a dictionary of read set keyword positions provided in an embodiment of this application.
[0038] Figure 7 This is an example of the write set keyword location dictionary provided in the embodiments of this application.
[0039] Figures 8 to 11 These are examples of direct conflict bitmaps and cumulative conflict bitmaps of transactions provided in embodiments of this application.
[0040] Figure 12 This is an example of an adjacency list provided in an embodiment of this application.
[0041] Figure 13 This is a schematic block diagram of an apparatus for determining a directed acyclic graph provided in an embodiment of this application.
[0042] Figure 14 This is a schematic block diagram of the electronic device provided in the embodiments of this application. Detailed Implementation
[0043] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the various embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0044] The system involved in the embodiments of this application can be a distributed system formed by connecting a client and multiple nodes (any form of computing device in the network, such as a server or user terminal) through network communication.
[0045] Taking a distributed system as an example, see blockchain system. Figure 1 , Figure 1 This is an optional structural diagram of the distributed system 100 provided in this application embodiment applied to a blockchain system. It consists of multiple nodes (any form of computing device in the network, such as servers or user terminals) and clients, forming a peer-to-peer (P2P) network. The P2P protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). In the distributed system, any machine, such as a server or terminal, can join and become a node. A node includes a hardware layer, a middleware layer, an operating system layer, and an application layer.
[0046] See Figure 1 The functions of each node in the blockchain system shown include:
[0047] 1) Routing: A basic function of a node used to support communication between nodes.
[0048] In addition to routing capabilities, nodes can also have the following functions:
[0049] 2) Application: It is used to deploy in the blockchain to realize specific business according to actual business needs, record data related to the realization of functions to form record data, carry digital signature in the record data to indicate the source of task data, and send the record data to other nodes in the blockchain system. When other nodes successfully verify the source and integrity of the record data, they add the record data to the temporary block.
[0050] For example, the business logic implemented by the application includes:
[0051] 2.1) Wallet: Used to provide the function of conducting electronic currency transactions, including initiating transactions (i.e., sending the transaction record of the current transaction to other nodes in the blockchain system. After the other nodes successfully verify the transaction, they store the transaction record data in the temporary block of the blockchain as a response to acknowledge the validity of the transaction; of course, the wallet also supports querying the remaining electronic currency in the electronic currency address.
[0052] 2.2) Shared Ledger: This provides functions for storing, querying, and modifying ledger data. It sends records of operations on ledger data to other nodes in the blockchain system. After other nodes verify the validity, they store the records in a temporary block as a response acknowledging the validity of the ledger data. It can also send confirmation to the node that initiated the operation.
[0053] 2.3) Smart Contracts: Computerized protocols that can execute the terms of a contract. They are implemented through code deployed on a shared ledger that executes when certain conditions are met. Based on actual business needs, the code is used to complete automated transactions, such as querying the logistics status of goods purchased by a buyer and transferring the buyer's electronic money to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions; they can also execute contracts for processing received information.
[0054] 3) Blockchain: It consists of a series of blocks that are sequentially generated. Once a new block is added to the blockchain, it will not be removed. The blocks record the data submitted by the nodes in the blockchain system.
[0055] See Figure 2 , Figure 2This is an optional schematic diagram of the block structure provided in this application embodiment. Each block includes the hash value of the transaction records stored in this block (the hash value of this block) and the hash value of the previous block. The blocks are connected through their hash values to form a blockchain. Additionally, the block may include information such as a timestamp when it was generated. A blockchain is essentially a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains relevant information used to verify the validity of the information (anti-counterfeiting) and to generate the next block.
[0056] The following is a description of the terminology used in this application:
[0057] Blockchain: A distributed ledger technology in the field of information technology, generally consisting of consensus, transaction blocks and state data storage, cryptographic identity security, etc. Because the ledger is stored in a distributed manner and the blocks are agreed upon, it has the characteristics of immutability, traceability, and joint maintenance.
[0058] Consensus: The mechanism by which all nodes in a blockchain system jointly maintain the development of blocks, such as the common POW, POS, DPOS, PBFT, etc.
[0059] Node: A blockchain node is the smallest unit that participates in the maintenance of the blockchain and is the unit for deploying and running blockchain node programs.
[0060] Consensus Node: A consensus node is a type of node that participates in the consensus voting of the blockchain, and after reaching a consensus, the height of the chain continues to grow.
[0061] Proposal Node: A block-producing node is a type of consensus node used to package blocks and propose them.
[0062] Validator Nodes: Validator nodes are also a type of consensus node, used to verify the blocks packaged by the proposing nodes and vote based on the verification results.
[0063] Bitmap: A commonly used data structure in the computer field, often used to express references to numbered data.
[0064] Read and write sets: These include read sets and write sets. The read set refers to all key-value pairs that a transaction reads from the blockchain, while the write set refers to all key-value pairs that a transaction writes to the blockchain.
[0065] Dynamic arrays: Dynamic arrays are a type of array that, compared to regular arrays, have the characteristic of self-managing space. For example, when adding elements to a dynamic array, if the array's space is insufficient, it can automatically expand. In this algorithm, the dynamic array is used to store all transaction numbers associated with a specific keyword.
[0066] Dictionary: A dictionary is a convenient data structure for retrieval, characterized by the ability to quickly find the corresponding value based on a keyword. In some programming languages, dictionaries are also called maps. This algorithm includes a read set dictionary and a write set dictionary. The read set dictionary stores the keywords of all transaction read sets and a dynamic array of transaction numbers using those keywords as read set indices. The write set dictionary stores the keywords of all transaction write sets and a dynamic array of transaction numbers using those keywords as write set indices.
[0067] Directed Acyclic Graph (DAG): A commonly used data structure in computer science. Due to the superior properties brought by its unique topological structure, it is frequently used in various algorithmic scenarios such as dynamic programming, finding the shortest path in navigation, and data compression. DAG can be represented using an adjacency list array.
[0068] Adjacency list: A commonly used data structure in computer science. In graph theory, it is often used to represent the nodes that are adjacent to a given node in a graph. In a DAG graph, an adjacency list is used to represent the set of nodes that a node depends on. It is often implemented using a dynamic array.
[0069] For transactions within a block on the Chang'an Chain, a Directed Acyclic Graph (DAG) can be constructed for the block. The DAG is used to express the dependencies between transactions within the block, so that the validator nodes in the consensus nodes can execute transactions in the same order as the proposer nodes according to the DAG of the packaged block sent by the proposer nodes, thereby achieving consensus.
[0070] The construction steps of the DAG construction algorithm for the Chang'an Chain are as follows:
[0071] 1. Number all transactions according to the actual execution order.
[0072] 2. Construct the global read-write set dictionary, transaction read set bitmap, and transaction write set bitmap, as follows:
[0073] 1) Initialize the global read-write set dictionary key value to 0 (that is, the first key in the dictionary has a value of 0).
[0074] 2) Check if the transaction set is empty. If it is empty, end the process. If it is not empty, take one transaction from all transactions in order of transaction number.
[0075] 3) Check if the transaction's read set is empty. If it is empty, proceed to step 7). If it is not empty, retrieve a read set element from the transaction's read set with the key KRX.
[0076] 4) Check if the global read / write set dictionary contains an element with the key KRX. If not, add the key to the dictionary and set its value to the key value of the global read / write set dictionary. The key value of the global read / write set dictionary is then assigned the original value plus 1.
[0077] 5) Set the position of the transaction's read set bitmap in the global read-write set dictionary with the key KRX as the key to 1.
[0078] 6) Continue with step 3).
[0079] 7) Check if the write set of the transaction is empty. If it is empty, proceed to step 2). If it is not empty, retrieve a write set element from the transaction's write set with the key KWX.
[0080] 8) Check if the global read / write set dictionary contains an element with the key KWX. If not, add the key to the dictionary and set its value to the key value of the global read / write set dictionary. The key value of the global read / write set dictionary is then assigned the original value plus 1.
[0081] 9) Set the value of the write set bitmap of the transaction to 1 in the global read-write set dictionary with the key KWX.
[0082] 10) Continue with step 7).
[0083] 3. Construct read and write cumulative bitmaps for all transactions sequentially by transaction number. The cumulative bitmap is the OR of the bitmaps of all transactions preceding this transaction, representing the key-value pair read or write reference relationships of all transactions before this transaction. The process is as follows:
[0084] 1) Check if the transaction read chart set is empty. If it is not empty, proceed to step 2). If it is empty, proceed to step 5.
[0085] 2) Take a transaction read bitmap from the transaction read bitmap set in numerical order and assign it to the value in the read cumulative transaction bitmap with this transaction number as the key.
[0086] 3) Check if the transaction number is greater than 0. If it is greater than 0, then assign the value with this transaction number as the key in the read cumulative transaction bitmap to the OR value of the value with this transaction number as the key in the read cumulative transaction bitmap and the value with this transaction number minus 1 as the key in the read cumulative transaction bitmap.
[0087] 4) Continue with step 2).
[0088] 5) Check if the transaction write bitmap set is empty. If it is not empty, proceed to step 6). If it is empty, end this process.
[0089] 6) Take a transaction write bitmap from the transaction write bitmap set in numerical order and assign it to the value in the write cumulative transaction bitmap with this transaction number as the key.
[0090] 7) Check if the transaction number is greater than 0. If it is greater than 0, assign the value with this transaction number as the key in the written cumulative transaction bitmap to the OR value of the value with this transaction number as the key in the written cumulative transaction bitmap and the value with this transaction number minus 1 as the key in the written cumulative transaction bitmap.
[0091] 8) Continue with step 5.
[0092] 4. Construct the DAG of transactions.
[0093] 1) Check if the transaction set is empty. If it is empty, end this process. If it is not empty, retrieve the read set bitmap and write set bitmap of this transaction from the read set bitmap set and write set bitmap set of the transaction respectively according to the transaction number.
[0094] 2) Check if there is a conflict between the transaction read bitmap and the cumulative write bitmap of this transaction (perform a bitwise AND operation between the transaction read bitmap and the cumulative write bitmap with the transaction number as the key; if the value is not 0, it indicates a conflict). If there is a conflict, proceed to step 5); otherwise, proceed to step 6.
[0095] 3) Check if there is a conflict between the write bitmap and the cumulative read bitmap of this transaction. If there is a conflict, proceed to step 5; otherwise, proceed to step 6.
[0096] 4) Check if there is a conflict between the write bitmap and the cumulative write bitmap of this transaction. If there is a conflict, proceed to step 5). If there is no conflict, proceed to step 6.
[0097] 5) Construct the direct conflict bitmap and cumulative conflict bitmap for the current transaction, as follows:
[0098] A. Initialize the current cumulative conflict bitmap, with the initial values containing only the current transaction.
[0099] B. Starting from the position 1 minus the current transaction number, traverse backwards through the previous transactions, checking if the previous transaction set is empty. If it is empty, end the process; otherwise, take a transaction.
[0100] C. Check if the current transaction is included in the cumulative conflict bitmap (the conflict bitmap constructed by transaction number). If it is included, skip the transaction; otherwise, proceed to step D.
[0101] D. Check if the read set bitmap of the current transaction conflicts with the write set bitmap of this transaction. If there is a conflict, add this transaction to the direct conflict bitmap of the current transaction and add the cumulative conflict bitmap of this transaction to the cumulative conflict bitmap of the current transaction (update the cumulative conflict bitmap of the current transaction to the OR value of the cumulative bitmap of the current transaction and the cumulative conflict bitset of this transaction). If there is no conflict, continue to step E.
[0102] E. Check if the write set bitmap of the current transaction conflicts with the read set bitmap of this transaction. If there is a conflict, add this transaction to the direct conflict bitmap of the current transaction and add the cumulative conflict bitmap of this transaction to the cumulative conflict bitmap of the current transaction (update the cumulative conflict bitmap of the current transaction to the OR value of the cumulative bitmap of the current transaction and the cumulative conflict bitset of this transaction). If there is no conflict, continue to step F.
[0103] F. Check if the write set bitmap of the current transaction conflicts with the write set bitmap of this transaction. If there is a conflict, add this transaction to the direct conflict bitmap of the current transaction and add the cumulative conflict bitmap of this transaction to the cumulative conflict bitmap of the current transaction (update the cumulative conflict bitmap of the current transaction to the OR value of the cumulative conflict bitmap of the current transaction and the cumulative conflict bitmap of this transaction). If there is no conflict, continue to step G.
[0104] G. Update the cumulative conflict bitmap of the current transaction to the global cumulative conflict bitmap dictionary. The dictionary key is the number of the current transaction, and the value is the cumulative conflict bitmap of the current transaction.
[0105] 6) Based on the direct conflict bitmap of the current transaction, construct the DAG dependency relationship of the current transaction, as follows:
[0106] A. Check if the bitmap of directly conflicting transactions is empty. If it is empty, end this process. If it is not empty, retrieve a conflicting transaction (number) from the bitmap.
[0107] B. Add the retrieved transaction number to the adjacency list of this transaction in the DAG, and continue to execute step A.
[0108] As shown above, determining the DAG of a block typically involves first determining the read set bitmap and write set bitmap for the current transaction within the block according to the actual transaction execution order. Then, iteratively, iterates through all transactions to determine the cumulative read and write bitmaps representing transactions that conflict with the current transaction. Finally, based on the current transaction's read set bitmap, write set bitmap, cumulative read bitmap, and cumulative write bitmap, iterates through all transactions using a slower bitmap comparison method to identify transactions that directly conflict with the current transaction. Therefore, this method of determining the DAG requires traversing all transactions for conflict checks when determining the cumulative read and write bitmaps of the current transaction and when searching for transactions that directly conflict with the current transaction, thus reducing the efficiency of DAG determination.
[0109] In particular, when the conflict rate is low, the need to traverse most transactions to find conflicting transactions increases unnecessary workload and reduces the efficiency of determining the DAG.
[0110] In view of this, embodiments of this application provide a method, apparatus, and electronic device for determining a directed acyclic graph (DAG), which can improve the efficiency of DAG determination.
[0111] Figure 3 A schematic flowchart of a method 400 for determining a directed acyclic graph (DAG) according to an embodiment of this application is shown. This method 400 can be executed by any electronic device with data processing capabilities. For example, the electronic device can be implemented as a server. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, and big data and artificial intelligence platforms. The server can be directly or indirectly connected via wired or wireless communication, and this application does not impose any limitations. For ease of description, the prediction method provided in this application will be described below using an apparatus for determining a DAG as an example.
[0112] like Figure 3 As shown, the method 400 may include some or all of the following:
[0113] S410, retrieve the transaction order of transactions in the transaction set.
[0114] S420, Based on the transaction order, determine the read set dictionary, the write set dictionary, the read set keyword position dictionary, and the write set keyword position dictionary for the transaction set;
[0115] The keys of the read set dictionary include: read set keys of transactions in the transaction set; the value of each read set key in the read set dictionary includes: the transaction number dependent on each read set key; the keys of the write set dictionary include: write set keys of transactions in the transaction set; the value of each write set key in the write set dictionary includes: the transaction number dependent on each write set key; the keys of the read set key position dictionary include: a two-dimensional read set key formed by the transaction number and the read set key of the transactions in the transaction set; the value of each two-dimensional read set key in the read set key position dictionary is used to indicate... The transaction number in each read set two-dimensional key is located in the read set dictionary within the transaction numbers whose read set key is the value of the read set key in each read set two-dimensional key. The key of the write set key position dictionary includes: a write set two-dimensional key formed by the transaction numbers in the transaction set and the write set key of the transactions in the transaction set. The value of each write set two-dimensional key in the write set key position dictionary is used to indicate: the transaction number in each write set two-dimensional key is located in the write set dictionary within the transaction numbers whose write set key is the value of the write set key in each write set two-dimensional key.
[0116] S430, based on the read set keyword position dictionary and the write set keyword position dictionary, determine the number of the transaction that directly conflicts with the current transaction in the transaction set.
[0117] S440, Based on the transaction numbers that directly conflict with the current transaction, determine the directed acyclic graph (DAG) of the transaction set.
[0118] In this embodiment, when determining transactions that directly conflict with the current transaction in the transaction set, a read set dictionary, a write set dictionary, a read set keyword position dictionary, and a write set keyword position dictionary for the transaction set are introduced. Through the design of these dictionaries, the application can determine the transaction numbers that directly conflict with the current transaction in the transaction set based on the read set keyword position dictionary and the write set keyword position dictionary. That is, it directly determines transactions that directly conflict with the current transaction from the perspective of read set keywords and write set keywords. This not only eliminates the need to construct read set bitmaps and write set bitmaps for the current transaction but also avoids the slow bitmap comparison method and the method of traversing all transactions to determine transactions that directly conflict with the current transaction, thus improving the efficiency of determining the DAG.
[0119] Taking the read set dictionary and the read set keyword position dictionary as examples, this application designs the keywords of the read set dictionary to include: read set keywords of transactions in the transaction set, and designs the value of each read set keyword in the read set dictionary to include: the transaction number that depends on each read set keyword; equivalently, the values of the keywords that enable the read set keyword in the read set dictionary to be the keyword of the current transaction include: transactions that directly conflict with the current transaction; furthermore, this application designs the keywords of the read set keyword position dictionary to include: a two-dimensional read set keyword formed by the transaction number and the read set keyword of the transaction in the transaction set, and designs each read set keyword position dictionary to include: The value of the two-dimensional key is designed to indicate the position of the transaction number in each read set's two-dimensional key within the read set dictionary, where the read set key is the value of the read set key in each read set's two-dimensional key. In other words, given that the key of the current transaction is determined, the transaction that directly conflicts with the current transaction can be identified from the transaction numbers in the read set dictionary whose key is the value of the current key, based on the position indicated by the value of the read set's two-dimensional key that includes the key of the current transaction. This avoids identifying the transaction that directly conflicts with the current transaction by traversing all transactions, thus improving the efficiency of determining the DAG.
[0120] Taking the write set dictionary and the write set keyword position dictionary as examples, this application designs the keywords of the write set dictionary to include: the write set keywords of transactions in the transaction set, and designs the value of each write set keyword in the write set dictionary to include: the transaction number that depends on each write set keyword; equivalently, the values that enable the write set keyword in the write set dictionary to be the keyword of the current transaction include: transactions that directly conflict with the current transaction; furthermore, this application designs the keywords of the write set keyword position dictionary to include: a two-dimensional write set keyword formed by the transaction number and the write set keyword of the transaction in the transaction set, and designs each write set keyword position dictionary to include: the write set keyword that depends on each write set keyword. The value of the two-dimensional key is designed to indicate the position of the transaction number in each write set two-dimensional key within the write set dictionary of transaction numbers whose write set key is the value of the write set key in each write set two-dimensional key. In other words, given that the key of the current transaction is determined, the transaction that directly conflicts with the current transaction can be identified from the transaction numbers in the write set dictionary whose key is the value of the current key, based on the position indicated by the value of the write set two-dimensional key that includes the key of the current transaction in the write set key position dictionary. This avoids identifying the transaction that directly conflicts with the current transaction by traversing all transactions, thus improving the efficiency of determining the DAG.
[0121] Furthermore, the solution provided in this application does not require constructing a read set bitmap and a write set bitmap for each transaction, nor does it require constructing a cumulative read bitmap and a cumulative write bitmap for each transaction. This reduces the complexity of determining the DAG and further improves the efficiency of determining the DAG.
[0122] It should be noted that the method for determining a Directed Acyclic Graph (DAG) provided in this application aims to construct a DAG data structure for transactions within a block, that is, to represent the dependencies between transactions. In other words, the transaction that directly conflicts with the current transaction in this application can be a transaction that has a direct dependency on the current transaction, and the transaction that conflicts with the current transaction can include transactions that have both direct and indirect dependencies on the current transaction.
[0123] For example, the value of each read set key in the read set dictionary includes: the number of the transaction that depends on each read set key in the order of the transactions.
[0124] For example, each two-dimensional key in the read set key location dictionary may include two keys: the ID of a transaction in the transaction set and the read set key of that transaction. Optionally, if the read set key of a transaction includes multiple read set keys, then the two-dimensional key formed by the ID of the transaction in the transaction set and the read set key of the transaction in the transaction set may be multiple read set keys.
[0125] For example, each two-dimensional key in the write set key location dictionary may include two keys: the ID of a transaction in the transaction set and the write set key of that transaction. Optionally, if the write set key of a transaction includes multiple write set keys, then the two-dimensional key formed by the ID of the transaction in the transaction set and the write set key of the transaction in the transaction set may be multiple write set keys.
[0126] For example, the DAG of a transaction set can be determined by the conflict relationships between the read and write sets of different transactions. Specifically, the DAG can be determined by the common keyword included in the read and write sets of different transactions, the common keyword included in the write and read sets of different transactions, and the common keyword included in the write sets of different transactions. For instance, based on the read set keyword location dictionary, transactions that have a direct conflict relationship with the read set of the current transaction can be identified in the read set dictionary; and based on the write set keyword location dictionary, transactions that have a direct conflict relationship with either the write set or the read set of the current transaction can be identified in the write set dictionary.
[0127] To facilitate understanding of the technical solution of this application, the following is combined with... Figures 4 to 7The dictionary for reading sets, the dictionary for writing sets, the dictionary for reading set keyword positions, and the dictionary for writing set keyword positions introduced in this application are illustrated by example:
[0128] Figure 4 This is an example of a read set dictionary provided in the embodiments of this application.
[0129] like Figure 4 As shown, assuming the current transactions include transactions 1 through 8, the read set key for transaction 1 includes read set key 1, the read set key for transaction 2 includes both read set key 1 and read set key 2, the read set key for transaction 3 includes read set key 1, the read set key for transaction 4 includes both read set key 1 and read set key 2, the read set key for transaction 5 includes both read set key 1 and read set key 2, the read set key for transaction 6 includes both read set key 1 and read set key 2, the read set key for transaction 7 includes read set key 2, and the read set key for transaction 8 includes read set key 2. Assuming the transaction order of transactions 1 through 8 is the execution order of transactions 1 through 8, the read set dictionary can include read set key 1 and read set key 2. The value of read set key 1 can sequentially include the numbers of transactions 1 through 6, and the value of read set key 2 can sequentially include the number of transaction 2 and the numbers of transactions 4 through 8.
[0130] Figure 5 This is an example of a write set dictionary provided in the embodiments of this application.
[0131] like Figure 5 As shown, assuming the current transactions include transactions 1 through 8, the write set key for transaction 1 includes write set key 1, the write set key for transaction 2 includes both write set key 1 and write set key 2, the write set key for transaction 3 includes write set key 1, the write set key for transaction 4 includes both write set key 1 and write set key 2, the write set key for transaction 5 includes both write set key 1 and write set key 2, the write set key for transaction 6 includes both write set key 1 and write set key 2, the write set key for transaction 7 includes write set key 2, and the write set key for transaction 8 includes write set key 2. Assuming the transaction order of transactions 1 through 8 is the execution order of transactions 1 through 8, the write set dictionary can include write set key 1 and write set key 2. The value of write set key 1 can sequentially include the numbers of transactions 1 through 6, and the value of write set key 2 can sequentially include the number of transaction 2 and the numbers of transactions 4 through 8.
[0132] Figure 6 This is an example of a dictionary of read set keyword positions provided in an embodiment of this application.
[0133] like Figure 6 As shown, assume the current transactions include transactions 1 through 8, where the dictionary for the read set of transactions 1 through 8 is... Figure 4The dictionary for the reading set shown includes the following keywords:
[0134] The two-dimensional key of the read set is formed by the number of transaction 1 and the read set key 1 of transaction 1; the value of the two-dimensional key of the read set formed by the number of transaction 1 and the read set key 1 of transaction 1 is 0, which is used to indicate that the number of transaction 1 is the number of the first transaction among the transaction numbers included in the read set dictionary where the read set key is the value of read set key 1.
[0135] The two-dimensional key of the read set is formed by the number of transaction 2 and the read set key 1 of transaction 2; the value of the two-dimensional key of the read set formed by the number of transaction 2 and the read set key 1 of transaction 2 is 1, which is used to indicate that the number of transaction 2 is the number of the second transaction among the transaction numbers included in the read set dictionary where the read set key is the value of read set key 1.
[0136] The two-dimensional key of the read set is formed by the number of transaction 2 and the read set key 2 of transaction 2; the value of the two-dimensional key of the read set formed by the number of transaction 2 and the read set key 2 of transaction 2 is 0, which is used to indicate that the number of transaction 2 is the number of the first transaction among the transaction numbers included in the read set dictionary where the read set key is the value of read set key 2.
[0137] The two-dimensional key of the reading set is formed by the number of transaction 3 and the reading set key 1 of transaction 3; the value of the two-dimensional key of the reading set formed by the number of transaction 3 and the reading set key 3 of transaction 3 is 2, which is used to indicate that the number of transaction 3 is the number of the 3rd transaction among the transaction numbers included in the reading set dictionary where the reading set key is the value of reading set key 1.
[0138] The two-dimensional key of the read set is formed by the number of transaction 4 and the read set key 1 of transaction 4; the value of the two-dimensional key of the read set formed by the number of transaction 4 and the read set key 1 of transaction 4 is 3, which is used to indicate that the number of transaction 4 is the number of the 4th transaction among the transaction numbers included in the read set dictionary where the read set key is the value of read set key 1.
[0139] The two-dimensional key of the read set is formed by the number of transaction 4 and the read set key 2 of transaction 4; the value of the two-dimensional key of the read set formed by the number of transaction 4 and the read set key 2 of transaction 4 is 1, which is used to indicate that the number of transaction 4 is the number of the second transaction among the transaction numbers included in the read set dictionary where the read set key is the value of read set key 2.
[0140] The two-dimensional key of the read set is formed by the number of transaction 5 and the read set key 1 of transaction 5; the value of the two-dimensional key of the read set formed by the number of transaction 5 and the read set key 1 of transaction 5 is 4, which is used to indicate that the number of transaction 5 is the number of the 5th transaction among the transaction numbers included in the read set dictionary where the read set key is the value of read set key 1.
[0141] The two-dimensional key of the read set is formed by the number of transaction 5 and the read set key 2 of transaction 5; the value of the two-dimensional key of the read set formed by the number of transaction 5 and the read set key 2 of transaction 5 is 2, which is used to indicate that the number of transaction 5 is the number of the third transaction among the transaction numbers included in the read set dictionary where the read set key is the value of read set key 2.
[0142] The two-dimensional key of the read set is formed by the number of transaction 6 and the read set key 1 of transaction 6; the value of the two-dimensional key of the read set formed by the number of transaction 6 and the read set key 1 of transaction 6 is 5, which is used to indicate that the number of transaction 6 is the number of the 6th transaction among the transaction numbers included in the read set dictionary where the read set key is the value of read set key 1.
[0143] The two-dimensional key of the read set is formed by the number of transaction 6 and the read set key 2 of transaction 6; the value of the two-dimensional key of the read set formed by the number of transaction 6 and the read set key 2 of transaction 6 is 3, which is used to indicate that the number of transaction 6 is the number of the 4th transaction among the transaction numbers included in the read set dictionary where the read set key is the value of read set key 2.
[0144] The two-dimensional key of the reading set is formed by the number of transaction 7 and the reading set key 2 of transaction 7; the value of the two-dimensional key of the reading set formed by the number of transaction 7 and the reading set key 2 of transaction 7 is 4, which is used to indicate that the number of transaction 7 is the number of the 5th transaction among the transaction numbers included in the reading set dictionary where the reading set key is the value of reading set key 2.
[0145] The two-dimensional key of the reading set is formed by the number of transaction 8 and the reading set key 2 of transaction 8; the value of the two-dimensional key of the reading set formed by the number of transaction 8 and the reading set key 2 of transaction 8 is 5, which is used to indicate that the number of transaction 8 is the number of the 6th transaction among the transaction numbers included in the reading set dictionary where the reading set key is the value of reading set key 2.
[0146] Figure 7 This is an example of the write set keyword location dictionary provided in the embodiments of this application.
[0147] like Figure 7 As shown, assume the current transactions include transactions 1 through 8, where the write set dictionary for transactions 1 through 8 is... Figure 5 The dictionary of write sets shown includes the following keywords:
[0148] The write set two-dimensional key is formed by the number of transaction 1 and the write set key 1 of transaction 1; the value of the write set two-dimensional key formed by the number of transaction 1 and the write set key 1 of transaction 1 is 0, which is used to indicate that the number of transaction 1 is the number of the first transaction among the transaction numbers included in the write set dictionary where the write set key is the value of write set key 1.
[0149] The write set two-dimensional key is formed by the number of transaction 2 and the write set key 1 of transaction 2; the value of the write set two-dimensional key formed by the number of transaction 2 and the write set key 1 of transaction 2 is 1, which is used to indicate that the number of transaction 2 is the number of the second transaction among the transaction numbers included in the write set dictionary where the write set key is the value of write set key 1.
[0150] The write set two-dimensional key is formed by the number of transaction 2 and the write set key 2 of transaction 2; the value of the write set two-dimensional key formed by the number of transaction 2 and the write set key 2 of transaction 2 is 0, which is used to indicate that the number of transaction 2 is the number of the first transaction among the transaction numbers included in the write set dictionary where the write set key is the value of write set key 2.
[0151] The write set two-dimensional key is formed by the number of transaction 3 and the write set key 1 of transaction 3; the value of the write set two-dimensional key formed by the number of transaction 3 and the write set key 3 of transaction 3 is 2, which is used to indicate that the number of transaction 3 is the number of the 3rd transaction among the transaction numbers included in the write set dictionary where the write set key is the value of write set key 1.
[0152] The write set two-dimensional key is formed by the number of transaction 4 and the write set key 1 of transaction 4; the value of the write set two-dimensional key formed by the number of transaction 4 and the write set key 1 of transaction 4 is 3, which is used to indicate that the number of transaction 4 is the number of the 4th transaction among the transaction numbers included in the write set dictionary where the write set key is the value of write set key 1.
[0153] The write set two-dimensional key is formed by the number of transaction 4 and the write set key 2 of transaction 4; the value of the write set two-dimensional key formed by the number of transaction 4 and the write set key 2 of transaction 4 is 1, which is used to indicate that the number of transaction 4 is the number of the second transaction among the transaction numbers included in the write set dictionary where the write set key is the value of write set key 2.
[0154] The write set two-dimensional key is formed by the number of transaction 5 and the write set key 1 of transaction 5; the value of the write set two-dimensional key formed by the number of transaction 5 and the write set key 1 of transaction 5 is 4, which is used to indicate that the number of transaction 5 is the number of the 5th transaction among the transaction numbers included in the write set dictionary where the write set key is the value of write set key 1.
[0155] The write set two-dimensional key is formed by the number of transaction 5 and the write set key 2 of transaction 5; the value of the write set two-dimensional key formed by the number of transaction 5 and the write set key 2 of transaction 5 is 2, which is used to indicate that the number of transaction 5 is the number of the third transaction among the transaction numbers included in the write set dictionary where the write set key is the value of write set key 2.
[0156] The write set two-dimensional key is formed by the number of transaction 6 and the write set key 1 of transaction 6; the value of the write set two-dimensional key formed by the number of transaction 6 and the write set key 1 of transaction 6 is 5, which is used to indicate that the number of transaction 6 is the number of the 6th transaction among the transaction numbers included in the write set dictionary where the write set key is the value of write set key 1.
[0157] The write set two-dimensional key is formed by the number of transaction 6 and the write set key 2 of transaction 6; the value of the write set two-dimensional key formed by the number of transaction 6 and the write set key 2 of transaction 6 is 3, which is used to indicate that the number of transaction 6 is the number of the 4th transaction among the transaction numbers included in the write set dictionary where the write set key is the value of write set key 2.
[0158] The write set two-dimensional key is formed by the number of transaction 7 and the write set key 2 of transaction 7; the value of the write set two-dimensional key formed by the number of transaction 7 and the write set key 2 of transaction 7 is 4, which is used to indicate that the number of transaction 7 is the number of the 5th transaction among the transaction numbers included in the write set dictionary where the write set key is the value of write set key 2.
[0159] The write set two-dimensional key formed by the number of transaction 8 and the write set key 2 of transaction 8; the value of the write set two-dimensional key formed by the number of transaction 8 and the write set key 2 of transaction 8 is 5, which is used to indicate that the number of transaction 8 is the number of the 6th transaction among the transaction numbers included in the write set dictionary where the write set key is the value of write set key 2.
[0160] It should be understood that Figures 4 to 7 This is merely an example of what is being done and should not be construed as limiting the scope of this application.
[0161] For example, in other alternative embodiments, there may be other numbers of transactions, or other numbers of read set keywords or write set keywords. The order of transactions 1 to 8 may also be other transaction orders, which are not limited in this application.
[0162] In some embodiments, S420 may include:
[0163] Determine if the read set for the current transaction is empty;
[0164] If the read set of the current transaction is not empty, then obtain the first element from the read set of the current transaction;
[0165] The length of the value of the key that is the first element in the read set dictionary is determined as the value of the two-dimensional key of the read set formed by the number of the current transaction and the key of the first element in the read set key position dictionary;
[0166] The length of the value of the key of the first element in the write set dictionary is determined as the value of the two-dimensional write set key formed by the current transaction number and the key of the first element in the write set key position dictionary.
[0167] For example, the keyword position dictionary for the read set and the keyword position dictionary for the write set can be updated by iterating through the elements in the read set of each transaction in the transaction set. For instance, assuming the transaction set includes transactions 1 to 8, the keyword position dictionary for the read set and the keyword position dictionary for the write set can be updated first based on the elements in the read set of transaction 1; then based on the elements in the read set of transaction 2, the keyword position dictionary for the read set and the keyword position dictionary for the write set can be updated; and so on. Finally, based on the elements in the read set of transaction 8, the keyword position dictionary for the read set and the keyword position dictionary for the write set can be updated to obtain the final keyword position dictionary for the read set and the keyword position dictionary for the write set.
[0168] For example, the keyword position dictionary for the read set and the keyword position dictionary for the write set can be updated by traversing the elements included in the read set of the current transaction. For instance, if the read set of the current transaction includes two elements, the keyword position dictionary for the read set and the keyword position dictionary for the write set can be updated first using one of the two elements; then, the keyword position dictionary for the read set and the keyword position dictionary for the write set can be updated using the other element. The method of updating the keyword position dictionary for the read set and the keyword position dictionary for the write set based on one element is the same as the method described above for updating the keyword position dictionary for the read set and the keyword position dictionary based on the first element; to avoid repetition, it will not be repeated here.
[0169] Of course, if the read set dictionary does not contain the keyword of the first element, then the read set keyword position dictionary does not need to be updated based on the keyword of the first element. In other words, if the read set dictionary does not contain the keyword of the first element, then it is not necessary to record the keyword of the first element in the read set keyword position dictionary. Similarly, if the write set dictionary does not contain the keyword of the first element, then it does not need to be updated based on the keyword of the first element. In other words, if the write set dictionary does not contain the keyword of the first element, then it is not necessary to record the keyword of the first element in the write set keyword position dictionary.
[0170] In some embodiments, the method 400 may further include:
[0171] Add the current transaction number to the value of the first element in the dictionary of the read set.
[0172] In some embodiments, S420 may include:
[0173] Determine if the write set of the current transaction is empty;
[0174] If the write set of the current transaction is not empty, then retrieve the second element from the write set of the current transaction;
[0175] Determine whether the keyword for the second element exists in the dictionary at the keyword position of the read set;
[0176] If the keyword of the second element does not exist in the keyword position dictionary of the read set, then the length of the value of the keyword of the second element in the read set dictionary is determined as the value of the two-dimensional keyword of the read set formed by the number of the current transaction and the keyword of the second element in the keyword position dictionary of the read set.
[0177] If the keyword of the second element exists in the keyword position dictionary of the read set, then the length of the value of the keyword of the second element in the write set dictionary is determined as the value of the two-dimensional keyword of the write set formed by the current transaction number and the keyword of the second element in the keyword position dictionary of the write set.
[0178] For example, the key position dictionary for the read set and the key position dictionary for the write set can be updated by iterating through the elements in the write set of the transactions in the transaction set. For instance, assuming the transaction set includes transactions 1 to 8, the key position dictionary for the read set and the key position dictionary for the write set can be updated first based on the elements in the write set of transaction 1; then based on the elements in the write set of transaction 2, the key position dictionary for the read set and the key position dictionary for the write set can be updated; and so on. Finally, based on the elements in the write set of transaction 8, the key position dictionary for the read set and the key position dictionary for the write set can be updated to obtain the final key position dictionary for the read set and the key position dictionary for the write set.
[0179] For example, the keyword position dictionaries of the read set and the write set can be updated by traversing the elements included in the write set of the current transaction. For instance, if the write set of the current transaction includes two elements, the keyword position dictionaries of the read set and the write set can be updated first using one of these two elements; then, they can be updated again using the other element. The method of updating the keyword position dictionaries of the read set and the write set based on a single element is similar to the method described above, which updates them based on a second element. To avoid repetition, this will not be repeated here.
[0180] In some embodiments, S430 may include:
[0181] Initialize the direct conflict bitmap of the current transaction to empty;
[0182] The direct conflict bitmap of the current transaction includes the first bit corresponding to each transaction in the transaction set. The first bit corresponding to each transaction is used to indicate whether each transaction is a transaction that directly conflicts with the current transaction.
[0183] The initialization of the cumulative conflict bitmap for the current transaction includes only the current transaction;
[0184] The cumulative conflict bitmap includes a second bit corresponding to each transaction in the transaction set. The second bit corresponding to each transaction is used to indicate the transaction that directly conflicts with the transaction in the transaction set that is located before the current transaction in the transaction order.
[0185] Based on whether the cumulative conflict bitmap of the current transaction includes: the transaction number that conflicts with the current transaction as determined in the read set dictionary based on the read set keyword location dictionary, and the transaction number that conflicts with the current transaction as determined in the write set dictionary based on the write set keyword location dictionary, update the direct conflict bitmap and the cumulative conflict bitmap of the current transaction.
[0186] Based on the updated direct conflict bitmap of the current transaction, determine the number of the transaction that directly conflicts with the current transaction.
[0187] For example, the transaction number that conflicts with the current transaction, determined in the read set keyword location dictionary based on the read set keyword location dictionary, can be: the transaction number that conflicts with the write set of the current transaction, determined in the read set keyword location dictionary based on the read set keyword location dictionary. In other words, whether the cumulative conflict bitmap of the current transaction includes: the transaction number that conflicts with the write set of the current transaction, determined in the read set keyword location dictionary based on the read set keyword location dictionary, allows the updated direct conflict bitmap of the current transaction to consider whether the write set of the current transaction directly conflicts with the read sets of other transactions.
[0188] For example, the transaction number that conflicts with the current transaction, determined in the write set dictionary based on the write set keyword location dictionary, can be: the transaction number that conflicts with the read set or write set of the current transaction, determined in the write set dictionary based on the write set keyword location dictionary. In other words, whether the cumulative conflict bitmap of the current transaction includes: the transaction number that conflicts with the read set or write set of the current transaction, determined in the write set dictionary based on the write set keyword location dictionary, allows the updated direct conflict bitmap of the current transaction to consider whether the write set or read set of the current transaction directly conflicts with the write set of other transactions.
[0189] For example, if the cumulative conflict bitmap of the current transaction includes "the transaction number that conflicts with the current transaction as determined in the read set dictionary based on the read set keyword location dictionary, and / or the transaction number that conflicts with the current transaction as determined in the write set dictionary based on the write set keyword location dictionary," it indicates that "the transaction number that conflicts with the current transaction as determined in the read set dictionary based on the read set keyword location dictionary, and / or the transaction number that conflicts with the current transaction as determined in the write set dictionary based on the write set keyword location dictionary" are transactions that directly conflict with transactions preceding the current transaction, and therefore, they are not considered transactions that directly conflict with the current transaction. Similarly, if the cumulative conflict bitmap of the current transaction does not include "the transaction number that conflicts with the current transaction as determined in the read set dictionary based on the read set keyword location dictionary," then... The text describes the direct conflict bitmap and cumulative conflict bitmap of the current transaction, specifying the transaction numbers that conflict with the current transaction and / or the transaction numbers that conflict with the current transaction as determined by the write set keyword location dictionary in the write set dictionary. It further explains that these transaction numbers directly conflict with the current transaction.
[0190] For example, when updating the direct conflict bitmap and cumulative conflict bitmap of the current transaction based on "the transaction number that conflicts with the current transaction as determined in the read set dictionary based on the read set keyword position dictionary, and / or the transaction number that conflicts with the current transaction as determined in the write set dictionary based on the write set keyword position dictionary", the values of the corresponding bits in the direct conflict bitmap and cumulative conflict bitmap of the current transaction can be set to values used to indicate conflicts, such as 1.
[0191] For example, suppose the transaction set includes transactions 1 to 8, and the transaction order of the transaction set is from transaction 1 to transaction 8. Taking transaction 4 as an example, if the direct conflict bitmap of transaction 4 is initialized to "00000000", and if the number of the transaction that conflicts with the current transaction is determined in the read set key position dictionary and / or the number of the transaction that conflicts with the current transaction is determined in the write set key position dictionary, then the direct conflict bitmap of transaction 3 is updated from "00000000" to "00100000" based on the number of transaction 3.
[0192] In some embodiments, S430 may include:
[0193] Determine if the read set for the current transaction is empty;
[0194] If the read set of the current transaction is not empty, then obtain the third element from the read set of the current transaction;
[0195] Based on whether the cumulative conflict bitmap includes: the transaction number that conflicts with the current transaction as determined in the write set dictionary based on the write set key position dictionary and the key of the third element, update the direct conflict bitmap and the cumulative conflict bitmap of the current transaction.
[0196] For example, the transaction number that conflicts with the current transaction, determined in the write set dictionary based on the write set keyword location dictionary and the keyword of the third element, may include: the transaction number indicated by the value of the write set keyword in the write set dictionary that is the keyword of the third element, and the transaction preceding the transaction indicated by the value of the two-dimensional keyword formed by the number of the current transaction and the keyword of the third element in the write set keyword location dictionary.
[0197] Of course, in other alternative embodiments, the transaction number that conflicts with the current transaction, determined in the write set dictionary based on the write set keyword location dictionary and the keyword of the third element, may also include: transactions in the write set dictionary whose write set keyword is the keyword of the third element, and transactions preceding the transaction indicated by the value of the two-dimensional keyword formed by the current transaction number and the keyword of the third element in the write set keyword location dictionary. This application does not specifically limit this.
[0198] For example, the direct conflict bitmap and the cumulative conflict bitmap of the current transaction can be updated by traversing the elements included in the read set of the current transaction. For instance, if the read set of the current transaction includes two elements, the direct conflict bitmap and the cumulative conflict bitmap of the current transaction can be updated first using one of the two elements; then, the direct conflict bitmap and the cumulative conflict bitmap of the current transaction can be updated using the other element. The method of updating the direct conflict bitmap and the cumulative conflict bitmap of the current transaction based on one element, as described above for updating the direct conflict bitmap and the cumulative conflict bitmap of the current transaction based on a third element, will not be repeated here to avoid repetition.
[0199] In some embodiments, S430 may include:
[0200] Determine whether the cumulative conflict bitmap includes: the transaction number indicated by the value of the key of the write set key in the write set dictionary that is the key of the third element, and the transaction preceding the transaction indicated by the value of the two-dimensional key formed by the number of the current transaction and the key of the third element in the write set key position dictionary;
[0201] If the cumulative conflict bitmap of the current transaction does not include the previous transaction, then the previous transaction is added to the direct conflict bitmap of the current transaction, and the transactions included in the cumulative conflict bitmap of the previous transaction are added to the cumulative conflict bitmap of the current transaction.
[0202] In this embodiment, based on the write set dictionary and write set keyword position dictionary introduced in this application, when determining other transactions that have a direct conflict with the read set of the current transaction, only one transaction (i.e. the previous transaction) needs to be considered. Compared with traversing all transactions, this reduces the complexity of the solution and improves processing efficiency.
[0203] In some embodiments, S430 may include:
[0204] Determine if the write set of the current transaction is empty;
[0205] If the write set of the current transaction is not empty, then obtain the fourth element from the write set of the current transaction;
[0206] Determine whether the cumulative conflict bitmap of the current transaction includes: the transaction number that conflicts with the current transaction as determined in the read set dictionary based on the read set keyword position dictionary and the keyword of the fourth element, and the transaction number that conflicts with the current transaction as determined in the write set dictionary based on the write set keyword position dictionary and the keyword of the fourth element; update the direct conflict bitmap and the cumulative conflict bitmap of the current transaction.
[0207] For example, the transaction number that conflicts with the current transaction, determined in the read set dictionary based on the read set keyword location dictionary and the keyword of the fourth element, may include: the transaction number in the read set dictionary indicated by the value of the read set keyword being the keyword of the fourth element, and the transaction preceding the transaction indicated by the value of the two-dimensional keyword formed by the number of the current transaction and the keyword of the fourth element in the read set keyword location dictionary.
[0208] For example, updating the direct conflict bitmap and the cumulative conflict bitmap of the current transaction based on the write set key location dictionary and the key of the fourth element, which are the transaction numbers that conflict with the current transaction as determined in the write set dictionary, may include: the transaction number in the write set dictionary where the write set key is the key of the fourth element, and the transaction preceding the transaction indicated by the value of the two-dimensional key formed by the number of the current transaction and the key of the fourth element in the write set key location dictionary.
[0209] Of course, in other alternative embodiments, updating the direct conflict bitmap and the cumulative conflict bitmap of the current transaction based on the transaction numbers that conflict with the current transaction, determined in the write set key location dictionary and the key of the fourth element, may also include: transactions preceding the transaction numbers in the write set dictionary whose write set key is the key of the fourth element, and transactions preceding the transaction indicated by the value of the two-dimensional key formed by the current transaction number and the key of the fourth element in the write set key location dictionary. This application does not specifically limit this.
[0210] For example, the direct conflict bitmap and the cumulative conflict bitmap of the current transaction can be updated by traversing the elements included in the read set of the current transaction. For instance, if the read set of the current transaction includes two elements, the direct conflict bitmap and the cumulative conflict bitmap of the current transaction can be updated first using one of the two elements; then, the direct conflict bitmap and the cumulative conflict bitmap of the current transaction can be updated using the other element. The method of updating the direct conflict bitmap and the cumulative conflict bitmap of the current transaction based on one element, as described above for updating the direct conflict bitmap and the cumulative conflict bitmap of the current transaction based on a third element, will not be repeated here to avoid repetition.
[0211] In some embodiments, S430 may include:
[0212] Determine whether the cumulative conflict bitmap of the current transaction includes: the transaction number indicated by the value of the key of the fourth element in the read set dictionary, and the transaction preceding the transaction indicated by the value of the two-dimensional key formed by the number of the current transaction and the key of the fourth element in the read set key position dictionary;
[0213] If the cumulative conflict bitmap of the current transaction does not include the first transaction preceding the transaction whose number is indicated by the value of the key of the fourth element in the read set dictionary, or the transaction indicated by the value of the two-dimensional key formed by the number of the current transaction and the key of the fourth element in the read set key position dictionary, then the first transaction is added to the direct conflict bitmap of the current transaction, and the transactions included in the cumulative conflict bitmap of the first transaction are added to the cumulative conflict bitmap of the current transaction.
[0214] In this embodiment, based on the read set dictionary and read set keyword position dictionary introduced in this application, when determining other transactions that have a direct conflict relationship with the write set of the current transaction, it is only necessary to traverse the transaction numbers indicated by the value of the fourth element keyword in the read set dictionary and the transactions preceding the transaction indicated by the value of the two-dimensional keyword formed by the current transaction number and the fourth element keyword in the read set keyword position dictionary. Compared with traversing all transactions, this can reduce the complexity of the solution and improve processing efficiency.
[0215] In some embodiments, S430 may include:
[0216] Determine whether the cumulative conflict bitmap of the current transaction includes: the transaction number indicated by the value of the key of the write set key in the write set dictionary that is the fourth element, and the transaction preceding the transaction indicated by the value of the two-dimensional key formed by the number of the current transaction and the key of the fourth element in the write set key position dictionary;
[0217] If the cumulative conflict bitmap of the current transaction does not include the previous transaction, then the previous transaction is added to the direct conflict bitmap of the current transaction, and the transactions included in the cumulative conflict bitmap of the previous transaction are added to the cumulative conflict bitmap of the current transaction.
[0218] In this embodiment, based on the write set dictionary and write set keyword position dictionary introduced in this application, when determining other transactions that have a direct conflict relationship with the write set of the current transaction, only one transaction (i.e. the previous transaction) needs to be considered. Compared with the method of traversing all transactions, this can reduce the complexity of the solution and improve the processing efficiency.
[0219] The following is based on Figures 4 to 7 Taking the various dictionaries shown as examples, combined with Figures 8 to 11The scheme for determining the direct conflict bitmap and cumulative conflict bitmap of the current transaction in this application is illustrated by way of example.
[0220] Figure 8 These are the direct conflict bitmap and cumulative conflict bitmap of transaction 1 provided in the embodiments of this application.
[0221] like Figure 8 As shown, when the current transaction is transaction 1, the direct conflict bitmap and cumulative conflict bitmap for transaction 1 can be determined as follows:
[0222] First, determine if the read set of transaction 1 is empty. Since the read set of transaction 1 is not empty, obtain the read set key 1 from the read set of transaction 1. Then, determine if the cumulative conflict bitmap of transaction 1 includes: the transaction number (i.e., transaction 1 to transaction 6) indicated by the value of the write set key (i.e., 0) formed by the number of transaction 1 and the read set key 1 in the write set dictionary, and the transaction preceding transaction 1. Since transaction 1 is the first transaction, the transaction preceding transaction 1 cannot be found. At this time, it can be determined that there is no transaction that directly conflicts with the read set of transaction 1.
[0223] Next, determine whether the write set of transaction 1 is empty; since the write set of transaction 1 is not empty, retrieve the write set key 1 from the write set of transaction 1; then, determine whether the cumulative conflict bitmap of transaction 1 includes: transactions preceding the transaction numbers (i.e., transactions 1 to 6) indicated by the value of the write set key 1 in the read set dictionary, and transactions preceding the transaction indicated by the value (i.e., 0) of the two-dimensional key formed by the number of transaction 1 and the write set key 1 in the read set key position dictionary; since transaction 1 is the first transaction (i.e., transactions 1 to 6) indicated by the value of the write set key 1 in the read set dictionary, no transactions preceding transaction 1 can be found. At this point, it can be determined that there is no transaction whose read set directly conflicts with the write set of transaction 1.
[0224] Furthermore, determine whether the cumulative conflict bitmap of transaction 1 includes: the transaction number indicated by the value of write set key 1 in the write set dictionary (i.e., transaction 1 to transaction 6), and the transaction (i.e., transaction 1) indicated by the value of the two-dimensional key formed by the number of transaction 1 and write set key 1 (i.e., 0) in the write set key position dictionary; since transaction 1 is the first transaction (i.e., transaction 1 to transaction 6) indicated by the value of write set key 1 in the read set dictionary, the transaction preceding transaction 1 cannot be found. At this time, it can be determined that there is no transaction whose write set directly conflicts with the write set of transaction 1.
[0225] Based on this, the direct conflict bitmap of transaction 1 can be determined to be 00000000; further, transaction 1 is added to the cumulative conflict bitmap of transaction 1, that is, the cumulative conflict bitmap of transaction 1 is 10000000.
[0226] Figure 9 These are the direct conflict bitmap and cumulative conflict bitmap of transaction 2 provided in the embodiments of this application.
[0227] like Figure 9 As shown, when the current transaction is transaction 2, the direct conflict bitmap and cumulative conflict bitmap of transaction 1 can be determined as follows:
[0228] First, determine if the read set of transaction 2 is empty. Since the read set of transaction 2 is not empty, obtain the read set key 1 from the read set of transaction 2. Then, determine if the cumulative conflict bitmap of transaction 2 includes: the transaction number (i.e., transaction 1 to transaction 6) indicated by the value of the write set key (i.e., read set key 1) in the write set dictionary, and the transaction (i.e., transaction 2) indicated by the value of the two-dimensional key formed by the number of transaction 2 and read set key 1 (i.e., 1) in the write set key position dictionary. Since the cumulative conflict bitmap of transaction 2 is initialized to include only transaction 2, i.e., not transaction 1, it can be determined that transaction 1 is a transaction that directly conflicts with the read set key 1 of transaction 2. That is, add transaction 1 to the direct conflict bitmap and cumulative conflict bitmap of transaction 2.
[0229] Further, obtain the read set key 2 from the read set of transaction 2; then, determine whether the cumulative conflict bitmap of transaction 2 includes: the transaction number indicated by the value of the write set key as read set key 2 in the write set dictionary (i.e., transaction 2, transaction 4 to transaction 8), and the transaction (i.e., transaction 2) indicated by the value of the two-dimensional key formed by the number of transaction 2 and read set key 2 (i.e., 0) in the write set key position dictionary; since transaction 2 is the first transaction among the transactions indicated by the value of the write set key as read set key 2 in the write set dictionary (i.e., transaction 2, transaction 4 to transaction 8), the transaction preceding transaction 2 cannot be found. At this time, it can be determined that there is no transaction in which the write set directly conflicts with the read set key 2 of transaction 2.
[0230] Next, determine whether the write set of transaction 2 is empty; since the write set of transaction 2 is not empty, obtain the write set key 1 from the write set of transaction 2; then, determine whether the cumulative conflict bitmap of transaction 2 includes: the transaction number (i.e., transaction 1 to transaction 6) indicated by the value of the write set key 1 in the read set dictionary, and the transaction (i.e., transaction 2) indicated by the value (i.e., 1) of the two-dimensional key formed by the number of transaction 2 and the write set key 1 in the read set key position dictionary; since transaction 1 has been added to the direct conflict bitmap and cumulative conflict bitmap of transaction 2 based on the read set key 1 of transaction 2, it can be determined that there is no transaction whose read set directly conflicts with the write set key 1 of transaction 2.
[0231] Further, the write set key 2 is obtained from the read set of transaction 2; then, it is determined whether the cumulative conflict bitmap of transaction 2 includes: the transaction number indicated by the value of write set key 2 in the write set dictionary (i.e., transaction 2, transaction 4 to transaction 8), and the transaction (i.e., transaction 2) indicated by the value of the two-dimensional key formed by the number of transaction 2 and write set key 2 (i.e., 0) in the write set key position dictionary; since transaction 2 is the first transaction in the write set dictionary (i.e., transaction 2, transaction 4 to transaction 8), the transaction preceding transaction 2 cannot be found. At this time, it can be determined that there is no transaction in the read set that directly conflicts with the write set key 2 of transaction 2.
[0232] Then, retrieve write set key 1 from the write set of transaction 2, and determine whether the cumulative conflict bitmap of transaction 2 includes: the transaction number (i.e., transaction 1 to transaction 6) indicated by the value of write set key 1 in the write set dictionary, and the transaction (i.e., transaction 2) indicated by the value (i.e., 1) of the two-dimensional key formed by the number of transaction 2 and write set key 1 in the write set key position dictionary; since transaction 1 has been added to the cumulative conflict bitmap of transaction 2, it can be determined that there is no transaction whose write set directly conflicts with the write set key 1 of transaction 2.
[0233] Further, obtain write set key 2 from the write set of transaction 2; then, determine whether the cumulative conflict bitmap of transaction 2 includes: the transaction number indicated by the value of write set key 2 in the write set dictionary (i.e., transaction 2, transaction 4 to transaction 8), and the transaction (i.e., transaction 2) indicated by the value of the two-dimensional key formed by the number of transaction 2 and write set key 2 (i.e., 0) in the write set key position dictionary; since transaction 2 is the first transaction in the write set dictionary (i.e., transaction 2, transaction 4 to transaction 8), the transaction preceding transaction 2 cannot be found. At this time, it can be determined that there is no transaction whose write set directly conflicts with the write set key 2 of transaction 2.
[0234] Based on this, the direct conflict bitmap of transaction 2 can be determined to be 10000000; further, transaction 2 is added to the cumulative conflict bitmap of transaction 2, that is, the cumulative conflict bitmap of transaction 2 is 11000000.
[0235] Figure 10 These are the direct conflict bitmap and cumulative conflict bitmap of transaction 3 provided in the embodiments of this application.
[0236] like Figure 10 As shown, when the current transaction is transaction 3, the direct conflict bitmap and cumulative conflict bitmap of transaction 1 can be determined as follows:
[0237] First, determine if the read set of transaction 3 is empty. Since the read set of transaction 3 is not empty, obtain the read set key 1 from the read set of transaction 3. Then, determine if the cumulative conflict bitmap of transaction 3 includes: the transaction number (i.e., transaction 1 to transaction 6) indicated by the value of the write set key 1 in the write set dictionary, and the transaction (i.e., transaction 3) indicated by the value of the two-dimensional key formed by the number of transaction 3 and the read set key 1 (i.e., 2) in the write set key position dictionary. Since the cumulative conflict bitmap of transaction 3 only includes transaction 3, it can be determined that transaction 2 is a transaction that directly conflicts with the read set key 1 of transaction 3. That is, add transaction 2 to the direct conflict bitmap of transaction 3, and add transaction 2 and the transaction that directly conflicts with transaction 2 (i.e., transaction 1) to the cumulative conflict bitmap.
[0238] Next, determine whether the write set of transaction 3 is empty; since the write set of transaction 3 is not empty, obtain the write set key 1 from the write set of transaction 3; then, determine whether the cumulative conflict bitmap of transaction 3 includes: the transaction numbers (i.e., transactions 1 to 6) indicated by the value of the write set key 1 in the read set dictionary, and the transactions (i.e., transactions 2 and 1) preceding the transaction (i.e., transaction 3) indicated by the value of the two-dimensional key formed by the number of transaction 3 and the write set key 1 in the read set key position dictionary; since transaction 2 has been added to the direct conflict bitmap and cumulative conflict bitmap of transaction 3 based on the read set key 1 of transaction 3, it can be determined that there is no transaction whose read set directly conflicts with the write set key 1 of transaction 3.
[0239] Furthermore, write set key 1 is obtained from the write set of transaction 3; then, it is determined whether the cumulative conflict bitmap of transaction 3 includes: the transaction numbers (i.e., transactions 1 to 6) indicated by the value of write set key 1 in the write set dictionary, and the transactions (i.e., transactions 3) preceding the transaction (i.e., transactions 2 and 1) indicated by the value of the two-dimensional key formed by the number of transaction 3 and write set key 1 in the write set key position dictionary; since transaction 2 has been added to the direct conflict bitmap and cumulative conflict bitmap of transaction 3 based on read set key 1 of transaction 3, it can be determined that there are no transactions in which write set directly conflicts with write set key 1 of transaction 3.
[0240] Based on this, the direct conflict bitmap of transaction 3 can be determined to be 01000000; further, transaction 3 is added to the cumulative conflict bitmap of transaction 3, that is, the cumulative conflict bitmap of transaction 3 is 11100000.
[0241] Figure 11 These are the direct conflict bitmap and cumulative conflict bitmap of transaction 4 provided in the embodiments of this application.
[0242] like Figure 11 As shown, when the current transaction is transaction 4, the direct conflict bitmap and cumulative conflict bitmap of transaction 1 can be determined as follows:
[0243] First, determine if the read set of transaction 4 is empty. Since the read set of transaction 4 is not empty, obtain the read set key 1 from the read set of transaction 4. Then, determine if the cumulative conflict bitmap of transaction 4 includes: the transaction number indicated by the value of the write set key 1 in the write set dictionary (i.e., transaction 1 to transaction 6), and the transaction (i.e., transaction 4) indicated by the value of the two-dimensional key formed by the number of transaction 4 and the read set key 1 (i.e., 3) in the write set key position dictionary (i.e., transaction 4) preceding the transaction (i.e., transaction 3). Since the cumulative conflict bitmap of transaction 4 is initialized to include only transaction 4, i.e., not transaction 3, it can be determined that transaction 3 is a transaction that directly conflicts with the read set key 1 of transaction 4. That is, add transaction 3 to the direct conflict bitmap of transaction 4, and add transaction 3, the transaction that directly conflicts with transaction 3 (i.e., transaction 2), and the transaction that directly conflicts with transaction 2 (i.e., transaction 1) to the cumulative conflict bitmap.
[0244] Further, the read set key 2 is obtained from the read set of transaction 4; then, it is determined whether the cumulative conflict bitmap of transaction 4 includes: the transaction number (i.e., transaction 2, transaction 4 to transaction 8) indicated by the value of the write set key 2 in the write set dictionary, and the transaction (i.e., transaction 4) indicated by the value of the two-dimensional key formed by the number of transaction 4 and the read set key 2 (i.e., 1) in the write set key position dictionary; since the cumulative conflict bitmap of transaction 4 includes transaction 2, it can be determined that there is no transaction in which the write set directly conflicts with the read set key 2 of transaction 4.
[0245] Next, determine whether the write set of transaction 4 is empty; since the write set of transaction 4 is not empty, obtain the write set key 1 from the write set of transaction 4; then, determine whether the cumulative conflict bitmap of transaction 4 includes: the transaction number (i.e., transaction 1 to transaction 6) indicated by the value of the write set key 1 in the read set dictionary, and the transaction (i.e., transaction 4) preceding the transaction (i.e., transaction 3) indicated by the value of the two-dimensional key formed by the number of transaction 4 and the write set key 1 in the read set key position dictionary; since transaction 3 has been added to the direct conflict bitmap and cumulative conflict bitmap of transaction 4 based on the read set key 1 of transaction 4, it can be determined that there is no transaction whose read set directly conflicts with the write set key 1 of transaction 4.
[0246] Further, the write set key 2 is obtained from the read set of transaction 4; then, it is determined whether the cumulative conflict bitmap of transaction 4 includes: the transaction number (i.e., transaction 4, transaction 4 to transaction 8) indicated by the value of write set key 2 in the write set dictionary, and the transaction (i.e., transaction 4) indicated by the value (i.e., 1) of the two-dimensional key formed by the number of transaction 4 and write set key 2 in the write set key position dictionary; since the cumulative conflict bitmap of transaction 4 includes transaction 2, it can be determined that there is no transaction in which the read set directly conflicts with the write set key 2 of transaction 4.
[0247] Then, retrieve write set key 1 from the write set of transaction 4, and determine whether the cumulative conflict bitmap of transaction 4 includes: the transaction number (i.e., transaction 1 to transaction 6) indicated by the value of write set key 1 in the write set dictionary, and the transaction (i.e., transaction 4) preceding the transaction (i.e., transaction 3) indicated by the value of the two-dimensional key formed by the number of transaction 4 and write set key 1 (i.e., 3) in the write set key position dictionary; since transaction 3 has been added to the cumulative conflict bitmap of transaction 4, it can be determined at this time that there is no transaction whose write set directly conflicts with the write set key 1 of transaction 4.
[0248] Furthermore, write set key 2 is obtained from the write set of transaction 4; then, it is determined whether the cumulative conflict bitmap of transaction 4 includes: the transaction number (i.e., transaction 2, transaction 4 to transaction 8) indicated by the value of write set key 2 in the write set dictionary, and the transaction (i.e., transaction 4) preceding the transaction (i.e., transaction 2) indicated by the value of the two-dimensional key formed by the number of transaction 4 and write set key 2 in the write set key position dictionary (i.e., 2); since the cumulative conflict bitmap of transaction 4 includes transaction 2, it can be determined that there is no transaction whose write set directly conflicts with the write set key 2 of transaction 4.
[0249] Based on this, the direct conflict bitmap of transaction 4 can be determined to be 00100000; further, transaction 4 is added to the cumulative conflict bitmap of transaction 4, that is, the cumulative conflict bitmap of transaction 4 is 11110000.
[0250] It should be understood that the determination of the direct conflict bitmap and cumulative conflict bitmap of transactions 5 and 6 is similar to that of transaction 2 (or transaction 4), and the determination of the direct conflict bitmap and cumulative conflict bitmap of transactions 7 and 8 is similar to that of transaction 3. To avoid repetition, it will not be repeated here.
[0251] In some embodiments, S440 may include:
[0252] Add the IDs of transactions that directly conflict with the current transaction to the adjacency list of the current transaction in the directed acyclic graph.
[0253] For example, the number of the transaction that directly conflicts with the current transaction can be determined first based on the direct conflict bitmap determined by the current transaction, and then the number of the transaction that directly conflicts with the current transaction can be added to the adjacency list of the current transaction in the directed acyclic graph.
[0254] Figure 12 This is an example of an adjacency list provided in an embodiment of this application.
[0255] like Figure 12 As shown, with Figure 11 Taking the direct conflict bitmap of transaction 4 as an example, where the direct conflict bitmap of transaction 4 is 00100000, it means that transaction 3 is a transaction that directly conflicts with transaction 4. In this case, the number of transaction 3 can be added to the adjacency list of transaction 4 in the directed acyclic graph. Of course, other transactions can be added to their respective adjacency lists in the same way as transaction 4, with the corresponding numbers of directly conflicting transactions added. To avoid duplication, this will not be elaborated further here.
[0256] The solution of this application will be described below with reference to specific embodiments.
[0257] 1. Number all transactions according to the execution order of the actual transactions in the transaction set.
[0258] 2. Construct the dictionary of read sets, the dictionary of write sets, the dictionary of read set key positions, and the dictionary of write set key positions for each transaction set.
[0259] 1) Check if the transaction set is empty. If it is empty, end the process. If it is not empty, take one transaction from all transactions in order of transaction number.
[0260] 2) Check if this transaction read set is empty. If it is empty, proceed to step 7). If it is not empty, take a read set element from the transaction read set with the key KRX and the value ValueRX.
[0261] 3) Take the length of the value with the key KRX in the read set dictionary as the read set key position dictionary, with the transaction number as the one-dimensional key and KRX as the two-dimensional key value.
[0262] 4) Take the length of the value with the key KRX in the write set dictionary as the write set key position dictionary. Use the transaction number as the one-dimensional key and KRX as the two-dimensional key value.
[0263] It is worth noting that steps 4) and 3) are not sequential and can be interchanged.
[0264] 5) Add this transaction number to the dynamic array of transaction numbers with KRX as the key in the global read set dictionary.
[0265] 6) Continue with step 2).
[0266] 7) Check if the write set of this transaction is empty. If it is empty, end this process. If it is not empty, take a write set element from the transaction's write set with the key KWX and the value ValueWX.
[0267] 8) Determine if there is an element with the key KWX in the dictionary of the read set. If it does not exist, proceed to step 9. If it does exist, proceed to step 10.
[0268] 9) Take the length of the Value with KWX as the key in the read set dictionary as the read set key position dictionary with the transaction number as the one-dimensional key and KWX as the two-dimensional key.
[0269] 10) Take the length of the Value with KWX as the key in the write set dictionary as the write set key position dictionary with the transaction number as the one-dimensional key and KWX as the two-dimensional key.
[0270] It is worth noting that steps 10) and 9) are not sequential and can be interchanged. After the interchange, the original step 9) becomes step 10), the original step 10 becomes step 9, and the original step 8) is modified to: determine whether there is an element with the key KWX in the dictionary of the write set key position. If it does not exist, execute step 9). If it exists, continue to execute step 10).
[0271] 11) Continue with step 1).
[0272] 3. Construct a DAG of the transaction set.
[0273] 1) Construct bitmaps for direct conflict transactions and cumulative conflict transactions.
[0274] a. The bitmap of the direct conflicting transactions of the initialization transaction is empty, and the bitmap of the cumulative conflicting transactions of the initialization transaction only contains itself.
[0275] b. Check if the transaction's read set is empty. If it is empty, proceed to step g. If it is not empty, retrieve a read set element from the transaction's read set, with the key being Key.
[0276] c. Retrieve the value with this key from the global write set dictionary, denoted as Txs (the set of all transactions that depend on this key as a write set element).
[0277] d. Retrieve the value (i.e., the position of this transaction in the global write set dictionary among all transactions in which the write set depends on this key) from the global write set key position dictionary, with this transaction number as the one-dimensional key and this key as the two-dimensional key, and denote it as Pos.
[0278] e. Starting from position Pos-1 of Txs, search for transactions sequentially backwards. Check if any transactions exist in the cumulative conflict bitmap. If they do, proceed to step b; otherwise, proceed to step f.
[0279] f. Set the found transactions into the cumulative transaction bitmap and the direct transaction bitmap according to their numbers.
[0280] g. Check if the write set of the transaction is empty. If it is empty, proceed to step p. If it is not empty, retrieve a read set element from the write set of the transaction, with the key KeyW.
[0281] h. Retrieve the value with this KeyWR as the key from the global read set dictionary, and denot it as WRTxs (the set of all transactions that depend on this KeyWR as the write set element).
[0282] i. Take the value of PosWR from the global read set key position dictionary, with the transaction number as the one-dimensional key and KeyWR as the two-dimensional key (i.e., the position of this transaction in the global write set dictionary among all transactions that depend on this KeyWR for the write set).
[0283] j. Starting from position PosWR-1 in WRTxs, search for transactions sequentially backwards. Check if any transactions exist in the cumulative conflict bitmap. If they do, proceed to step l; otherwise, proceed to step k.
[0284] k. Set the found transactions into the cumulative transaction bitmap and the direct transaction bitmap according to their numbers.
[0285] l. Retrieve the value with this KeyWW as the key from the global write set dictionary, and denot it as WWTxs (the set of all transactions that depend on this KeyWW as the write set element).
[0286] m. Take the value from the global write set key position dictionary with this transaction number as the one-dimensional key and this KeyWW as the two-dimensional key (that is, the position of this transaction in the global write set dictionary among all transactions with write set dependency on this KeyWW), denoted as PosWW.
[0287] n. Starting from position PosWW-1 of WWTxs, search for transactions sequentially backwards. Check if any transactions exist in the cumulative conflict bitmap. If they do, proceed to step p; otherwise, proceed to step o.
[0288] o. Set the found transactions into the cumulative transaction bitmap and the direct transaction bitmap according to their numbers.
[0289] p. Check if the bitmap of directly conflicting transactions is empty. If it is empty, end this process. If it is not empty, retrieve a conflicting transaction (number) from the bitmap.
[0290] q. Add the retrieved transaction number to the adjacency list of this transaction in the DAG, and continue to step p.
[0291] The preferred embodiments of this application have been described in detail above with reference to the accompanying drawings. However, this application is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this application, various simple modifications can be made to the technical solutions of this application, and these simple modifications all fall within the protection scope of this application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, this application will not describe the various possible combinations separately. Furthermore, various different embodiments of this application can also be arbitrarily combined, as long as they do not violate the spirit of this application, they should also be considered as the content disclosed in this application.
[0292] It should also be understood that, in the various method embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0293] The methods provided in the embodiments of this application have been described above. The apparatus provided in the embodiments of this application will be described below.
[0294] Figure 13 This is a schematic block diagram of the apparatus 500 for determining a directed acyclic graph provided in the embodiments of this application.
[0295] like Figure 13 As shown, the apparatus 500 for determining a directed acyclic graph may include:
[0296] The acquisition unit 510 is used to acquire the transaction order of transactions in the transaction set;
[0297] The determining unit 520 is used to determine the read set dictionary, the write set dictionary, the read set keyword position dictionary, and the write set keyword position dictionary of the transaction set based on the transaction order.
[0298] The key of the read set dictionary includes: the read set key of the transaction in the transaction set, and the value of each read set key in the read set dictionary includes: the number of the transaction that depends on each read set key;
[0299] The key of the write set dictionary includes: the write set key of the transaction in the transaction set, and the value of each write set key in the write set dictionary includes: the number of the transaction that depends on each write set key;
[0300] The keywords of the read set keyword position dictionary include: a two-dimensional read set keyword formed by the transaction number in the transaction set and the read set keyword of the transaction in the transaction set; the value of each two-dimensional read set keyword in the read set keyword position dictionary is used to indicate: the position of the transaction number in each two-dimensional read set keyword in the read set dictionary, which is the position of the transaction number included by the value of the read set keyword in each two-dimensional read set keyword;
[0301] The keywords of the write set keyword position dictionary include: a two-dimensional write set keyword formed by the transaction number in the transaction set and the write set keyword of the transaction in the transaction set; the value of each two-dimensional write set keyword in the write set keyword position dictionary is used to indicate: the position of the transaction number in each two-dimensional write set keyword in the write set dictionary within the transaction number included by the value of the write set keyword in each two-dimensional write set keyword.
[0302] The determining unit 520 is further configured to: determine, based on the read set keyword location dictionary and the write set keyword location dictionary, the number of the transaction that directly conflicts with the current transaction in the transaction set;
[0303] The determining unit 520 is also used to: determine the directed acyclic graph of the transaction set based on the transaction numbers that directly conflict with the current transaction.
[0304] In some embodiments, the determining unit 520 is specifically used for:
[0305] Determine if the read set for the current transaction is empty;
[0306] If the read set of the current transaction is not empty, then obtain the first element from the read set of the current transaction;
[0307] The length of the value of the key that is the first element in the read set dictionary is determined as the value of the two-dimensional key of the read set formed by the number of the current transaction and the key of the first element in the read set key position dictionary;
[0308] The length of the value of the key of the first element in the write set dictionary is determined as the value of the two-dimensional write set key formed by the current transaction number and the key of the first element in the write set key position dictionary.
[0309] In some embodiments, the determining unit 520 is further configured to:
[0310] Add the current transaction number to the value of the first element in the dictionary of the read set.
[0311] In some embodiments, the determining unit 520 is specifically used for:
[0312] Determine if the write set of the current transaction is empty;
[0313] If the write set of the current transaction is not empty, then retrieve the second element from the write set of the current transaction;
[0314] Determine whether the keyword for the second element exists in the dictionary at the keyword position of the read set;
[0315] If the keyword of the second element does not exist in the keyword position dictionary of the read set, then the length of the value of the keyword of the second element in the read set dictionary is determined as the value of the two-dimensional keyword of the read set formed by the number of the current transaction and the keyword of the second element in the keyword position dictionary of the read set.
[0316] If the keyword of the second element exists in the keyword position dictionary of the read set, then the length of the value of the keyword of the second element in the write set dictionary is determined as the value of the two-dimensional keyword of the write set formed by the current transaction number and the keyword of the second element in the keyword position dictionary of the write set.
[0317] In some embodiments, the determining unit 520 is specifically used for:
[0318] Initialize the direct conflict bitmap of the current transaction to empty;
[0319] The direct conflict bitmap of the current transaction includes the first bit corresponding to each transaction in the transaction set. The first bit corresponding to each transaction is used to indicate whether each transaction is a transaction that directly conflicts with the current transaction.
[0320] The initialization of the cumulative conflict bitmap for the current transaction includes only the current transaction;
[0321] The cumulative conflict bitmap includes a second bit corresponding to each transaction in the transaction set. The second bit corresponding to each transaction is used to indicate the transaction that directly conflicts with the transaction in the transaction set that is located before the current transaction in the transaction order.
[0322] Based on whether the cumulative conflict bitmap of the current transaction includes: the transaction number that conflicts with the current transaction as determined in the read set dictionary based on the read set keyword location dictionary, and the transaction number that conflicts with the current transaction as determined in the write set dictionary based on the write set keyword location dictionary, update the direct conflict bitmap and the cumulative conflict bitmap of the current transaction.
[0323] Based on the updated direct conflict bitmap of the current transaction, determine the number of the transaction that directly conflicts with the current transaction.
[0324] In some embodiments, the determining unit 520 is specifically used for:
[0325] Determine if the read set for the current transaction is empty;
[0326] If the read set of the current transaction is not empty, then obtain the third element from the read set of the current transaction;
[0327] Based on whether the cumulative conflict bitmap includes: the transaction number that conflicts with the current transaction as determined in the write set dictionary based on the write set key position dictionary and the key of the third element, update the direct conflict bitmap and the cumulative conflict bitmap of the current transaction.
[0328] In some embodiments, the determining unit 520 is specifically used for:
[0329] Determine whether the cumulative conflict bitmap includes: the transaction number indicated by the value of the key of the write set key in the write set dictionary that is the key of the third element, and the transaction preceding the transaction indicated by the value of the two-dimensional key formed by the number of the current transaction and the key of the third element in the write set key position dictionary;
[0330] If the cumulative conflict bitmap of the current transaction does not include the previous transaction, then the previous transaction is added to the direct conflict bitmap of the current transaction, and the transactions included in the cumulative conflict bitmap of the previous transaction are added to the cumulative conflict bitmap of the current transaction.
[0331] In some embodiments, the determining unit 520 is specifically used for:
[0332] Determine if the write set of the current transaction is empty;
[0333] If the write set of the current transaction is not empty, then obtain the fourth element from the write set of the current transaction;
[0334] Determine whether the cumulative conflict bitmap of the current transaction includes: the transaction number that conflicts with the current transaction as determined in the read set dictionary based on the read set keyword position dictionary and the keyword of the fourth element, and the transaction number that conflicts with the current transaction as determined in the write set dictionary based on the write set keyword position dictionary and the keyword of the fourth element; update the direct conflict bitmap and the cumulative conflict bitmap of the current transaction.
[0335] In some embodiments, the determining unit 520 is specifically used for:
[0336] Determine whether the cumulative conflict bitmap of the current transaction includes: the transaction number indicated by the value of the key of the fourth element in the read set dictionary, and the transaction preceding the transaction indicated by the value of the two-dimensional key formed by the number of the current transaction and the key of the fourth element in the read set key position dictionary;
[0337] If the cumulative conflict bitmap of the current transaction does not include the first transaction preceding the transaction whose number is indicated by the value of the key of the fourth element in the read set dictionary, or the transaction indicated by the value of the two-dimensional key formed by the number of the current transaction and the key of the fourth element in the read set key position dictionary, then the first transaction is added to the direct conflict bitmap of the current transaction, and the transactions included in the cumulative conflict bitmap of the first transaction are added to the cumulative conflict bitmap of the current transaction.
[0338] In some embodiments, the determining unit 520 is specifically used for:
[0339] Determine whether the cumulative conflict bitmap of the current transaction includes: the transaction number indicated by the value of the key of the write set key in the write set dictionary that is the fourth element, and the transaction preceding the transaction indicated by the value of the two-dimensional key formed by the number of the current transaction and the key of the fourth element in the write set key position dictionary;
[0340] If the cumulative conflict bitmap of the current transaction does not include the previous transaction, then the previous transaction is added to the direct conflict bitmap of the current transaction, and the transactions included in the cumulative conflict bitmap of the previous transaction are added to the cumulative conflict bitmap of the current transaction.
[0341] In some embodiments, the determining unit 520 is specifically used for:
[0342] Add the IDs of transactions that directly conflict with the current transaction to the adjacency list of the current transaction in the directed acyclic graph.
[0343] It should be understood that the device embodiments and method embodiments can correspond to each other, and similar descriptions can be referred to the method embodiments. To avoid repetition, they will not be repeated here. Specifically, the device 500 for determining the directed acyclic graph can correspond to the corresponding subject in the method 400 of the embodiments of this application, and each unit in the device 500 for determining the directed acyclic graph is for implementing the corresponding process in the method 400. For the sake of brevity, they will not be repeated here.
[0344] It should also be understood that the various units in the apparatus 500 for determining a directed acyclic graphs involved in the embodiments of this application can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This can achieve the same operation without affecting the technical effect of the embodiments of this application. The above-mentioned units are based on logical function division. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the apparatus 500 for determining a directed acyclic graphs may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units. According to another embodiment of this application, the apparatus 500 for determining a directed acyclic graph (DAG) according to the embodiments of this application, and the method for determining a DAG according to the embodiments of this application, can be constructed by running a computer program (including program code) capable of performing the steps involved in the corresponding method on a general-purpose computing device including processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM). The computer program can be recorded on, for example, a computer-readable storage medium, loaded into an electronic device through the computer-readable storage medium, and run therein to implement the corresponding method of the embodiments of this application.
[0345] In other words, the units mentioned above can be implemented in hardware, in software instructions, or in a combination of hardware and software. Specifically, the steps of the method embodiments in this application can be completed by the integrated logic circuits in the processor's hardware and / or by software instructions. The steps of the method disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or executed by a combination of hardware and software in the decoding processor. Optionally, the software can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. This storage medium is located in memory, and the processor reads the information in the memory and completes the steps in the above method embodiments in conjunction with its hardware.
[0346] Figure 14 This is a schematic structural diagram of the electronic device 600 provided in the embodiments of this application.
[0347] like Figure 14As shown, the electronic device 600 includes at least a processor 610 and a computer-readable storage medium 620. The processor 610 and the computer-readable storage medium 620 can be connected via a bus or other means. The computer-readable storage medium 620 stores a computer program 621, which includes computer instructions. The processor 610 executes the computer instructions stored in the computer-readable storage medium 620. The processor 610 is the computing and control core of the electronic device 600, and is suitable for implementing one or more computer instructions, specifically for loading and executing one or more computer instructions to achieve a corresponding method flow or function.
[0348] As an example, processor 610 may also be referred to as a central processing unit (CPU). Processor 610 may include, but is not limited to: general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0349] As an example, the computer-readable storage medium 620 may be a high-speed RAM memory or a non-volatile memory, such as at least one disk storage device; optionally, it may also be at least one computer-readable storage medium located remotely from the aforementioned processor 610. Specifically, the computer-readable storage medium 620 includes, but is not limited to, volatile memory and / or non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).
[0350] like Figure 14 As shown, the electronic device 600 may also include a transceiver 630.
[0351] The processor 610 can control the transceiver 630 to communicate with other devices; specifically, it can send information or data to other devices or receive information or data sent by other devices. The transceiver 630 may include a transmitter and a receiver. The transceiver 630 may further include antennas, and the number of antennas may be one or more.
[0352] It should be understood that the various components in the communication device 600 are connected through a bus system, which includes a data bus, a power bus, a control bus, and a status signal bus.
[0353] In one implementation, the electronic device 600 can be any electronic device with data processing capabilities; the computer-readable storage medium 620 stores first computer instructions; the processor 610 loads and executes the first computer instructions stored in the computer-readable storage medium 620 to achieve... Figure 1 The corresponding steps in the method embodiment shown are as follows; in specific implementation, the first computer instruction in the computer-readable storage medium 620 is loaded by the processor 610 and the corresponding steps are executed. To avoid repetition, they will not be described again here.
[0354] According to another aspect of this application, embodiments of this application also provide a computer-readable storage medium (Memory), which is a memory device in electronic device 600 for storing programs and data. For example, computer-readable storage medium 620. It is understood that computer-readable storage medium 620 here may include both built-in storage media in electronic device 600 and extended storage media supported by electronic device 600. The computer-readable storage medium provides storage space that stores the operating system of electronic device 600. Furthermore, the storage space also stores one or more computer instructions suitable for loading and execution by processor 610, which may be one or more computer programs 621 (including program code).
[0355] According to another aspect of this application, embodiments of this application also provide a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. For example, computer program 621. In this case, the data processing device 600 may be a computer, and the processor 610 reads the computer instructions from the computer-readable storage medium 620. The processor 610 executes the computer instructions, causing the computer to perform the method for determining a directed acyclic graph provided in the various alternative embodiments described above.
[0356] In other words, when implemented using software, it can be implemented entirely or partially in the form of a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes of the embodiments of this application are run or the functions of the embodiments of this application are implemented. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0357] Those skilled in the art will recognize that the units and process steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0358] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for determining a directed acyclic graph, characterized in that, include: Get the transaction order of transactions in a transaction set; Based on the transaction order, determine the read set dictionary, the write set dictionary, the read set keyword position dictionary, and the write set keyword position dictionary of the transaction set; The keywords of the read set dictionary include: read set keywords of transactions in the transaction set, and the value of each read set keyword in the read set dictionary includes: the number of the transaction that depends on each read set keyword; The key of the write set dictionary includes: the write set key of the transaction in the transaction set, and the value of each write set key in the write set dictionary includes: the number of the transaction that depends on each write set key; The keywords of the read set keyword position dictionary include: a two-dimensional keyword for the read set formed by the transaction number in the transaction set and the read set keyword of the transaction in the transaction set; the value of each two-dimensional keyword in the read set keyword position dictionary is used to indicate: the position of the transaction number in each two-dimensional keyword in the read set dictionary among the transaction numbers included by the value of the read set keyword in each two-dimensional keyword; The keywords of the write set keyword position dictionary include: a two-dimensional write set keyword formed by the transaction number in the transaction set and the write set keyword of the transaction in the transaction set; the value of each two-dimensional write set keyword in the write set keyword position dictionary is used to indicate: the position of the transaction number in each two-dimensional write set keyword in the write set dictionary among the transaction numbers included by the value of the write set keyword in each two-dimensional write set keyword; Based on the read set keyword location dictionary and the write set keyword location dictionary, determine the number of the transaction that directly conflicts with the current transaction in the transaction set from the read set dictionary and the write set dictionary; A directed acyclic graph of the transaction set is determined based on the transaction numbers that directly conflict with the current transaction.
2. The method according to claim 1, characterized in that, The step of determining the read set dictionary, the write set dictionary, the read set keyword position dictionary, and the write set keyword position dictionary of the transaction set based on the transaction order includes: Determine whether the read set of the current transaction is empty; If the read set of the current transaction is not empty, then obtain the first element from the read set of the current transaction; The length of the value of the keyword in the read set dictionary that is the keyword of the first element is determined as the value of the two-dimensional keyword of the read set formed by the number of the current transaction and the keyword of the first element in the read set keyword position dictionary; The length of the value of the key of the first element in the write set dictionary is determined as the value of the two-dimensional write set key formed by the current transaction number and the key of the first element in the write set key position dictionary.
3. The method according to claim 2, characterized in that, The method further includes: Add the current transaction number to the value of the key in the read set dictionary that is the key of the first element.
4. The method according to claim 1, characterized in that, The step of determining the read set dictionary, the write set dictionary, the read set keyword position dictionary, and the write set keyword position dictionary of the transaction set based on the transaction order includes: Determine whether the write set of the current transaction is empty; If the write set of the current transaction is not empty, then obtain the second element from the write set of the current transaction; Determine whether the keyword of the second element exists in the keyword position dictionary of the read set; If the keyword of the second element does not exist in the read set keyword position dictionary, then the length of the value of the keyword of the second element in the read set dictionary is determined as the value of the two-dimensional keyword of the read set formed by the number of the current transaction and the keyword of the second element in the read set keyword position dictionary; If the keyword of the second element exists in the read set keyword position dictionary, then the length of the value of the keyword of the second element in the write set dictionary is determined as the value of the write set two-dimensional keyword formed by the current transaction number and the keyword of the second element in the write set keyword position dictionary.
5. The method according to claim 1, characterized in that, The step of determining the transaction number that directly conflicts with the current transaction in the transaction set based on the read set keyword location dictionary and the write set keyword location dictionary includes: Initialize the direct conflict bitmap of the current transaction to empty; The direct conflict bitmap of the current transaction includes the first bit corresponding to each transaction in the transaction set. The first bit corresponding to each transaction is used to indicate whether each transaction is a transaction that directly conflicts with the current transaction. The initialization of the cumulative conflict bitmap for the current transaction includes only the current transaction; The cumulative conflict bitmap includes a second bit corresponding to each transaction in the transaction set. The second bit corresponding to each transaction is used to indicate the transaction that directly conflicts with the transaction in the transaction set that is located before the current transaction in the transaction order. Based on whether the cumulative conflict bitmap of the current transaction includes: the transaction number that conflicts with the current transaction as determined in the read set dictionary based on the read set keyword location dictionary, and the transaction number that conflicts with the current transaction as determined in the write set dictionary based on the write set keyword location dictionary, update the direct conflict bitmap and the cumulative conflict bitmap of the current transaction. Based on the updated direct conflict bitmap of the current transaction, the numbers of transactions that directly conflict with the current transaction are determined.
6. The method according to claim 5, characterized in that, Updating the direct conflict bitmap and the cumulative conflict bitmap of the current transaction includes: Determine whether the read set of the current transaction is empty; If the read set of the current transaction is not empty, then obtain the third element from the read set of the current transaction; Based on whether the cumulative conflict bitmap includes: the transaction number that conflicts with the current transaction, determined in the write set dictionary based on the write set keyword position dictionary and the keyword of the third element, the direct conflict bitmap and the cumulative conflict bitmap of the current transaction are updated.
7. The method according to claim 6, characterized in that, Updating the direct conflict bitmap and the cumulative conflict bitmap of the current transaction includes: Determine whether the cumulative conflict bitmap of the current transaction includes: the transaction number indicated by the value of the key of the write set key in the write set dictionary, which is the key of the third element, and the transaction preceding the transaction indicated by the value of the two-dimensional key formed by the number of the current transaction and the key of the third element in the write set key position dictionary; If the cumulative conflict bitmap of the current transaction does not include the previous transaction, then the previous transaction is added to the direct conflict bitmap of the current transaction, and the transactions included in the cumulative conflict bitmap of the previous transaction are added to the cumulative conflict bitmap of the current transaction.
8. The method according to claim 5, characterized in that, Updating the direct conflict bitmap and the cumulative conflict bitmap of the current transaction includes: Determine whether the write set of the current transaction is empty; If the write set of the current transaction is not empty, then obtain the fourth element from the write set of the current transaction; Determine whether the cumulative conflict bitmap of the current transaction includes: the transaction number that conflicts with the current transaction as determined in the read set dictionary based on the read set keyword location dictionary and the keyword of the fourth element, and the transaction number that conflicts with the current transaction as determined in the write set dictionary based on the write set keyword location dictionary and the keyword of the fourth element; update the direct conflict bitmap and the cumulative conflict bitmap of the current transaction.
9. The method according to claim 8, characterized in that, Updating the direct conflict bitmap and the cumulative conflict bitmap of the current transaction includes: Determine whether the cumulative conflict bitmap of the current transaction includes: the transaction number indicated by the value of the key of the fourth element in the read set dictionary, and the transaction preceding the transaction indicated by the value of the two-dimensional key formed by the number of the current transaction and the key of the fourth element in the read set key position dictionary; If the cumulative conflict bitmap of the current transaction does not include the first transaction preceding the transaction whose ID is indicated by the value of the key of the fourth element in the read set dictionary, or the transaction indicated by the value of the two-dimensional key formed by the ID of the current transaction and the key of the fourth element in the read set key position dictionary, then the first transaction is added to the direct conflict bitmap of the current transaction, and the transactions included in the cumulative conflict bitmap of the first transaction are added to the cumulative conflict bitmap of the current transaction.
10. The method according to claim 8, characterized in that, Updating the direct conflict bitmap and the cumulative conflict bitmap of the current transaction includes: Determine whether the cumulative conflict bitmap of the current transaction includes: the transaction number indicated by the value of the key of the fourth element in the write set dictionary, and the transaction preceding the transaction indicated by the value of the two-dimensional key formed by the number of the current transaction and the key of the fourth element in the write set key position dictionary; If the cumulative conflict bitmap of the current transaction does not include the previous transaction, then the previous transaction is added to the direct conflict bitmap of the current transaction, and the transactions included in the cumulative conflict bitmap of the previous transaction are added to the cumulative conflict bitmap of the current transaction.
11. The method according to claim 1, characterized in that, Determining the directed acyclic graph of the transaction set based on the transaction numbers that directly conflict with the current transaction includes: Add the IDs of transactions that directly conflict with the current transaction to the adjacency list of the current transaction in the directed acyclic graph.
12. An apparatus for determining a directed acyclic graph, characterized in that, include: The acquisition unit is used to retrieve the transaction order of transactions in the transaction set; The determining unit is configured to determine, based on the transaction order, the read set dictionary, the write set dictionary, the read set keyword position dictionary, and the write set keyword position dictionary of the transaction set; The keywords of the read set dictionary include: read set keywords of transactions in the transaction set, and the value of each read set keyword in the read set dictionary includes: the number of the transaction that depends on each read set keyword; The key of the write set dictionary includes: the write set key of the transaction in the transaction set, and the value of each write set key in the write set dictionary includes: the number of the transaction that depends on each write set key; The keywords of the read set keyword position dictionary include: a two-dimensional keyword for the read set formed by the transaction number in the transaction set and the read set keyword of the transaction in the transaction set; the value of each two-dimensional keyword in the read set keyword position dictionary is used to indicate: the position of the transaction number in each two-dimensional keyword in the read set dictionary among the transaction numbers included by the value of the read set keyword in each two-dimensional keyword; The keywords of the write set keyword position dictionary include: a two-dimensional write set keyword formed by the transaction number in the transaction set and the write set keyword of the transaction in the transaction set; the value of each two-dimensional write set keyword in the write set keyword position dictionary is used to indicate: the position of the transaction number in each two-dimensional write set keyword in the write set dictionary among the transaction numbers included by the value of the write set keyword in each two-dimensional write set keyword; The determining unit is further configured to: based on the read set keyword location dictionary and the write set keyword location dictionary, determine the number of the transaction that directly conflicts with the current transaction in the transaction set in the read set dictionary and the write set dictionary; The determining unit is further configured to: determine a directed acyclic graph of the transaction set based on the transaction numbers that directly conflict with the current transaction.
13. An electronic device, characterized in that, include: A processor, adapted to execute computer programs; A computer-readable storage medium storing a computer program that, when executed by the processor, implements the method as described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, Used to store a computer program that causes a computer to perform the method as described in any one of claims 1 to 11.
15. A computer program product comprising a computer program and / or instructions, characterized in that, When the computer program and / or instructions are executed by a processor, they implement the method as described in any one of claims 1 to 11.
Citation Information
Patent Citations
Block chain-based transaction conflict detection method, device, equipment and storage medium
CN114022148A
Parallel execution of blockchain transactions
US20170212781A1