Data processing method, device, electronic device and computer readable medium
By hash partitioning the database data and setting up a B-tree for each partition, the problem of low operating efficiency of B-tree indexes in the existing technology is solved, and data processing efficiency improvement and resource saving under high concurrency are achieved.
Patent Information
- Application Number
- CN202010728918.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-24
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2040-07-24
AI Technical Summary
Under high concurrency conditions in existing databases, B-tree index operation efficiency is low and resources are wasted. Especially when processing massive data, query operations of multiple data processing threads lead to frequent disk IO, affecting performance.
Hash partitioning technology is used to hash partition the index information of the data in the database, and set up a B-tree for each hash partition to achieve parallel processing and updating of data and reduce useless disk queries.
It improves the efficiency of data operations, reduces the time-consuming disk IO, alleviates the problem of low index operation efficiency, supports multiple users to perform data writing and query operations at the same time, and improves the concurrent processing capabilities of the database.
Smart Images

Figure CN111858607B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of databases, and in particular to a data processing method, device, electronic device and computer-readable medium. Background Art
[0002] In existing databases, due to the large amount of data, the database stores a massive amount of data. In many databases, the number of rows of data in a single table reaches tens of millions or even hundreds of millions. A table in the database that stores hundreds of millions of data has a huge amount of data. However, the database also needs to provide data query, update and other functions for applications. In the existing data query method, B-tree or B+ tree can be used.
[0003] For example, for a data processing thread, in a data table with more than 100 million or 10 million data, the B-tree can perform binary search more than 30 times. Although the number of single searches is not large, if multiple data processing threads initiate data processing operations at the same time, the number of queries will be magnified several times. If the number of data processing threads is 2000, the number of queries is 30*2000, which is magnified 2000 times. In a high concurrency state, the B-tree also involves disk reading during the search process. Disk IO is very time-consuming, and binary search involves many unnecessary disk queries. Summary of the invention
[0004] In view of this, an object of the present invention is to provide a data processing method, device, electronic device and computer-readable medium to alleviate the technical problems of low efficiency and waste of resources in existing database index operations.
[0005] In the first aspect, an embodiment of the present invention provides a data processing method, including: obtaining a plurality of pre-set target index information for indexing data in a database; performing a hash partitioning operation on the plurality of target index information to obtain at least one target hash partition; wherein each target hash partition contains a hash value of the corresponding target index information; setting a corresponding B-tree for each target hash partition in the at least one target hash partition; and performing target data operations on the data in the database based on each of the target hash partitions and its corresponding B-tree.
[0006] Furthermore, performing a hash partitioning operation on the multiple target index information to obtain at least one target hash partition includes: calculating a hash value of each of the target index information to obtain multiple target hash values; obtaining at least one pre-set initial hash partition; determining the initial hash partition to which each of the target hash values belongs to obtain at least one target hash partition.
[0007] Furthermore, determining the initial hash partition to which each of the target hash values belongs includes: obtaining the number of the at least one initial hash partition to obtain a target number; performing a remainder calculation on each of the target hash values based on the target number to obtain a first calculation result; and determining the initial hash partition to which each of the target hash values belongs based on the first calculation result.
[0008] Furthermore, each initial hash partition contains corresponding sequential marking information; determining the initial hash partition to which each target hash value belongs based on the first calculation result includes: determining the target sequential marking information that is the same as each first calculation result in at least one sequential marking information, and determining the initial hash partition corresponding to the target sequential marking information as the initial hash partition to which each target hash value belongs.
[0009] Furthermore, performing a target data operation on the data in the database based on each of the target hash partitions and its corresponding B-tree includes: when the target data operation is a data write operation, determining data index information of the data to be written, calculating a hash value of the data index information of the data to be written, and obtaining a first hash value; determining the hash partition to which the first hash value belongs in the at least one target hash partition, and obtaining a first hash partition; and establishing a corresponding B-tree node on the B-tree corresponding to the first hash partition, wherein the B-tree node includes at least one of the data index information of the data to be written and storage location information of the data to be written in the database.
[0010] Furthermore, determining the hash partition to which the first hash value belongs in the at least one target hash partition to obtain the first hash partition includes: performing a remainder calculation on the first hash value based on the number of the at least one target hash partition to obtain a second calculation result; and determining the hash partition to which the first hash value belongs based on the second calculation result to obtain the first hash partition.
[0011] Furthermore, performing a target data operation on the data in the database based on each of the target hash partitions and its corresponding B-tree also includes: when the target data operation is a data query operation, determining the data index information of the data to be queried, calculating the hash value of the data index information of the data to be queried, and obtaining a second hash value; determining the hash partition to which the second hash value belongs in the at least one target hash partition, and obtaining a second hash partition; determining the B-tree corresponding to the second hash partition; traversing and searching the B-tree corresponding to the second hash partition to obtain the storage location of the data to be queried in the database, and reading the data to be queried according to the storage location.
[0012] Furthermore, determining the hash partition to which the second hash value belongs in the at least one target hash partition to obtain the second hash partition includes: performing a remainder calculation on the second hash value based on the number of the at least one target hash partition to obtain a third calculation result; determining the hash partition to which the second hash value belongs based on the third calculation result to obtain the second hash partition.
[0013] Furthermore, before performing a target data operation on the data in the database based on each of the target hash partitions and its corresponding B-tree, the method further includes: controlling the B-tree corresponding to the target hash partition corresponding to the target data operation to be in a locked state.
[0014] In the second aspect, an embodiment of the present invention also provides a data processing device, comprising: an acquisition unit, used to acquire a plurality of pre-set target index information for indexing data in a database; a partitioning unit, used to perform a hash partitioning operation on the plurality of target index information to obtain at least one target hash partition; wherein each target hash partition contains a hash value of the corresponding target index information; a construction unit, used to set a corresponding B-tree for each target hash partition in the at least one target hash partition; and an operation unit, used to perform target data operations on the data in the database based on each of the target hash partitions and its corresponding B-tree.
[0015] In a third 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 the processor implements the steps of the method described in the first aspect when executing the computer program.
[0016] In a fourth 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 the steps of the method described in the first aspect above.
[0017] In an embodiment of the present invention, first, a plurality of target index information for indexing data in a database is obtained in advance; then, a hash partitioning operation is performed on the plurality of target index information to obtain at least one target hash partition; wherein each target hash partition contains a hash value of the corresponding target index information; then, a corresponding B-tree is set for each target hash partition in at least one target hash partition; finally, target data operations are performed on the data in the database based on each target hash partition and its corresponding B-tree. In the present application, by performing hash partitioning on the target index information and setting a B-tree for each hash partition, it is possible to implement the execution on the B-tree corresponding to the corresponding target hash partition during the data update process, and to implement simultaneous updating of data in different target hash partitions, so as to solve the problem of traditional data serial indexing, thereby improving the efficiency of target data operations, and reducing useless disk queries, thereby alleviating the technical problems of low efficiency and waste of resources in existing database index operations.
[0018] 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.
[0019] 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
[0020] 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.
[0021] Figure 1 A flowchart of a data processing method provided by an embodiment of the present invention;
[0022] Figure 2 A flowchart of a method for determining a target hash partition provided by an embodiment of the present invention;
[0023] Figure 3 A schematic diagram of a data processing device provided by an embodiment of the present invention;
[0024] Figure 4 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0025] 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.
[0026] Embodiment 1:
[0027] 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.
[0028] 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:
[0029] Step S102: obtaining a plurality of preset target index information for indexing data in a database.
[0030] Specifically, in the present application, the target index information is index information preset by a user, and the index information is used to index data in a database.
[0031] Step S104, performing a hash partitioning operation on the multiple target index information to obtain at least one target hash partition; wherein each target hash partition contains a hash value of the corresponding target index information.
[0032] It should be noted that a hash partition can be understood as a hash bucket, each hash bucket corresponds to a hash value of target index information of data in the database, wherein a hash bucket can correspond to one or more hash values.
[0033] The above-mentioned target index information is applicable to the character index. The hash value corresponding to each target index information is calculated through the character index, and the corresponding hash partition is determined according to the hash value corresponding to the target index information data, thereby obtaining at least one target hash partition.
[0034] Step S106, setting a corresponding B-tree for each target hash partition in at least one target hash partition;
[0035] It should be noted that the B-tree is a self-balancing tree that can keep data in order. This data structure allows the actions of searching for data, sequential access, inserting data, and deleting data to be completed in logarithmic time. The B-tree contains multiple nodes, each of which contains the index information of the data and the storage location of the data in the database.
[0036] In the present application, a target hash linked list can be constructed based on at least one target hash partition. The target hash linked list is a linked list constructed based on the hash partition. For example, a corresponding data field and pointer field can be constructed in advance for each target hash partition, wherein the data field is used to store the hash value corresponding to the target hash partition, and the pointer field is used to determine the next "node" or "element". Among them, a B-tree pointer is set corresponding to at least one target hash partition to determine the B-tree corresponding to the at least one target hash partition.
[0037] Step S108, performing target data operations on the data in the database based on each target hash partition and its corresponding B-tree.
[0038] In an optional implementation of the present application, before performing a target data operation on data in a database based on each target hash partition and its corresponding B-tree, the B-tree corresponding to the target hash partition corresponding to the target data operation may be controlled to be in a locked state.
[0039] It should be noted that after determining the target hash partition corresponding to the target data operation, and before executing the target data operation on the data in the database based on each target hash partition and its corresponding B-tree, it is necessary to set a lock flag for the target hash partition corresponding to the target data operation so that the B-tree corresponding to the target hash partition corresponding to the target data operation is in a locked state. When the target hash partition corresponding to the target data operation is in a locked state, the target data operation is executed on the data in the database based on the target hash partition corresponding to the target data operation and its corresponding B-tree.
[0040] In an embodiment of the present invention, a plurality of target index information for indexing data in a database is obtained in advance; a hash partitioning operation is performed on the plurality of target index information to obtain at least one target hash partition; wherein each target hash partition contains a hash value of the corresponding target index information; a corresponding B-tree is set for each target hash partition in at least one target hash partition; and a target data operation is performed on the data in the database based on each target hash partition and its corresponding B-tree. In the present application, by performing hash partitioning on the target index information and setting a B-tree for each hash partition, it is possible to implement the execution on the B-tree corresponding to the corresponding target hash partition during the data update process, and to implement simultaneous updating of data in different target hash partitions, so as to solve the problem of traditional data serial indexing, thereby improving the efficiency of target data operations, and reducing useless disk queries, thereby alleviating the technical problems of low efficiency and waste of resources in existing database index operations.
[0041] Finally, it should be noted that since hash values cannot be sorted, the ranges of the B-trees corresponding to at least one target hash partition are different and there will be intersections. If sorting is required, secondary sorting is required.
[0042] In the embodiment of the present invention, Figure 2 As shown, step S104 includes the following steps:
[0043] Step S11, calculating the hash value of each target index information to obtain multiple target hash values;
[0044] Step S12, obtaining at least one preset initial hash partition;
[0045] Step S13, determining the initial hash partition to which each target hash value belongs, and obtaining at least one target hash partition.
[0046] In the embodiment of the present invention, firstly, a hash value of each target index information is calculated to obtain multiple target hash values.
[0047] Next, obtain at least one pre-set initial hash partition. It should be noted that the at least one initial hash partition corresponds to one or more hash values. For example, when the target number of at least one initial hash partition is 997 (that is, the hash linked list contains 997 initial hash partitions), the sequence mark information of the first initial hash partition is 1, and the hash value corresponding to hash partition 1 is the hash value of the target index information divided by 997, which has a remainder of 1. The hash value corresponding to the first initial hash partition can be 1, 998, 1995, ..., and other hash values. The method for determining the hash values corresponding to the remaining initial hash partitions and the hash value corresponding to the first initial hash partition is the same as the above process, and will not be repeated here.
[0048] After determining to calculate the target hash value of each target index information, determining the initial hash partition to which each target hash value belongs, and obtaining at least one target hash partition, comprises the following steps:
[0049] Step S31, obtaining the number of at least one initial hash partition to obtain a target number;
[0050] Step S32, performing remainder calculation on each target hash value based on the target quantity to obtain a first calculation result;
[0051] Step S33: Determine the initial hash partition to which each target hash value belongs based on the first calculation result.
[0052] In the embodiment of the present invention, after determining the number of at least one initial hash partition, a remainder calculation is performed on each target hash value and the target number to determine the remainder corresponding to each target hash value, and the remainder corresponding to each target hash value is determined as the first calculation result.
[0053] Then, the initial hash partition to which each target hash value belongs is determined according to the first calculation result.
[0054] For example, the target number of initial hash partitions is 997. Among multiple target index information, the target hash value of one target index information is 201. It is necessary to calculate 201 divided by 997, and the remainder is 201 (that is, the first calculation result is 201). Then it is determined that the initial hash partition to which the target hash value 201 belongs is the 201st initial hash partition.
[0055] It should be noted that, in an embodiment of the present invention, each initial hash partition contains corresponding sequential marking information. Therefore, when determining the initial hash partition to which each target hash value belongs based on the first calculation result, the target sequential marking information that is the same as the first calculation result can be determined from multiple sequential marking information, and the initial hash partition corresponding to the target sequential marking information is determined as the initial hash partition to which the target hash value belongs.
[0056] In the present application, the target data operation described in step S108 includes any of the following: a data writing operation, a data query operation.
[0057] Based on this, the target data operation being a data write operation and the target data operation being a data query operation will be described below respectively.
[0058] In the embodiment of the present invention, when the target data operation is a data write operation, step S108 includes the following steps:
[0059] Step S41, when the target data operation is a data writing operation, determining data index information of the data to be written, calculating a hash value of the data index information of the data to be written, and obtaining a first hash value;
[0060] Step S42, determining the hash partition to which the first hash value belongs in at least one target hash partition, to obtain a first hash partition;
[0061] Step S43, establishing a corresponding B-tree node on the B-tree corresponding to the first hash partition, wherein the B-tree node includes at least one of data index information of the data to be written and storage location information of the data to be written in the database.
[0062] In an embodiment of the present invention, when the target data operation is a data write operation, after acquiring the data to be written, the data index information of the data to be written is determined, and a hash value (ie, a first hash value) of the data index information of the data to be written is calculated.
[0063] Then, the hash partition to which the hash value of the data index information of the to-be-written data (ie, the first hash value) belongs is determined to obtain a first hash partition.
[0064] Specifically, when determining the hash partition to which the hash value of the data index information to be written belongs, the remainder of the first hash value divided by the number of at least one target hash partitions can be calculated to obtain a second calculation result, and the hash partition to which the remainder (that is, the second calculation result) belongs can be determined as the first hash partition.
[0065] For example, when the number of at least one target hash partition is 997, and the hash value of the data index information of the data to be written (i.e., the first hash value) is determined to be 201, 201 is divided by 997, and the remainder obtained is 201 (i.e., the second calculation result), then the hash partition to which 201 belongs is determined to be the first hash partition.
[0066] Finally, a B-tree node corresponding to the data to be written is established in the B-tree corresponding to the first hash partition, and the data index information of the data to be written and the storage location of the data to be written in the database are written into the B-tree node, thereby completing the writing operation of the data to be written.
[0067] In the prior art, when multiple users write data to a database, since each user needs to add a write lock to the B-tree in the database when writing data, the users need to be queued. After the current user completes writing data, the next user can write data.
[0068] In the present application, taking the example of 997 hash value partitions and 500 users, when the hash values of the data written by 500 users are in different partitions of the 997 hash value partitions, the 500 users can write 500 data into the database at the same time, thereby improving the data writing efficiency of the database. The present application supports 997 data writing operations in parallel at the same time.
[0069] In the embodiment of the present invention, when the target data operation is a data query operation, step S108 includes the following steps:
[0070] Step S51, when the target data operation is a data query operation, determining data index information of the data to be queried, calculating a hash value of the data index information of the data to be queried, and obtaining a second hash value;
[0071] Step S52, determining the target hash partition to which the second hash value belongs in at least one target hash partition, to obtain a second hash partition;
[0072] Step S53, determining the B-tree corresponding to the second hash partition;
[0073] Step S54, traverse and search the B-tree corresponding to the second hash partition to obtain the storage location of the data to be queried in the database, and read the data to be queried according to the storage location.
[0074] In the embodiment of the present invention, when the target data operation is a data query operation, first, data index information of the data to be queried is determined, and a hash value of the data index information of the data to be written is calculated to obtain a second hash value.
[0075] After obtaining the second hash value, a target hash partition to which the second hash value belongs in at least one target hash partition is determined, and the target hash partition is determined as the second hash partition.
[0076] In the present application, when determining the hash partition to which the second hash value belongs in at least one target hash partition and obtaining the second hash partition, the remainder of dividing the second hash value by the number of at least one target hash partition can be first calculated and used as the third calculation result.
[0077] Then, the hash partition to which the second hash value belongs is determined according to the third calculation result, thereby obtaining the second hash partition.
[0078] For example, when the number of at least one target hash partition is 997 and the second hash value is determined to be 101, 101 is divided by 997, and the remainder obtained is 101, and the hash partition to which 101 belongs is determined to be the second hash partition.
[0079] Finally, the B-tree corresponding to the second hash partition is traversed to obtain the storage location of the data to be queried in the database, and the data to be queried is read according to the storage location, thereby completing the query operation on the data to be queried.
[0080] In the prior art, a database contains a large amount of data, and therefore the B-tree of the database contains a large number of nodes. When a user queries the data in the database, it is necessary to traverse a large number of nodes before querying the data to be queried, resulting in a slow query speed, useless disk queries during the query process, and a large number of IO queries.
[0081] In the embodiment of the present invention, a large amount of data is partitioned according to its hash value, and each partition contains a part of the large amount of data. Therefore, the B-tree corresponding to each partition is reduced in height compared with the B-tree in the prior art. When querying data in a database, the hash value of the data to be queried is calculated to determine the hash value partition to which the data to be queried belongs, and the data to be queried is queried from the B-tree corresponding to the hash value partition, thereby reducing useless disk queries, reducing the number of IO queries, and improving the data query speed.
[0082] In addition, in the prior art, when multiple users query data in a database, since each user needs to add a write lock to the B-tree in the database when querying the data, the users need to be queued, and the next user can query only after the current user completes the query.
[0083] For example, in a database containing a table with a data volume of more than 100 million or 10 million, the B-tree takes more than 25 binary searches. Although the number of searches per time is not large, the number of queries will be magnified several times under high concurrency. If the concurrency is 1000, the number of queries will be 25*1000, which is magnified 1000 times. If the data is updated, a write lock is required to lock the entire B-tree. With 1000 concurrency, the traversal becomes serial, which seriously affects performance. The main disadvantage is that under high concurrency, the B-tree also involves disk reading during the search process, and disk IO is very time-consuming, and binary search involves many unnecessary disk queries.
[0084] In the present application, taking the number of target hash partitions as 997 and the number of users as 500 as an example, when the data to be queried by 500 users are respectively in different partitions of the 997 target hash partitions, the 500 users can query the B-trees corresponding to the 500 target hash partitions at the same time, thereby querying the data required by the 500 users. In theory, the present application supports 997 data query operations in parallel at the same time. Therefore, it can effectively improve the efficiency of multiple users in querying data on the database and reduce the time consumption of disk IO during queries.
[0085] Embodiment 2:
[0086] An embodiment of the present invention further provides a data processing device, which is mainly used to execute a data processing method provided in the first embodiment of the present invention. The data processing device provided in the embodiment of the present invention is specifically introduced below.
[0087] Figure 3 is a schematic diagram of a data processing device according to an embodiment of the present invention. Figure 3 As shown, the data processing device mainly includes the following units:
[0088] The acquisition unit 10 is used to acquire a plurality of preset target index information for indexing the data in the database;
[0089] A partitioning unit 20 is used to perform a hash partitioning operation on the multiple target index information to obtain at least one target hash partition; wherein each target hash partition contains a hash value of the corresponding target index information;
[0090] A construction unit 30, configured to set a corresponding B-tree for each target hash partition in the at least one target hash partition;
[0091] The operation unit 40 is used to perform a target data operation on the data in the database based on each of the target hash partitions and its corresponding B-tree.
[0092] In an embodiment of the present invention, a plurality of target index information for indexing data in a database is obtained in advance; a hash partitioning operation is performed on the plurality of target index information to obtain at least one target hash partition; wherein each target hash partition contains a hash value corresponding to the target index information; a corresponding B-tree is set for each target hash partition in at least one target hash partition; and a target data operation is performed on the data in the database based on each target hash partition and its corresponding B-tree. In the present application, by performing hash partitioning on the target index information and setting a B-tree for each hash partition, it is possible to implement the execution on the B-tree corresponding to the corresponding target Hash partition during the data update process, and to implement simultaneous updating of data in different target hash partitions, so as to solve the problem of traditional data serial indexing, thereby improving the efficiency of target data operations, and reducing useless disk queries, thereby alleviating the technical problems of low efficiency and waste of resources in existing database index operations.
[0093] Optionally, the partitioning unit is used to: calculate the hash value of each target index information to obtain multiple target hash values; obtain at least one preset initial hash partition; determine the initial hash partition to which each target hash value belongs to, and obtain at least one target hash partition.
[0094] Optionally, the partitioning unit is further used to: obtain the number of the at least one initial hash partition to obtain a target number; perform remainder calculation on each target hash value based on the target number to obtain a first calculation result; and determine the initial hash partition to which each target hash value belongs based on the first calculation result.
[0095] Optionally, each initial hash partition contains corresponding sequential marking information, and the partitioning unit is also used to: determine the target sequential marking information that is the same as each first calculation result in at least one sequential marking information, and determine the initial hash partition corresponding to the target sequential marking information as the initial hash partition to which each target hash value belongs.
[0096] Optionally, the first operation unit is used to: when the target data operation is a data write operation, determine the data index information of the data to be written, calculate the hash value of the data index information of the data to be written, and obtain a first hash value; determine the hash partition to which the first hash value belongs in the at least one target hash partition, and obtain the first hash partition; establish a corresponding B-tree node on the B-tree corresponding to the first hash partition, wherein the B-tree node includes at least one of the data index information of the data to be written and the storage location information of the data to be written in the database.
[0097] Optionally, the first operation unit is further used to: perform a remainder calculation on the first hash value based on the number of the at least one target hash partition to obtain a second calculation result; determine the hash partition to which the first hash value belongs based on the second calculation result to obtain the first hash partition.
[0098] Optionally, the first operation unit is also used to: when the target data operation is a data query operation, determine the data index information of the data to be queried, calculate the hash value of the data index information of the data to be queried, and obtain a second hash value; determine the hash partition to which the second hash value belongs in the at least one target hash partition to obtain a second hash partition; determine the B-tree corresponding to the second hash partition; traverse the B-tree corresponding to the second hash partition to obtain the storage location of the data to be queried in the database, and read the data to be queried according to the storage location.
[0099] Optionally, the first operation unit is further used to: perform a remainder calculation on the second hash value based on the number of the at least one target hash partition to obtain a third calculation result; determine the hash partition to which the second hash value belongs based on the third calculation result to obtain a second hash partition.
[0100] Optionally, the first operation unit is further used to: before performing a target data operation on the data in the database based on each of the target hash partitions and its corresponding B-tree, control the B-tree corresponding to the target hash partition corresponding to the target data operation to be in a locked state.
[0101] The data processing device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment 1. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0102] Embodiment three:
[0103] An embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first embodiment when executing the computer program.
[0104] See also Figure 4 An embodiment of the present invention further provides an electronic device 100, including: a processor 90, a memory 91, a bus 92 and a communication interface 93, wherein the processor 90, the communication interface 93 and the memory 91 are connected via the bus 92; the processor 90 is used to execute an executable module stored in the memory 91, such as a computer program.
[0105] The memory 91 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 93 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.
[0106] The bus 92 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, Figure 4 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.
[0107] Among them, the memory 91 is used to store programs, and the processor 90 executes the program after receiving the execution instruction. The method executed by the device for flow process definition disclosed in any embodiment of the above-mentioned embodiments of the present invention can be applied to the processor 90 or implemented by the processor 90.
[0108] The processor 90 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 90. The above processor 90 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-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiments of the present invention can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field 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 91, and the processor 90 reads the information in the memory 91 and completes the steps of the above method in combination with its hardware.
[0109] 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.
[0110] 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.
[0111] An embodiment of the present application provides a computer-readable medium having a non-volatile program code executable by a processor, including a computer-readable storage medium storing a non-volatile program code executable by a processor, wherein the instructions included in the program code can be used to execute the method described in the foregoing method embodiment. For specific implementation, please refer to the method embodiment, which will not be described in detail here.
[0112] 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.
[0113] 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.
[0114] 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.
[0115] 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.
[0116] 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.
[0117] 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: Acquire a plurality of preset target index information for indexing data in a database; Performing a hash partitioning operation on the multiple target index information to obtain at least one target hash partition; wherein each target hash partition contains a hash value of the corresponding target index information; Setting a corresponding B-tree for each target hash partition in the at least one target hash partition; Perform a target data operation on the data in the database based on each of the target hash partitions and its corresponding B-tree; Setting a corresponding B-tree for each target hash partition in the at least one target hash partition includes: A target hash linked list is constructed according to the at least one target hash partition; wherein the target hash linked list includes a B-tree pointer set corresponding to the at least one target hash partition, and the B-tree pointer is used to determine the B-tree corresponding to the at least one target hash partition; Before performing a target data operation on the data in the database based on each of the target hash partitions and its corresponding B-tree, the method further includes: The B-tree corresponding to the target hash partition corresponding to the target data operation is controlled to be in a locked state.
2. The method according to claim 1, characterized in that Performing a hash partitioning operation on the plurality of target index information to obtain at least one target hash partition includes: Calculate the hash value of each target index information to obtain multiple target hash values; Obtain at least one preset initial hash partition; Determine the initial hash partition to which each target hash value belongs, and obtain at least one target hash partition.
3. The method according to claim 2, characterized in that Determining the initial hash partition to which each target hash value belongs includes: Obtaining the number of the at least one initial hash partition to obtain a target number; Perform remainder calculation on each of the target hash values based on the target quantity to obtain a first calculation result; The initial hash partition to which each target hash value belongs is determined based on the first calculation result.
4. The method according to claim 3, characterized in that Each initial hash partition contains corresponding sequential tag information; Determining the initial hash partition to which each target hash value belongs based on the first calculation result includes: The target sequence marking information identical to each first calculation result is determined in at least one sequence marking information, and the initial hash partition corresponding to the target sequence marking information is determined as the initial hash partition to which each target hash value belongs.
5. The method according to claim 1, characterized in that Performing a target data operation on the data in the database based on each of the target hash partitions and its corresponding B-tree includes: When the target data operation is a data writing operation, determining data index information of the data to be written, calculating a hash value of the data index information of the data to be written, and obtaining a first hash value; Determine the hash partition to which the first hash value belongs in the at least one target hash partition to obtain a first hash partition; A corresponding B-tree node is established on the B-tree corresponding to the first hash partition, wherein the B-tree node includes at least one of data index information of the data to be written and storage location information of the data to be written in the database.
6. The method according to claim 5, characterized in that Determining the hash partition to which the first hash value belongs in the at least one target hash partition, and obtaining the first hash partition includes: Performing remainder calculation on the first Hash value based on the number of the at least one target Hash partition to obtain a second calculation result; The hash partition to which the first hash value belongs is determined based on the second calculation result to obtain the first hash partition.
7. The method according to claim 1, characterized in that Performing a target data operation on the data in the database based on each of the target hash partitions and its corresponding B-tree also includes: When the target data operation is a data query operation, determining data index information of the data to be queried, calculating a hash value of the data index information of the data to be queried, and obtaining a second hash value; Determine the hash partition to which the second hash value belongs in the at least one target hash partition to obtain a second hash partition; Determine the B-tree corresponding to the second hash partition; The B-tree corresponding to the second hash partition is traversed and searched to obtain the storage location of the data to be queried in the database, and the data to be queried is read according to the storage location.
8. The method according to claim 7, characterized in that Determining the hash partition to which the second hash value belongs in the at least one target hash partition, and obtaining the second hash partition includes: Performing remainder calculation on the second Hash value based on the number of the at least one target Hash partition to obtain a third calculation result; The hash partition to which the second hash value belongs is determined based on the third calculation result to obtain a second hash partition.
9. A data processing device, characterized in that: include: An acquisition unit, used to acquire a plurality of preset target index information for indexing data in a database; A partitioning unit, configured to perform a hash partitioning operation on the plurality of target index information to obtain at least one target hash partition; wherein each target hash partition contains a hash value of the corresponding target index information; A construction unit, configured to set a corresponding B-tree for each target hash partition in the at least one target hash partition; An operation unit, configured to control the B-tree corresponding to the target hash partition corresponding to the target data operation to be in a locked state; and to perform the target data operation on the data in the database based on each of the target hash partitions and the B-tree corresponding thereto; The construction unit is also used to: construct a target hash linked list according to the at least one target hash partition; wherein the target hash linked list includes a B-tree pointer set corresponding to the at least one target hash partition, and the B-tree pointer is used to determine the B-tree corresponding to the at least one target hash partition.
10. 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 steps of the method according to any one of claims 1 to 8 are implemented.
11. 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 steps of the method according to any one of claims 1 to 8.
