A method and device for operating blockchain data
By adopting multi-data page storage and index information management methods in blockchain, the problem of low reading and writing efficiency of data records in the financial industry when the primary key corresponds to the financial industry is solved, and the efficient performance of data operations is achieved and the efficient operation needs of financial institutions are met.
Patent Information
- Application Number
- CN202010144327.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-04
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2040-03-04
AI Technical Summary
Since the business data stored in the financial industry in the blockchain is low in reading and writing efficiency when there are many records of primary key corresponding data, the business data stored in the financial industry is unable to meet the efficient operation needs of financial institutions.
Data records in the form of key-value pairs are stored in multiple data pages. Each primary key corresponds to at least one key value. The blockchain node determines the page to be operated by obtaining data operation instructions, reads and performs data operations to avoid obtaining all key values. Increase read and write performance, and generate target index information through preset objects for storage and query optimization.
It significantly improves the read and write performance of data records, improves the data query and modification efficiency, and meets the needs of financial institutions for efficient operation.
Smart Images

Figure CN111367915B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain in the field of financial technology (Fintech), and in particular to a method and device for operating blockchain data. Background Art
[0002] With the development of computer technology, more and more technologies are being applied in the financial field. Traditional finance is gradually transforming to Fintech. However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on technology. The data in the financial industry has extremely high security requirements and is often stored through blockchain.
[0003] In the current method, the business data of the financial industry is stored in the form of key-value pairs in the blockchain in the storage table. A primary key in the storage table corresponds to one or more data records, and the key value of the primary key is operated in a holistic manner when reading and writing. When there are many data records corresponding to a primary key, the reading and writing efficiency is very low, which is a problem that needs to be solved urgently. Summary of the invention
[0004] The present invention provides a method and device for operating blockchain data, which solves the problem in the prior art that when there are many data records corresponding to a primary key, the reading and writing efficiency is very low.
[0005] In a first aspect, the present invention provides a method for operating blockchain data, comprising: a blockchain node obtains a data operation instruction; the data operation instruction includes a first data record with a target primary key; the blockchain node stores data records in the form of key-value pairs in a multi-data page manner; each primary key corresponds to at least one key value; the blockchain node determines a page to be operated for the first data record; the blockchain node reads an existing data record with the target primary key in the page to be operated; the blockchain node performs data operations on the existing data record according to the data operation instruction.
[0006] Under the above method, the blockchain node stores data records in the form of key-value pairs in multiple data pages; each primary key corresponds to at least one key value; when the blockchain node obtains a data operation instruction, the data operation instruction includes a first data record with a target primary key, and there is no need to obtain all key values of the primary key distributed and stored in multiple data pages. Instead, the page to be operated of the first data record is first determined, and then the existing data record with the target primary key in the page to be operated is read, and data operations are performed on the existing data record according to the data operation instruction, thereby eliminating the need to obtain all key values of the primary key, which can greatly increase the reading and writing performance of data records.
[0007] In an optional implementation, the data operation instruction is a new instruction; the method also includes: the blockchain node generates target index information of the first data record based on the correspondence between the value of the preset object in the first data record and the page to be operated; the blockchain node determines the first index page in the index library where the target index information is to be stored based on the value of the preset object in the first data record; the blockchain node stores the target index information in the index library based on the first index page.
[0008] In the above method, the blockchain node generates the target index information of the first data record according to the correspondence between the value of the preset object in the first data record and the page to be operated, determines the first index page according to the value of the preset object in the first data record, and stores the target index information in the index library, so that after the first data record is added, the target index information of the first data record is also recorded, which can facilitate subsequent search of the first data record.
[0009] In an optional implementation, the index information in the index page is arranged in a preset order according to the value of the preset object; the blockchain node stores the target index information in the index library according to the first index page, including: the blockchain node determines the page position to be stored in the first index page according to the value of the preset object; if the page position to be stored in the first index page is the middle of the first index page and the first index page is full, the blockchain node splits the first index page into a second index page and a third index page from the middle of the first index page; the blockchain node stores the index information before the middle of the first index page and the target index information in the second index page; the blockchain node stores the index information after the middle of the first index page in the third index page.
[0010] In the above method, after the blockchain node determines the page position to be stored in the first index page according to the value of the preset object, if the page position to be stored in the first index page is the middle of the first index page and the first index page is full, it can also be split into a second index page and a third index page without affecting the preset order between the index information, thereby re-opening up space for storing index information and reconstructing the index page, thereby providing a method for adding new index information without changing the preset order between the index information.
[0011] In an optional implementation, the index information in the index page is arranged in a preset order according to the value of the preset object; the blockchain node stores the target index information in the index library according to the first index page, including: the blockchain node determines the page position to be stored in the first index page according to the value of the preset object; if the page position to be stored in the first index page is the head or tail of the first index page, and the first index page is full, the blockchain node creates a fourth index page and stores the target index information in the fourth index page.
[0012] In the above manner, after the blockchain node determines the page position to be stored in the first index page according to the value of the preset object, if the page position to be stored in the first index page is the head or tail of the first index page, and the first index page is full, it is also possible to create a fourth index page without affecting the preset order between the index information, thereby opening up new space for storing index information and reconstructing the index page, thereby providing a method for adding new index information without changing the preset order between the index information.
[0013] In an optional implementation, the data operation instruction is a new instruction; the blockchain node performs data operation on the existing data record according to the data operation instruction, including: the blockchain node adds the first data record to the existing data record based on the existing data record and the first data record, thereby updating the data record of the target primary key in the page to be operated.
[0014] In the above manner, when the data operation instruction is a new instruction, the blockchain node only needs to add the first data record to the existing data record based on the existing data record and the first data record of the page to be operated, without obtaining all key values based on the target primary key, thereby providing a higher-performance method for updating the data record of the target primary key in the page to be operated.
[0015] In an optional implementation, the data operation instruction is a modification instruction or a query instruction; the blockchain node determines the page to be operated of the first data record, including: the blockchain node determines the first index page corresponding to the first data record according to the value of a preset object in the first data record; the first index page records multiple index information; wherein each index information records the correspondence between the value of the preset object and the data page; the blockchain node determines the target index information corresponding to the first data record from the first index page; the blockchain node determines the page to be operated according to the target index information.
[0016] In the above manner, since multiple index information are recorded in the first index page, each index information records the correspondence between the value of the preset object and the data page, and the blockchain node can determine the first index page corresponding to the first data record according to the value of the preset object in the first data record, the blockchain node can quickly find the target index information and the page to be operated, so that there is no need to traverse all the data pages, thereby improving the data query performance.
[0017] In an optional implementation, the data operation instruction is a modification instruction; the modification instruction also includes a second data record with a target primary key; the modification instruction is used to modify the first data record to the second data record; the existing data record includes the first data record; the blockchain node performs data operations on the existing data record in accordance with the data operation instruction, including: the blockchain node modifies the first data record in the existing data record to the second data record based on the existing data record and the second data record, thereby updating the existing data record of the target primary key in the page to be operated.
[0018] In the above manner, when the data operation instruction is a modification instruction, the modification instruction also includes a second data record having a target primary key; the modification instruction is used to modify the first data record to the second data record; since the existing data record includes the first data record, it is only necessary to read the page to be operated to modify the first data record in the existing data record to the second data record, thereby improving the data modification performance.
[0019] In a second aspect, the present invention provides a blockchain data operation device, comprising: an acquisition module, used to acquire data operation instructions; the data operation instructions include a first data record with a target primary key; the blockchain node stores data records in the form of key-value pairs in a multi-data page manner; each primary key corresponds to at least one key value; a processing module, used to determine the page to be operated for the first data record; used to read an existing data record with the target primary key in the page to be operated; and used to perform data operations on the existing data records according to the data operation instructions.
[0020] In an optional embodiment, the processing module is also used to: generate target index information of the first data record based on the correspondence between the value of the preset object in the first data record and the page to be operated; determine the first index page in the index library where the target index information is to be stored based on the value of the preset object in the first data record; and store the target index information in the index library based on the first index page.
[0021] In an optional implementation, the index information in the index page is arranged in a preset order according to the value of the preset object; the processing module is specifically used to: determine the page position to be stored in the first index page according to the value of the preset object; if the page position to be stored in the first index page is the middle of the first index page and the first index page is full, then split the first index page into a second index page and a third index page from the middle of the first index page; store the index information before the middle of the first index page and the target index information in the second index page; and store the index information after the middle of the first index page in the third index page.
[0022] In an optional implementation, the index information in the index page is arranged in a preset order according to the value of the preset object; the processing module is specifically used to: determine the page position to be stored in the first index page according to the value of the preset object; if the page position to be stored in the first index page is the head or tail of the first index page, and the first index page is full, create a fourth index page, and store the target index information in the fourth index page.
[0023] In an optional implementation, the data operation instruction is a new addition instruction; the processing module is specifically used to: add the first data record to the existing data record based on the existing data record and the first data record, thereby updating the data record of the target primary key in the page to be operated.
[0024] In an optional implementation, the data operation instruction is a modification instruction or a query instruction; the processing module is specifically used to: determine the first index page corresponding to the first data record according to the value of a preset object in the first data record; the first index page records multiple index information; wherein each index information records the correspondence between the value of the preset object and the data page; determine the target index information corresponding to the first data record from the first index page; and determine the page to be operated according to the target index information.
[0025] In an optional implementation, the data operation instruction is a modification instruction; the modification instruction also includes a second data record with a target primary key; the modification instruction is used to modify the first data record to the second data record; the existing data record includes the first data record; the processing module is specifically used to: based on the existing data record and the second data record, modify the first data record in the existing data record to the second data record, thereby updating the existing data record of the target primary key in the page to be operated.
[0026] The above-mentioned second aspect and each beneficial effect of the second aspect can refer to the above-mentioned first aspect and each beneficial effect of the first aspect, and will not be repeated here.
[0027] In a third aspect, the present invention provides a computer device, including a program or an instruction, which, when executed, is used to execute the above-mentioned first aspect and each optional method of the first aspect.
[0028] In a fourth aspect, the present invention provides a storage medium, comprising a program or an instruction, which, when executed, is used to execute the above-mentioned first aspect and each optional method of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 A schematic diagram of the steps of a blockchain data operation method provided in an embodiment of the present application;
[0030] Figure 2 A schematic diagram of the structure of an index library provided in an embodiment of the present application;
[0031] Figure 3 A schematic diagram of the structure of a blockchain data operating device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to better understand the above-mentioned technical scheme, the above-mentioned technical scheme will be described in detail below in combination with the accompanying drawings and specific implementation methods of the specification. It should be understood that the embodiments of the present application and the specific features in the embodiments are detailed descriptions of the technical scheme of the present application, rather than limitations on the technical scheme of the present application. In the absence of conflict, the embodiments of the present application and the technical features in the embodiments may be combined with each other.
[0033] Storage table: The storage table maps the primary key of the distributed storage (Advanced Mass Database, AMDB) to the corresponding entry. It can add, delete, modify and query based on the primary key of AMDB, and supports conditional filtering.
[0034] Data record: A data record corresponds to a row in a storage table. Each row uses the column name as the key and the corresponding value as the key value, forming a key-value pair (KV) structure. Each data record has its own AMDB primary key, and different data records are allowed to have the same AMDB primary key.
[0035] Data record group: Data records with the same primary key are stored in the data record group. The primary key of AMDB is different from the primary key of traditional databases. The AMDB primary key is used to indicate which primary key the data record belongs to. Data records with the same primary key will be stored in the same data record group.
[0036] Filter conditions: The delete, modify, and query interfaces in the storage table support the input of filter conditions. These three interfaces will return the results filtered according to the conditions. If the filter condition is empty, no filtering will be performed.
[0037] As shown in Table 1, taking a company's employee materials registration form as an example, the above terms are explained.
[0038] Name (primary key) Data record number Data record name Alice 1001001 Laptop Alice 1001002 monitor Bob 1002001 Laptop Chris 1003001 Desktop Computer
[0039] Table 1
[0040] Specifically, name is the primary key of distributed storage. Each row in Table 1 is a data record. There are 4 data records in total, and each data record stores data in the form of key-value pairs. The 4 data records are as follows:
[0041] Data record 1: {name: Alice, data record number: 1001001, data record name: laptop};
[0042] Data record 2: {name: Alice, data record number: 1001002, data record name: display};
[0043] Data record 3: {name: Bob, data record number: 1002001, data record name: laptop};
[0044] Data record 4: {Name: Chris, Data record number: 1003001, Data record name: Desktop Computer}.
[0045] The storage table uses name as the primary key and stores three data record group objects. The first data record group contains two records of Alice, the second data record group contains one record of Bob, and the third data record group contains one record of Chris. When calling the query interface of the storage table class, the query interface needs to specify the primary key and filter condition in the distributed storage. Set the primary key of the distributed storage to be queried to Alice, and the filter condition to: condition number = 1001001, and data record 1 will be queried.
[0046] When financial institutions (banks, insurance institutions or securities institutions) are operating their businesses (such as bank loan business, deposit business, etc.), they often store data through storage tables on blockchain nodes. When reading and writing storage tables, the key value of the primary key is operated in an overall manner. When there are many data records corresponding to a primary key, the reading and writing efficiency is very low. This situation does not meet the needs of banks and other financial institutions, and cannot ensure the efficient operation of various businesses of financial institutions.
[0047] For this reason, Figure 1 As shown, the present application provides a method for operating blockchain data.
[0048] Step 101: The blockchain node obtains a data operation instruction; the data operation instruction includes a first data record with a target primary key.
[0049] Step 102: The blockchain node determines the page to be operated on the first data record.
[0050] Step 103: The blockchain node reads the existing data record with the target primary key in the page to be operated.
[0051] Step 104: The blockchain node performs data operations on the existing data records according to the data operation instructions.
[0052] It should be noted that in the above steps 101 to 104, the blockchain node stores data records in the form of key-value pairs in multiple data pages; each primary key corresponds to at least one key value. The space for storing data records in each data page can be set to be the same, such as 5 rows per page, which can store 5 data records.
[0053] Take the data records with the same primary key (Xiaoming) as an example, as shown in Table 2-1 and Table 2-2, 9 data records with the primary key Xiaoming are stored in paging form, and each data page has 5 rows of space for storing data records. Among them, Table 2-1 represents Xiaoming's data page 1, and Table 2-2 represents Xiaoming's data page 2.
[0054] Name Asset Number Asset Type price Xiao Ming 1 watch 100k Xiao Ming 2 Sports Car 1000k Xiao Ming 3 Sea View Room 60m Xiao Ming 4 High level 80m Xiao Ming 5 Shops 200m
[0055] Table 2-1
[0056] Name Asset Number Asset Type price Xiao Ming 6 apartment 100m Xiao Ming 7 Securities 600m Xiao Ming 8 Insurance 100k Xiao Ming 9 yacht 200m
[0057] Table 2-2
[0058] When the instruction to be operated is a new instruction, the page to be operated can be a randomly specified data page, or the last page of the data page can be directly set as the page to be operated. The appending rule of data records can be: sort Xiao Ming's data pages, and sort according to Xiao Ming's data page 1 and Xiao Ming's data page 2. Append at the end of the data page of Xiao Ming's last page. For example, add a data record with asset number 10, and directly store it in the last line of Xiao Ming's data page 2. In addition, the total number of pages of Xiao Ming's data page can also be recorded on the first page, such as recording the total number of pages as 2 on the first page. If data records with asset numbers 10 and 11 are added, a new data page Xiao Ming's data page 3 can be created, and the total number of pages recorded in Xiao Ming's data page 1 can be updated by 3. Therefore, in the best case, the write operation only needs to update the data page where the data record is located, and 1 page needs to be written; in the worst case, the write operation needs to create a new page, and 2 data pages need to be written, the newly created data page and the first data page. It can be seen that when the page is only for data records with one primary key, the total number of pages recorded on the first page can quickly locate the data page to be operated.
[0059] In an optional implementation, the blockchain in steps 101 to 104 can add index information of data records when adding new data records, so that the page to be operated can be quickly and conveniently located when modifying, querying and deleting data records in the future. The details can be as follows:
[0060] The blockchain node generates target index information of the first data record based on the correspondence between the value of the preset object in the first data record and the page to be operated; the blockchain node determines the first index page in the index library where the target index information is to be stored based on the value of the preset object in the first data record; the blockchain node stores the target index information in the index library based on the first index page.
[0061] For example, the preset object is a preset column name, such as the price in Table 2-1 and Table 2-2, and the corresponding relationship between the value of the preset object in the first data record and the page to be operated is: the price is 40K, data page 10; that is, the data record recording the price 40K is stored in data page 10. It should be noted that there may be many data records of the price 40K, and they may also be stored in multiple data pages. There may be a corresponding relationship between one price and multiple data pages at the same time, such as the price is 40K, data page 10; the price is 40K, data page 11.
[0062] Index information is uniformly stored in the index library. The index library has multiple index pages for storing index information, and the index page where each index information is stored can also be determined according to the value of the preset object. The storage rules of specific index information can be flexibly set according to the scenario. For example, it can be stored in the order of the value of the preset object, and index page one is set to store index information with a price of 0 to 80K, and index page two is set to store index information with a price of 80K to 100K. Then, when the price of the first data record is 40K, the first index page to be stored in the generated target index information is index page one. Then, when it is necessary to query the page to be operated of the first data record, it can be known from the price of 40K that the first index information is queried on index page one to find the page to be operated of the first data record.
[0063] It should be noted that the data structure of the index library can be multiple. For example, the index library uses the B+ tree to store index information. The leaf nodes of the B+ tree are index pages that store index information, and the non-leaf nodes (root pages when there are two layers) are used to store indexes of index pages. The specific structure can be as follows: Figure 2 It should be noted that Figure 2 The two-layer B+ tree structure shown is only for illustration. In fact, the B+ tree can have any number of layers.
[0064] The root node stores the index of the index page, for example, as shown in Table 3-1.
[0065]
[0066] Table 3-1
[0067] The index information stored in the index page may be as shown in Table 3-2.
[0068] price Data page number 10K 4 20K 1 30K 3 42K 3 60K 2
[0069] Table 3-2
[0070] It is worth mentioning that the value size of the preset object and the size of the data page number are not necessarily positively correlated. This is related to the storage mechanism of the data page. If the tail append mechanism is followed, the newly added data records will be stored first, and the data pages stored will be closer to the front.
[0071] In the above optional implementation, the index information in the index page can be arranged in a preset order according to the value of the preset object. Then in the method in which the blockchain node stores the target index information in the index library according to the first index page, the blockchain node first determines the page position to be stored in the first index page according to the value of the preset object; the subsequent steps can be specifically divided into the following situations:
[0072] The first type: writing to the first index page, and the first index page is not full.
[0073] Directly update the first index page and write 1 page.
[0074] The second type: writing to the middle of the first index page, and the first index page is full.
[0075] If the page position to be stored in the first index page is in the middle of the first index page and the first index page is full, the blockchain node splits the first index page into a second index page and a third index page from the middle of the first index page.
[0076] The blockchain node stores the index information before the middle of the first index page and the target index information in the second index page; the blockchain node stores the index information after the middle of the first index page in the third index page. For example, if the index pages are all 1000 rows, the first index page is 1000 rows, and the row number for the target index information to be stored is row 751. Then the first 750 rows of the second index page just after the split store the first 750 rows of index information of the original first index page, and the last 250 rows are empty, and the target index information is stored in row 751 of the second index page; the first 250 rows of the third index page store index information, and the last 750 rows are empty. The target index information can also be stored in row 1 of the third index page, and rows 2 to 251 of the third index page store rows 1 to 250 of the original first index page. Update the root page at the same time, and write a total of 3 pages.
[0077] More specifically, as shown in Table 4-1, the range of index information stored in the first index page is index information with preset object values between 0K and 100K, and 1000 rows are already stored.
[0078]
[0079] Table 4-1
[0080] For example, the value of the preset object of the newly added target index information is 80K. Obviously, 80K is between 0K and 100K, so 0K to 100K needs to be split into the second index page for storing 0K to 80K and the third index page for storing 80K to 100K. The index of the first index page in the root page is also divided into two parts. The root page is represented as shown in Table 4-2.
[0081] Starting value End value Index Page 0 80K Second index page 80K 100K Third index page
[0082] Table 4-2
[0083] The second index page and the third index page are divided as shown in Table 4-3 and Table 4-4 respectively:
[0084] The second index page is shown in Table 4-3:
[0085]
[0086] Table 4-3
[0087] The third index page is shown in Table 4-4:
[0088]
[0089] Table 4-4
[0090] The third type: writing to the head or tail of the first index page, and the first index page is full.
[0091] The blockchain node creates a fourth index page and stores the target index information in the fourth index page. At the same time, the root page is updated, and a total of 2 pages are written. The specific process can be inferred from the second case and will not be repeated here.
[0092] It should be noted that in steps 101 to 104, the data operation instructions may be new adding instructions, query instructions and modification instructions.
[0093] In an optional implementation of step 103, the data operation instruction is a modification instruction or a query instruction; step 103 can be performed in the following manner:
[0094] The blockchain node determines the first index page corresponding to the first data record according to the value of the preset object in the first data record; the blockchain node determines the target index information corresponding to the first data record from the first index page; the blockchain node determines the page to be operated according to the target index information.
[0095] For example, the value of the preset object in the first data record is a price of 40K, and the index information stored in the first index page is 0K to 80K, so it can be known that the first data record corresponds to the first index page. Then, the target index information corresponding to 40K is found in the first index page. At this time, the target index information can be one index information, corresponding to one data page, and this data page is the page to be operated. The target index information may also be multiple index information. Then, according to the first data record, the page to be operated where the first data record is located is found in these multiple data pages.
[0096] The first index page records a plurality of index information, wherein each index information records a corresponding relationship between the value of the preset object and the data page.
[0097] In an optional implementation of step 104, the data operation instruction is a new instruction; then step 104 can be performed in the following manner:
[0098] The blockchain node adds the first data record to the existing data record based on the existing data record and the first data record, thereby updating the data record of the target primary key in the page to be operated.
[0099] The specific update operation can be similar to the operation in the index page, and a new data page is created when the data page is full.
[0100] In another optional implementation of step 104, the data operation instruction is a modification instruction; the modification instruction also includes a second data record having a target primary key; the modification instruction is used to modify the first data record to the second data record; the existing data record includes the first data record; step 104 can be specifically performed in the following manner:
[0101] The blockchain node modifies the first data record in the existing data records into the second data record based on the existing data record and the second data record, thereby updating the existing data record of the target primary key in the page to be operated.
[0102] like Figure 3 As shown, the present invention provides a blockchain data operation device, including: an acquisition module 301, used to acquire a data operation instruction; the data operation instruction includes a first data record with a target primary key; the blockchain node stores data records in the form of key-value pairs in a multi-data page manner; each primary key corresponds to at least one key value; a processing module 302, used to determine the page to be operated for the first data record; used to read an existing data record with the target primary key in the page to be operated; and used to perform data operations on the existing data record according to the data operation instruction.
[0103] In an optional implementation, the processing module 302 is also used to: generate target index information of the first data record based on the correspondence between the value of the preset object in the first data record and the page to be operated; determine the first index page in the index library where the target index information is to be stored based on the value of the preset object in the first data record; and store the target index information in the index library based on the first index page.
[0104] In an optional implementation, the index information in the index page is arranged in a preset order according to the value of the preset object; the processing module 302 is specifically used to: determine the page position to be stored in the first index page according to the value of the preset object; if the page position to be stored in the first index page is the middle of the first index page and the first index page is full, then split the first index page into a second index page and a third index page from the middle of the first index page; store the index information before the middle of the first index page and the target index information in the second index page; store the index information after the middle of the first index page in the third index page.
[0105] In an optional implementation, the index information in the index page is arranged in a preset order according to the value of the preset object; the processing module 302 is specifically used to: determine the page position to be stored in the first index page according to the value of the preset object; if the page position to be stored in the first index page is the head or tail of the first index page, and the first index page is full, create a fourth index page, and store the target index information in the fourth index page.
[0106] In an optional implementation, the data operation instruction is a new addition instruction; the processing module 302 is specifically used to: add the first data record to the existing data record based on the existing data record and the first data record, thereby updating the data record of the target primary key in the page to be operated.
[0107] In an optional implementation, the data operation instruction is a modification instruction or a query instruction; the processing module 302 is specifically used to: determine the first index page corresponding to the first data record according to the value of the preset object in the first data record; the first index page records multiple index information; wherein each index information records the correspondence between the value of the preset object and the data page; determine the target index information corresponding to the first data record from the first index page; and determine the page to be operated according to the target index information.
[0108] In an optional implementation, the data operation instruction is a modification instruction; the modification instruction also includes a second data record with a target primary key; the modification instruction is used to modify the first data record to the second data record; the existing data record includes the first data record; the processing module 302 is specifically used to: based on the existing data record and the second data record, modify the first data record in the existing data record to the second data record, thereby updating the existing data record of the target primary key in the page to be operated.
[0109] An embodiment of the present application provides a computer device, including a program or instruction, which, when executed, is used to execute a blockchain data operation method and any optional method provided in an embodiment of the present application.
[0110] An embodiment of the present application provides a storage medium, including a program or instruction, which, when executed, is used to execute a blockchain data operation method and any optional method provided in an embodiment of the present application.
[0111] Finally, it should be noted that: those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program code.
[0112] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0113] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0114] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for operating blockchain data, characterized in that: include: The blockchain node obtains a data operation instruction; the data operation instruction includes a first data record having a target primary key; The blockchain node stores data records in the form of key-value pairs in a multi-data page manner; each primary key corresponds to at least one key value; The blockchain node determines a page to be operated on the first data record; The blockchain node reads an existing data record having the target primary key in the page to be operated; The blockchain node performs data operation on the existing data record according to the data operation instruction; The data operation instruction is a newly added instruction; The method further comprises: The blockchain node generates target index information of the first data record according to the correspondence between the value of the preset object in the first data record and the page to be operated; the preset object is a preset column name; The blockchain node determines, according to the value of the preset object in the first data record, a first index page in the index library where the target index information is to be stored; The blockchain node stores the target index information in the index library according to the first index page.
2. The method according to claim 1, characterized in that The index information in the index page is arranged in a preset order according to the value of the preset object; The blockchain node stores the target index information in the index library according to the first index page, including: The blockchain node determines, according to the value of the preset object, a page location to be stored in the first index page; If the page position to be stored in the first index page is in the middle of the first index page and the first index page is full, the blockchain node splits the first index page into a second index page and a third index page from the middle of the first index page; The blockchain node stores the index information before the middle of the first index page and the target index information in the second index page; the blockchain node stores the index information after the middle of the first index page in the third index page.
3. The method according to claim 1, characterized in that The index information in the index page is arranged in a preset order according to the value of the preset object; The blockchain node stores the target index information in the index library according to the first index page, including: The blockchain node determines, according to the value of the preset object, a page position to be stored in the first index page; If the page position to be stored in the first index page is the head or tail of the first index page, and the first index page is full, the blockchain node creates a fourth index page and stores the target index information in the fourth index page.
4. The method according to any one of claims 1 to 3, characterized in that: The data operation instruction is a newly added instruction; The blockchain node performs data operations on the existing data records according to the data operation instructions, including: The blockchain node adds the first data record to the existing data record based on the existing data record and the first data record, thereby updating the data record of the target primary key in the page to be operated.
5. The method according to any one of claims 1 to 3, characterized in that: The data operation instruction is a modification instruction or a query instruction; The blockchain node determines the page to be operated on the first data record, including: The blockchain node determines a first index page corresponding to the first data record according to the value of the preset object in the first data record; the first index page records a plurality of index information; wherein each index information records a corresponding relationship between the value of the preset object and the data page; The blockchain node determines target index information corresponding to the first data record from the first index page; The blockchain node determines the page to be operated according to the target index information.
6. The method according to any one of claims 1 to 3, characterized in that: The data operation instruction is a modification instruction; the modification instruction also includes a second data record having a target primary key; the modification instruction is used to modify the first data record to the second data record; the existing data record includes the first data record; The blockchain node performs data operations on the existing data records according to the data operation instructions, including: The blockchain node modifies the first data record in the existing data records into the second data record based on the existing data record and the second data record, thereby updating the existing data record of the target primary key in the page to be operated.
7. A device for operating blockchain data, characterized in that: include: An acquisition module, configured to acquire a data operation instruction; the data operation instruction includes a first data record having a target primary key; The blockchain node stores data records in the form of key-value pairs in a multi-data page manner; each primary key corresponds to at least one key value; A processing module, used for determining a page to be operated on the first data record; and for reading an existing data record having the target primary key in the page to be operated; and for performing data operations on the existing data records according to the data operation instructions; The data operation instruction is a new instruction; the processing module is further used to: generate target index information of the first data record according to the corresponding relationship between the value of the preset object in the first data record and the page to be operated; The preset object is a preset column name; Determining, according to the value of the preset object in the first data record, a first index page in the index library where the target index information is to be stored; According to the first index page, the target index information is stored in the index library.
8. A computer device, characterized in that: The method comprises a program or an instruction, and when the program or the instruction is executed, the method according to any one of claims 1 to 6 is performed.
9. A storage medium, characterized in that: The method comprises a program or an instruction, and when the program or the instruction is executed, the method according to any one of claims 1 to 6 is performed.
Citation Information
Patent Citations
Block chain account book data query method, electronic device and storage medium
CN110162540A