Data processing method, device and electronic device
By dividing the preset index range into multiple data index ranges and building a B-tree, concurrent execution of data operations in high concurrency is achieved, and the problem of inefficient index query and update of massive data tables is solved, and the data is improved Processing efficiency and reduce time-consuming.
Patent Information
- Application Number
- CN202010727974.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-24
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2040-07-24
AI Technical Summary
In the case of high concurrency, the B-tree index query and update of massive data tables is inefficient, resulting in a multiplier number of queries and data updates being performed serially, which seriously affects efficiency and is time-consuming.
通过将预设索引范围划分为多个数据索引范围,并为每个索引范围构建相应的B树,分区并发执行数据操作,控制目标数据索引范围的B树处于锁定状态以避免冲突。
It improves the efficiency of data processing, saves data processing time, realizes concurrent execution of data operations, reduces the B-tree height and number of queries, and avoids useless disk queries.
Smart Images

Figure CN111858606B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computers, and in particular to a data processing method, device and electronic equipment. Background Art
[0002] With the rapid development of mobile Internet, social networks, and e-commerce, the amount of information is increasing day by day, and a huge amount of data is stored in the database. Many data tables in the database store tens of millions or even hundreds of millions of data. When processing data, it is often necessary to rely on indexes. Currently, commonly used indexes include B-tree or B+ tree.
[0003] For a data table with massive data, there is a corresponding B-tree. When performing a data query or data update, the data query or data update is often implemented through binary search based on the B-tree. The number of queries for the above single search is not large, but in the case of high concurrency (for example, 1,000 data queries are performed at the same time), the number of queries will increase exponentially (number of queries = number of queries for a single search * number of concurrency). In addition, when a data table is updated (including data writing and data reading), the entire B-tree corresponding to the data table is in a locked state. When the data table is updated 1,000 times at the same time, the data update process can only be performed serially, which seriously affects the efficiency of data update and is very time-consuming. Summary of the invention
[0004] In view of this, an object of the present invention is to provide a data processing method, device and electronic device to alleviate the technical problems of low efficiency and serious time consumption of existing data processing methods.
[0005] In a first aspect, an embodiment of the present invention provides a data processing method, comprising: obtaining a preset index range, wherein the preset index range is a preset range interval of index key values for indexing data in a database; dividing the preset index range into multiple data index ranges, and constructing a corresponding B-tree for each of the data index ranges; performing specified data operations on the data based on each of the data index ranges and the B-tree corresponding to each of the data index ranges.
[0006] Furthermore, performing a specified data operation on the data based on each of the data index ranges and the B-tree corresponding to each of the data index ranges includes: when the specified data operation is a data update operation, determining the data index key value of the data to be updated; determining the data index range to which the data index key value of the data to be updated belongs among the multiple data index ranges; constructing a first target B-tree node on the B-tree corresponding to the data index range to which the data index key value of the data to be updated belongs; and updating the data to be updated according to the index key value of the first target B-tree node and the storage location corresponding to the first target B-tree node.
[0007] Furthermore, performing a specified data operation on data based on each of the data index ranges and the B-tree corresponding to each of the data index ranges also includes: when the specified data operation is a data read operation, determining the data index key value of the data to be read; determining the data index range to which the data index key value of the data to be read belongs among the multiple data index ranges; determining the B-tree corresponding to the data index range to which the data index key value of the data to be read belongs; traversing and searching the B-tree corresponding to the data index range to which the data index key value of the data to be read belongs, obtaining the storage location of the data to be read in the database, and reading the data to be read according to the storage location.
[0008] Furthermore, before performing a specified data operation on the data based on each of the data index ranges and the B-tree corresponding to each of the data index ranges, the method further includes: determining a target data index range corresponding to the specified data operation; and controlling the B-tree corresponding to the target data index range to be in a locked state.
[0009] Further, controlling the B-tree corresponding to the target data index range to be in a locked state includes: setting a lock flag for the B-tree corresponding to the target data index range; and controlling the B-tree corresponding to the target data index range to be in a locked state according to the lock flag.
[0010] In a second aspect, an embodiment of the present invention further provides a data processing method, comprising: obtaining a data index key value of the data to be read; determining a first target data index range in multiple data index ranges based on the data index key value, wherein each data index range contains the data index key value of each data in the database; each data index range corresponds to a B-tree; determining a storage location of the data to be read in the database based on the first target data index range and its corresponding first target B-tree, and reading the data to be read according to the storage location.
[0011] Furthermore, each data index range corresponds to a B-tree pointer; determining the storage location of the data to be read in the database based on the first target data index range and its corresponding first target B-tree includes: determining the first target B-tree according to the B-tree pointer of the first target data index range; determining the storage location of the data to be read in the database based on the first target B-tree.
[0012] Furthermore, before determining the storage location of the to-be-read data in the database based on the first target B-tree, the method further includes: setting a lock flag for the first target B-tree; and controlling the first target B-tree to be in a locked state according to the lock flag.
[0013] In a third aspect, an embodiment of the present invention further provides a data processing method, comprising: obtaining a data index key value of the data to be updated; determining a second target data index range to which the data to be updated belongs in multiple data index ranges according to the data index key value, wherein each data index range contains the data index key values of each data in a database; each data index range corresponds to a B-tree; constructing a second target B-tree node on the B-tree corresponding to the second target data index range; and updating the data to be updated according to the index key value of the second target B-tree node and the storage location corresponding to the second target B-tree node.
[0014] Furthermore, before constructing a second target B-tree node on the B-tree corresponding to the second target data index range, the method also includes: setting a lock flag for the B-tree corresponding to the second target data index range; and controlling the B-tree corresponding to the second target data index range to be in a locked state according to the lock flag.
[0015] In a fourth aspect, an embodiment of the present invention further provides a data processing device, comprising: a first acquisition unit, used to acquire a preset index range, wherein the preset index range is a preset range interval of index key values for indexing data in a database; a division unit, used to divide the preset index range into multiple data index ranges, and construct a corresponding B-tree for each of the data index ranges; an operation execution unit, used to perform specified data operations on the data based on each of the data index ranges and the B-tree corresponding to each of the data index ranges.
[0016] In the fifth aspect, an embodiment of the present invention also provides a data processing device, including: a second acquisition unit, used to acquire a data index key value of the data to be read; a first determination unit, used to determine a first target data index range in multiple data index ranges based on the data index key value, wherein each data index range contains the data index key value of each data in the database; each data index range corresponds to a B-tree; a second determination unit, used to determine the storage location of the data to be read in the database based on the first target data index range and its corresponding first target B-tree, and read the data to be read according to the storage location.
[0017] In the sixth aspect, an embodiment of the present invention also provides a data processing device, comprising: a third acquisition unit, used to acquire the data index key value of the data to be updated; a third determination unit, used to determine the second target data index range to which the data to be updated belongs in multiple data index ranges according to the data index key value, wherein each data index range contains the data index key value of each data in the database; each data index range corresponds to a B-tree; a construction unit, used to construct a second target B-tree node on the B-tree corresponding to the second target data index range; and an update unit, used to update the data to be updated according to the index key value of the second target B-tree node and the storage location corresponding to the second target B-tree node.
[0018] In the seventh aspect, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method described in any one of the first aspect, the second aspect, or the third aspect is implemented.
[0019] In an eighth aspect, an embodiment of the present invention further provides a computer-readable medium having a non-volatile program code executable by a processor, wherein the program code enables the processor to execute any one of the methods described in the first aspect, the second aspect, or the third aspect.
[0020] In an embodiment of the present invention, first, a preset index range is obtained, wherein the preset index range is a range interval of index key values pre-set to index data in a database; the preset index range is divided into multiple data index ranges, and a corresponding B-tree is constructed for each data index range; and a specified data operation is performed on the data based on each data index range and the B-tree corresponding to each data index range. It can be seen from the above description that after the preset index range is divided into multiple data index ranges, when performing a specified data operation on the data in the database, it can be performed in partitions and concurrently, which improves the efficiency of data processing, saves data processing time, and alleviates the technical problems of low efficiency and serious time consumption of existing data processing methods.
[0021] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0022] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 A flowchart of a data processing method provided by an embodiment of the present invention;
[0025] Figure 2 A schematic diagram of a linked list provided in an embodiment of the present invention;
[0026] Figure 3 A flowchart of performing a specified data operation on data in a database provided by an embodiment of the present invention;
[0027] Figure 4 Another flowchart of performing a specified data operation on data in a database provided by an embodiment of the present invention;
[0028] Figure 5 A flowchart of another embodiment of the present invention for performing a specified data operation on data in a database;
[0029] Figure 6 A flowchart of a data processing method provided by an embodiment of the present invention;
[0030] Figure 7 A flowchart of a data processing method provided by an embodiment of the present invention;
[0031] Figure 8 A schematic diagram of a data processing device provided by an embodiment of the present invention;
[0032] Fig. 9 A schematic diagram of another data processing device provided by an embodiment of the present invention;
[0033] Fig.10 A schematic diagram of another data processing device provided by an embodiment of the present invention;
[0034] Fig.11 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0036] Embodiment 1:
[0037] According to an embodiment of the present invention, an embodiment of a data processing method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0038] Figure 1 is a flow chart of a data processing method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:
[0039] Step S102: obtaining a preset index range, wherein the preset index range is a preset range interval of index key values for indexing data in a database.
[0040] In the present application, the preset index range may be a user-defined range of index key values for indexing data in a database.
[0041] For ease of understanding, refer to Figure 2 , the data processing method of the present invention is introduced:
[0042] exist Figure 2 In the embodiment, the range from 0 to 10099 is the preset index range. Of course, the embodiment of the present invention does not specifically limit the above preset index range.
[0043] Step S104: divide the preset index range into multiple data index ranges, and construct a corresponding B-tree for each data index range.
[0044] After obtaining the preset index range, the preset index range is further divided into multiple data index ranges. When dividing the data index range, the preset range division interval is first obtained, and then the preset index range is divided into multiple data index ranges according to the preset range division interval, wherein the multiple data index ranges can form a target linked list.
[0045] It should be noted that the above-mentioned preset range division interval can be one or more. When the above-mentioned preset range division interval is multiple, the index range to be divided corresponding to each preset range division interval can be defined, and then the corresponding index range to be divided can be divided according to each preset range division interval. When the preset range division interval is one, the range sizes of the data index ranges obtained by division are equal; when the preset range division interval is multiple, the range sizes of the data index ranges obtained by division according to the same preset range division interval are equal, and the range sizes of the data index ranges obtained by division according to different preset range division intervals are different.
[0046] like Figure 2 As shown, the preset range division interval is 100, and the data index ranges obtained by the final division include: 0-99, 100-199, 200-299, 300-399, ..., 10000-10099, and then a target linked list consisting of multiple data index ranges is obtained. Among them, each data index range of the target linked list includes a data domain and a pointer domain, the data in the data domain is used to represent the index range, and the pointer domain includes two pointers, one of which points to the B-tree corresponding to the data index range (the pointer can be called a B-tree pointer), and the other pointer points to the next node in the target linked list.
[0047] Step S106: performing a specified data operation on the data based on each data index range and the B-tree corresponding to each data index range.
[0048] After obtaining multiple data index ranges, the specified data operation can be performed on the data in the database based on each data index range and the B-tree corresponding to each data index range. When performing the above specified data operation, it can be performed concurrently in partitions. For example, when performing specified data operations for 1,000 data index ranges, the corresponding data index ranges are different, so the specified data operation can be performed on the data in the 1,000 data index ranges at the same time, which improves the efficiency of data processing and saves data processing time.
[0049] In an embodiment of the present invention, first, a preset index range is obtained, wherein the preset index range is a range interval of index key values pre-set to index data in a database; the preset index range is divided into multiple data index ranges, and a corresponding B-tree is constructed for each data index range; and a specified data operation is performed on the data based on each data index range and the B-tree corresponding to each data index range. It can be seen from the above description that after the preset index range is divided into multiple data index ranges, when performing a specified data operation on the data in the database, it can be performed in partitions and concurrently, which improves the efficiency of data processing, saves data processing time, and alleviates the technical problems of low efficiency and serious time consumption of existing data processing methods.
[0050] The above content briefly introduces the data processing method of the present invention, and the specific contents involved therein are described in detail below.
[0051] In an optional embodiment of the present application, reference Figure 3 The above step S106, performing a specified data operation on the data based on each data index range and the B-tree corresponding to each data index range, includes the following steps:
[0052] Step S301, when the designated data operation is a data update operation, determining a data index key value of the data to be updated, and obtaining a first data index key value;
[0053] Step S302, determining the data index range to which the data index key value of the data to be updated belongs from among multiple data index ranges;
[0054] Step S303, constructing a first target B-tree node on the B-tree corresponding to the data index range to which the data index key value of the data to be updated belongs;
[0055] Step S304: update the data to be updated according to the index key value of the first target B-tree node and the storage location corresponding to the first target B-tree node.
[0056] The following is a specific example to illustrate the data update process:
[0057] If the data index key value of the data to be updated is 201, the data index range to which the data index key value 201 belongs can be determined according to the multiple data index ranges obtained by dividing the preset range into intervals. Figure 2The data index range of 200 to 299 in the data index range of 200 to 299 is then used to establish a corresponding B-tree node (i.e., the first target B-tree node) on the B-tree corresponding to the data index range of 200 to 299, that is, insert the corresponding node into the B-tree according to the B-tree construction principle. After the first target B-tree node is established, the data to be updated can be updated according to the data index key value of the first target B-tree node and the storage location corresponding to the first target B-tree node.
[0058] In another optional embodiment of the present application, reference Figure 4 The above step S106, performing the specified data operation on the data based on each data index range and the B-tree corresponding to each data index range, further includes the following steps:
[0059] Step S401, when the designated data operation is a data read operation, determining a data index key value of the data to be read;
[0060] Step S402, determining the data index range to which the data index key value of the data to be read belongs from among multiple data index ranges;
[0061] Step S403, determining the B-tree corresponding to the data index range to which the data index key value of the data to be read belongs;
[0062] Step S404, traverse and search the B-tree corresponding to the data index range to which the data index key value of the data to be read belongs, obtain the storage location of the data to be read in the database, and read the data to be read according to the storage location.
[0063] The following is a specific example to illustrate the process of data query:
[0064] If the data index key value of the data to be read is 201, the data index range to which the data index key value 201 belongs can be determined as follows: Figure 2 The data index range of 200 to 299 in the data index range is then traversed and searched for the B-tree corresponding to the data index range of 200 to 299 to obtain the storage location of the to-be-read data in the database, and read the to-be-read data stored in the storage location.
[0065] In another optional embodiment of the present application, reference Figure 5 Before performing a specified data operation on the data based on each data index range and the B-tree corresponding to each data index range, the method further includes the following steps:
[0066] Step S501, determining the target data index range corresponding to the specified data operation;
[0067] Specifically, firstly, multiple data index ranges are obtained according to the preset range division interval, then the data index key value corresponding to the specified data operation is determined, and then the target data index range to which the data index key value belongs is determined in the multiple data index ranges, and the target data index range is the target data index range corresponding to the specified data operation. Figure 2 As shown, if the preset range division interval is 100, the multiple data index ranges obtained are 0-99, 100-199, 200-299, 300-399, ..., 10000-10099. If the data index key value corresponding to the specified data operation is 201, then it can be determined that the target data index range to which 201 belongs is 200-299, that is, the target data index range corresponding to the specified data operation is a data index range of 200-299.
[0068] Step S502, controlling the B-tree corresponding to the target data index range to be in a locked state;
[0069] Specifically, a lock flag may be set for the B-tree corresponding to the target data index range, wherein the lock flag is used to indicate that the B-tree corresponding to the target data index range is in a locked state; and then the B-tree corresponding to the target data index range is controlled to be in a locked state according to the lock flag.
[0070] When the B-tree corresponding to the target data index range is in a locked state, a specified data operation can be performed on the data in the database based on the target data index range and the B-tree corresponding thereto.
[0071] If the specified data operation is a data update operation, then a corresponding B-tree node is constructed on the target B-tree (i.e., the B-tree corresponding to the target data index range); if the specified data operation is a data read operation, then the target B-tree (i.e., the B-tree corresponding to the target data index range) is traversed and searched to obtain the storage location of the data to be read in the database, and the data to be read is read according to the storage location.
[0072] It can be seen from the above process of executing the specified data operation that when processing data, only the B-tree corresponding to the target data index range is controlled to be in a locked state, and it is not necessary to make the B-trees corresponding to all data index ranges in a locked state. In this way, when multiple parallel target data index ranges are different, corresponding operations can be performed on multiple corresponding B-trees concurrently without conflicts, thereby improving the efficiency of data processing.
[0073] The data processing method of the present invention has the following advantages: the B-trees corresponding to different data index ranges can be operated simultaneously, the data corresponding to different partitions can be processed concurrently, and the data processing efficiency is improved; the height of the B-tree is reduced, the number of queries is reduced, and useless disk queries are avoided, thereby reducing the number of IO queries.
[0074] Embodiment 2:
[0075] Figure 6 is a flow chart of a data processing method according to an embodiment of the present invention. Figure 6 As shown, the method comprises the following steps:
[0076] Step S602, obtaining the data index key value of the data to be read;
[0077] Step S604, determining a first target data index range in a plurality of data index ranges according to the data index key value, wherein each data index range contains the data index key value of each data in the database; and each data index range corresponds to a B-tree.
[0078] refer to Figure 2 , Figure 2 The first line of is a target linked list, which contains the multiple data index ranges described above. If the data index key value is 201, then it can be determined that the first target data index range to which the data index key value 201 belongs in the target linked list is Figure 2 The data index range is 200 to 299.
[0079] Step S606: determine the storage location of the to-be-read data in the database based on the first target data index range and its corresponding first target B-tree, and read the to-be-read data according to the storage location.
[0080] In an optional implementation, if each data index range corresponds to a B-tree pointer, then determining the storage location of the to-be-read data in the database based on the first target data index range and its corresponding first target B-tree includes the following process:
[0081] Determine a first target B-tree according to a B-tree pointer of a first target data index range; and determine a storage location of the to-be-read data in a database based on the first target B-tree.
[0082] Before determining the storage location of the to-be-read data in the database based on the first target B-tree, a lock flag may be set for the first target B-tree, and the first target B-tree may be controlled to be in a locked state according to the lock flag.
[0083] In the data processing method of the present invention, when the data index key values of the data to be read are in different data index ranges, the data reading process can be executed in parallel, thereby improving the efficiency of data reading.
[0084] Embodiment three:
[0085] Figure 7 is a flow chart of a data processing method according to an embodiment of the present invention. Figure 7 As shown, the method comprises the following steps:
[0086] Step S702, obtaining the data index key value of the data to be updated;
[0087] Step S704, determining a second target data index range to which the to-be-updated data belongs in a plurality of data index ranges according to the data index key value, wherein each data index range contains the data index key value of each data in the database; and each data index range corresponds to a B-tree.
[0088] refer to Figure 2 , Figure 2 The first line of the target linked list contains the multiple data index ranges described above. If the data index key value is 201, then it can be determined that the second target data index range of the data index key value 201 in the target linked list is Figure 2 The data index range is 200 to 299.
[0089] Step S706, constructing a second target B-tree node on the B-tree corresponding to the second target data index range; specifically, when constructing the second target B-tree node on the B-tree corresponding to the second target data index range, the index key value of the second target B-tree node can be set to the data index key value of the data to be updated, and the storage location corresponding to the second target B-tree node can be set to the storage location of the data to be updated in the database, so as to implement the data update operation on the data to be updated.
[0090] Step S708: Update the data to be updated according to the index key value of the second target B-tree node and the storage location corresponding to the second target B-tree node.
[0091] Each data index range corresponds to a B-tree pointer. Specifically, the B-tree corresponding to the second target data index range can be determined according to the B-tree pointer of the second target data index range.
[0092] In an optional embodiment of the present application, before constructing the second target B-tree node on the B-tree corresponding to the second target data index range, the method also includes: setting a lock flag for the B-tree corresponding to the second target data index range; and controlling the B-tree corresponding to the second target data index range to be in a locked state according to the lock flag.
[0093] Specifically, in the present application, a lock flag may be set for the B-tree corresponding to the second target data index range, wherein the lock flag is used to indicate that the B-tree corresponding to the second target data index range is in a locked state. Then, when in the locked state, a second target B-tree node is constructed on the B-tree corresponding to the second target data index range.
[0094] In the data processing method of the present invention, when the data index key values of the data to be updated are in different data index ranges, the data updating process can be executed in parallel, thereby improving the efficiency of the data updating.
[0095] Embodiment 4:
[0096] An embodiment of the present invention further provides a data processing device, which is mainly used to execute the data processing method provided in the above-mentioned embodiment 1 of the present invention. The data processing device provided in the embodiment of the present invention is specifically introduced below.
[0097] Figure 8 is a schematic diagram of a data processing device according to an embodiment of the present invention. Figure 8 As shown, the data processing device mainly includes: a first acquisition unit 81, a division unit 82 and an operation execution unit 83, wherein:
[0098] A first acquisition unit 81 is used to acquire a preset index range, wherein the preset index range is a preset range interval of index key values for indexing data in a database;
[0099] A division unit 82, configured to divide the preset index range into a plurality of data index ranges, and construct a corresponding B-tree for each of the data index ranges;
[0100] The operation execution unit 83 is used to execute a specified data operation on the data based on each of the data index ranges and the B-tree corresponding to each of the data index ranges.
[0101] In an embodiment of the present invention, first, a preset index range is obtained, wherein the preset index range is a range interval of index key values pre-set to index data in a database; the preset index range is divided into multiple data index ranges, and a corresponding B-tree is constructed for each data index range; and a specified data operation is performed on the data based on each data index range and the B-tree corresponding to each data index range. It can be seen from the above description that after the preset index range is divided into multiple data index ranges, when performing a specified data operation on the data in the database, it can be performed in partitions and concurrently, which improves the efficiency of data processing, saves data processing time, and alleviates the technical problems of low efficiency and serious time consumption of existing data processing methods.
[0102] Optionally, the operation execution unit 83 is also used to: when the designated data operation is a data update operation, determine the data index key value of the data to be updated; determine the data index range to which the data index key value of the data to be updated belongs in the multiple data index ranges; construct a first target B-tree node on the B-tree corresponding to the data index range to which the data index key value of the data to be updated belongs; and update the data to be updated according to the index key value of the first target B-tree node and the storage location corresponding to the target B-tree node.
[0103] Optionally, the operation execution unit 83 is also used to: when the designated data operation is a data reading operation, determine the data index key value of the data to be read; determine the data index range to which the data index key value of the data to be read belongs in the multiple data index ranges; determine the B-tree corresponding to the data index range to which the data index key value of the data to be read belongs; traverse and search the B-tree corresponding to the data index range to which the data index key value of the data to be read belongs, obtain the storage location of the data to be read in the database, and read the data to be read according to the storage location.
[0104] Optionally, the device is also used to: before performing a specified data operation on data based on each of the data index ranges and the B-tree corresponding to each of the data index ranges, determine a target data index range corresponding to the specified data operation; and control the B-tree corresponding to the target data index range to be in a locked state.
[0105] Optionally, the operation execution unit is further used to: set a lock mark for the B-tree corresponding to the target data index range; and control the B-tree corresponding to the target data index range to be in a locked state according to the lock mark.
[0106] Embodiment five:
[0107] The embodiment of the present invention further provides a data processing device, which is mainly used to execute the data processing method provided in the above-mentioned embodiment 2 of the present invention. The data processing device provided in the embodiment of the present invention is specifically introduced below.
[0108] Fig. 9 is a schematic diagram of a data processing device according to an embodiment of the present invention. Fig. 9 As shown, the data processing device mainly includes: a second acquisition unit 91, a first determination unit 92 and a second determination unit 93, wherein:
[0109] A second acquisition unit 91 is used to acquire a data index key value of the data to be read;
[0110] A first determining unit 92, configured to determine a first target data index range in a plurality of data index ranges according to the data index key value, wherein each data index range includes a data index key value of each data in the database; and each data index range corresponds to a B-tree;
[0111] The second determining unit 93 is used to determine the storage location of the to-be-read data in the database based on the first target data index range and its corresponding first target B-tree, and read the to-be-read data according to the storage location.
[0112] Optionally, each data index range corresponds to a B-tree pointer; the second determination unit 93 is further used to: determine the first target B-tree according to the B-tree pointer of the first target data index range; and determine the storage location of the data to be read in the database based on the first target B-tree.
[0113] Optionally, the device is further used to: before determining the storage location of the to-be-read data in the database based on the first target B-tree, set a lock mark for the first target B-tree; and control the first target B-tree to be in a locked state according to the lock mark.
[0114] In the data processing device of the present invention, when the data index key values of the data to be read are in different data index ranges, the data reading process can be executed in parallel, thereby improving the efficiency of data reading.
[0115] Embodiment six:
[0116] The embodiment of the present invention further provides a data processing device, which is mainly used to execute the data processing method provided in the above-mentioned embodiment 3 of the present invention. The data processing device provided in the embodiment of the present invention is specifically introduced below.
[0117] Fig.10 is a schematic diagram of a data processing device according to an embodiment of the present invention. Fig.10 As shown, the data processing device mainly includes: a third acquisition unit 101, a third determination unit 102, a construction unit 103 and an update unit 104, wherein:
[0118] The third acquisition unit 101 is used to acquire the data index key value of the data to be updated;
[0119] A third determining unit 102 is used to determine a second target data index range to which the to-be-updated data belongs in a plurality of data index ranges according to the data index key value, wherein each data index range includes the data index key value of each data in the database; and each data index range corresponds to a B-tree;
[0120] A construction unit 103 is used to construct a second target B-tree node on the B-tree corresponding to the second target data index range;
[0121] The updating unit 104 is used to update the to-be-updated data according to the index key value of the second target B-tree node and the storage location corresponding to the second target B-tree node.
[0122] Optionally, the device is also used to: before constructing the second target B-tree node on the B-tree corresponding to the second target data index range, set a lock flag for the B-tree corresponding to the second target data index range; and control the B-tree corresponding to the second target data index range to be in a locked state according to the lock flag.
[0123] In the data processing device of the present invention, when the data index key values of the data to be updated are in different data index ranges, the data updating process can be executed in parallel, thereby improving the efficiency of the data updating.
[0124] Embodiment seven:
[0125] See also Fig.11 An embodiment of the present invention further provides an electronic device 100, including: a processor 110, a memory 111, a bus 112 and a communication interface 113, the processor 110, the communication interface 113 and the memory 111 are connected via the bus 112; the processor 110 is used to execute an executable module stored in the memory 111, such as a computer program.
[0126] The memory 111 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 113 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.
[0127] The bus 112 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.11 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0128] Among them, the memory 111 is used to store programs, and the processor 110 executes the program after receiving the execution instruction. The method executed by the device for flow process definition disclosed in any of the embodiments of the present invention can be applied to the processor 110 or implemented by the processor 110.
[0129] The processor 110 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 110. The above processor 110 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 111, and the processor 110 reads the information in the memory 111 and completes the steps of the above method in combination with its hardware.
[0130] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0131] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0132] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0133] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0134] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0135] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0136] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0137] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A data processing method, characterized in that: include: Obtaining a preset index range, wherein the preset index range is a preset range interval of index key values for indexing data in a database; Divide the preset index range into multiple data index ranges, and construct a corresponding B-tree for each data index range; Performing a specified data operation on the data based on each of the data index ranges and the B-tree corresponding to each of the data index ranges; The dividing the preset index range into a plurality of data index ranges comprises: Obtain a preset range partition interval, and divide the preset index range into a plurality of data index ranges according to the preset range partition interval, wherein the preset range partition interval is one or more, and the plurality of data index ranges constitute a target linked list, and each data index range of the target linked list comprises a data domain and a pointer domain, the data in the data domain is used to characterize the index range, and the pointer domain comprises two pointers, wherein one B-tree pointer points to the B-tree corresponding to the data index range, and the other pointer points to the next node in the target linked list.
2. The method according to claim 1, characterized in that Performing a specified data operation on the data based on each of the data index ranges and the B-tree corresponding to each of the data index ranges includes: When the designated data operation is a data update operation, determining a data index key value of the data to be updated; Determine, from among the multiple data index ranges, a data index range to which the data index key value of the data to be updated belongs; Constructing a first target B-tree node on the B-tree corresponding to the data index range to which the data index key value of the data to be updated belongs; The to-be-updated data is updated according to the index key value of the first target B-tree node and the storage location corresponding to the first target B-tree node.
3. The method according to claim 1, characterized in that Performing a specified data operation on the data based on each of the data index ranges and the B-tree corresponding to each of the data index ranges also includes: When the designated data operation is a data read operation, determining a data index key value of the data to be read; Determine, from among the multiple data index ranges, a data index range to which the data index key value of the data to be read belongs; Determine the B-tree corresponding to the data index range to which the data index key value of the data to be read belongs; The B-tree corresponding to the data index range to which the data index key value of the data to be read belongs is traversed and searched to obtain the storage location of the data to be read in the database, and the data to be read is read according to the storage location.
4. The method according to any one of claims 1 to 3, characterized in that Before performing a specified data operation on the data based on each of the data index ranges and the B-tree corresponding to each of the data index ranges, the method further includes: Determine the target data index range corresponding to the specified data operation; The B-tree corresponding to the target data index range is controlled to be in a locked state.
5. The method according to claim 4, characterized in that Controlling the B-tree corresponding to the target data index range to be in a locked state includes: Setting a lock flag for the B-tree corresponding to the target data index range; The B-tree corresponding to the target data index range is controlled to be in a locked state according to the locking identifier.
6. A data processing method, characterized in that: include: Get the data index key value of the data to be read; Determine a first target data index range in a plurality of data index ranges according to the data index key value, wherein each data index range includes the data index key value of each data in the database; each data index range corresponds to a B-tree; the plurality of data index ranges are obtained by dividing the preset index range according to the obtained preset range division intervals, the preset range division intervals are one or more, and the plurality of data index ranges form a target linked list, each data index range of the target linked list includes a data domain and a pointer domain, the data in the data domain is used to characterize the index range, the pointer domain includes two pointers, one of the B-tree pointers points to the B-tree corresponding to the data index range, and the other pointer points to the next node in the target linked list; The storage location of the to-be-read data in the database is determined based on the first target data index range and its corresponding first target B-tree, and the to-be-read data is read according to the storage location.
7. The method according to claim 6, characterized in that Each data index range corresponds to a B-tree pointer; Determining the storage location of the to-be-read data in the database based on the first target data index range and its corresponding first target B-tree includes: Determine the first target B-tree according to the B-tree pointer of the first target data index range; The storage location of the to-be-read data in the database is determined based on the first target B-tree.
8. The method according to claim 7, characterized in that Before determining the storage location of the to-be-read data in the database based on the first target B-tree, the method further includes: Setting a lock flag for the first target B-tree; The first target B-tree is controlled to be in a locked state according to the locking identifier.
9. A data processing method, characterized in that: include: Get the data index key value of the data to be updated; Determine a second target data index range to which the data to be updated belongs in a plurality of data index ranges according to the data index key value, wherein each data index range includes the data index key value of each data in the database; each data index range corresponds to a B-tree; the plurality of data index ranges are obtained by dividing the preset index range according to the obtained preset range division intervals, the preset range division intervals are one or more, and the plurality of data index ranges form a target linked list, each data index range of the target linked list includes a data domain and a pointer domain, the data in the data domain is used to characterize the index range, and the pointer domain includes two pointers, wherein one B-tree pointer points to the B-tree corresponding to the data index range, and the other pointer points to the next node in the target linked list; Constructing a second target B-tree node on the B-tree corresponding to the second target data index range; The to-be-updated data is updated according to the index key value of the second target B-tree node and the storage location corresponding to the second target B-tree node.
10. The method according to claim 9, characterized in that Before constructing a second target B-tree node on the B-tree corresponding to the second target data index range, the method further includes: Setting a lock flag for the B-tree corresponding to the second target data index range; The B-tree corresponding to the second target data index range is controlled to be in a locked state according to the locking identifier.
11. A data processing device, characterized in that: include: A first acquisition unit is used to acquire a preset index range, wherein the preset index range is a preset range interval of index key values for indexing data in a database; A division unit, used for dividing the preset index range into a plurality of data index ranges, and constructing a corresponding B-tree for each of the data index ranges; An operation execution unit, configured to execute a specified data operation on the data based on each of the data index ranges and the B-tree corresponding to each of the data index ranges; The partitioning unit is specifically used to: obtain a preset range partitioning interval, and divide the preset index range into multiple data index ranges according to the preset range partitioning interval, wherein the preset range partitioning interval is one or more, and multiple data index ranges constitute a target linked list, each data index range of the target linked list includes a data domain and a pointer domain, the data in the data domain is used to characterize the index range, and the pointer domain includes two pointers, one of which is a B-tree pointer pointing to the B-tree corresponding to the data index range, and the other pointer points to the next node in the target linked list.
12. A data processing device, characterized in that: include: A second acquisition unit, used to acquire a data index key value of the data to be read; A first determination unit is used to determine a first target data index range in a plurality of data index ranges according to the data index key value, wherein each data index range includes the data index key value of each data in the database; each data index range corresponds to a B-tree; the plurality of data index ranges are obtained by dividing the preset index range according to the obtained preset range division interval, the preset range division interval is one or more, and the plurality of data index ranges form a target linked list, each data index range of the target linked list includes a data domain and a pointer domain, the data in the data domain is used to characterize the index range, and the pointer domain includes two pointers, one of which is a B-tree pointer pointing to the B-tree corresponding to the data index range, and the other pointer points to the next node in the target linked list; The second determining unit is used to determine the storage location of the to-be-read data in the database based on the first target data index range and its corresponding first target B-tree, and read the to-be-read data according to the storage location.
13. A data processing device, characterized in that: include: A third acquisition unit is used to acquire a data index key value of the data to be updated; A third determination unit is used to determine, according to the data index key value, a second target data index range to which the to-be-updated data belongs in a plurality of data index ranges, wherein each data index range includes the data index key value of each data in the database; each data index range corresponds to a B-tree; the plurality of data index ranges are obtained by dividing the preset index range according to the obtained preset range division intervals, the preset range division intervals are one or more, and the plurality of data index ranges form a target linked list, each data index range of the target linked list includes a data domain and a pointer domain, the data in the data domain is used to characterize the index range, and the pointer domain includes two pointers, wherein one B-tree pointer points to the B-tree corresponding to the data index range, and the other pointer points to the next node in the target linked list; A construction unit, configured to construct a second target B-tree node on the B-tree corresponding to the second target data index range; An updating unit is used to update the to-be-updated data according to the index key value of the second target B-tree node and the storage position corresponding to the second target B-tree node.
14. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the data processing method described in any one of claims 1 to 10 is implemented.
15. A computer readable medium having a non-volatile program code executable by a processor, characterized in that: The program code enables the processor to execute the data processing method according to any one of claims 1 to 10.
