CN111858606A - Data processing method, apparatus and electronic equipment - Google Patents
Data processing method, apparatus and electronic equipment Download PDFInfo
- Publication number
- CN111858606A CN111858606A CN202010727974.5A CN202010727974A CN111858606A CN 111858606 A CN111858606 A CN 111858606A CN 202010727974 A CN202010727974 A CN 202010727974A CN 111858606 A CN111858606 A CN 111858606A
- Authority
- CN
- China
- Prior art keywords
- data
- tree
- data index
- target
- index range
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2228—Indexing structures
- G06F16/2246—Trees, e.g. B+trees
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2379—Updates performed during online database operations; commit processing
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/526—Mutual exclusion algorithms
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明提供了一种数据处理方法、装置和电子设备,包括:获取预设索引范围,其中,预设索引范围为预先设定的对数据库中的数据进行索引的索引键值的范围区间;将预设索引范围划分为多个数据索引范围,并为每个数据索引范围构建相应的B树;基于每个数据索引范围和每个数据索引范围所对应的B树对数据执行指定数据操作。通过上述描述可知,将预设索引范围划分为多个数据索引范围后,在对数据库中的数据执行指定数据操作时,能够分区并发执行,提高了数据处理的效率,节省了数据处理的时间,缓解了现有的数据处理方法效率低下,耗时严重的技术问题。
The present invention provides a data processing method, device and electronic equipment, comprising: obtaining a preset index range, wherein the preset index range is a preset range of index key values for indexing 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; 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. As can be seen from the above description, after the preset index range is divided into multiple data index ranges, when the specified data operation is performed on the data in the database, it can be executed concurrently by partition, which improves the efficiency of data processing and saves the time of data processing. It alleviates the technical problems of low efficiency and serious time-consuming of existing data processing methods.
Description
技术领域technical field
本发明涉及计算机的技术领域,尤其是涉及一种数据处理方法、装置和电子设备。The present invention relates to the technical field of computers, and in particular, to a data processing method, apparatus and electronic device.
背景技术Background technique
随着移动互联网、社交网络、电子商务的飞速发展,信息量与日俱增,由此数据库中也存储了海量的数据。其中,数据库中的很多数据表都存储有几千万甚至过亿的数据,在进行数据处理时,往往需要依靠索引实现。目前,常用的索引包括B树或者B+树。With the rapid development of mobile Internet, social network, and e-commerce, the amount of information is increasing day by day, and a large amount of data is also stored in the database. Among them, 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. At present, commonly used indexes include B-tree or B+ tree.
对于一个具有海量数据的数据表来说,其对应有一个B树,在进行一次数据查询或数据更新时,往往基于该B树通过二分查找的方式实现该次的数据查询或数据更新。上述单次查找的查询次数并不多,但是在高并发的情况下(例如,同时进行1000次数据查询),查询次数会成倍增加(查询次数=单次查找的查询次数*并发数)。此外,在对数据表进行一次数据更新(包括数据写入和数据读取)时,该数据表对应的整颗B树都处于锁定状态,当对该数据表同时进行1000次的数据更新时,数据更新的过程只能串行进行,严重影响了数据更新的效率,耗时严重。For a data table with massive data, it corresponds to a B-tree. When a data query or data update is performed, the data query or data update is often implemented by binary search based on the B-tree. The number of queries for a single search above is not many, but in the case of high concurrency (for example, 1000 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 concurrent queries). In addition, when a data update (including data writing and data reading) is performed on the data table, the entire B-tree corresponding to the data table is in a locked state. When the data table is updated 1000 times at the same time, The process of data update can only be carried out in series, which seriously affects the efficiency of data update and takes a lot of time.
发明内容SUMMARY OF THE INVENTION
有鉴于此,本发明的目的在于提供一种数据处理方法、装置和电子设备,以缓解现有的数据处理方法效率低下,耗时严重的技术问题。In view of this, the purpose of the present invention is to provide a data processing method, device and electronic device, so as to alleviate the technical problems of low efficiency and serious time-consuming of the existing data processing method.
第一方面,本发明实施例提供了一种数据处理方法,包括:获取预设索引范围,其中,所述预设索引范围为预先设定的对数据库中的数据进行索引的索引键值的范围区间;将所述预设索引范围划分为多个数据索引范围,并为每个所述数据索引范围构建相应的B树;基于每个所述数据索引范围和每个所述数据索引范围所对应的B树对数据执行指定数据操作。In a first aspect, an embodiment of the present invention provides a data processing method, including: acquiring a preset index range, where the preset index range is a preset range of index key values for indexing data in a database interval; the preset index range is divided into a plurality of data index ranges, and a corresponding B-tree is constructed for each of the data index ranges; based on each of the data index ranges and the corresponding data index ranges The B-tree performs specified data operations on the data.
进一步地,基于每个所述数据索引范围和每个所述数据索引范围所对应的B树对数据执行指定数据操作包括:在所述指定数据操作为数据更新操作时,确定待更新数据的数据索引键值;在所述多个数据索引范围中确定所述待更新数据的数据索引键值所属的数据索引范围;构建所述待更新数据的数据索引键值所属的数据索引范围所对应的B树上的第一目标B树结点;根据所述第一目标B树结点的索引键值和所述第一目标B树结点所对应的存储位置,更新所述待更新数据。Further, 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 of the data to be updated. index key value; 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 the B corresponding to the data index range to which the data index key value of the data to be updated belongs The first target B-tree node on the tree; the data to be updated 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.
进一步地,基于每个所述数据索引范围和每个所述数据索引范围所对应的B树对数据执行指定数据操作还包括:在所述指定数据操作为数据读取操作时,确定待读取数据的数据索引键值;在所述多个数据索引范围中确定所述待读取数据的数据索引键值所属的数据索引范围;确定所述待读取数据的数据索引键值所属的数据索引范围所对应的B树;对所述待读取数据的数据索引键值所属的数据索引范围所对应的B树进行遍历查找,得到所述待读取数据在数据库中的存储位置,并根据所述存储位置读取所述待读取数据。Further, 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 specified data operation is a data read operation, determining to be read the data index key value of the data; 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 data index to which the data index key value of the data to be read belongs B-tree corresponding to the range; traverse the B-tree corresponding to the data index range to which the data index key value of the data to be read belongs, to obtain the storage location of the data to be read in the database, and according to the The storage location reads the data to be read.
进一步地,在基于每个所述数据索引范围和每个所述数据索引范围所对应的B树对数据执行指定数据操作之前,所述方法还包括:确定所述指定数据操作所对应的目标数据索引范围;控制所述目标数据索引范围所对应的B树处于锁定状态。Further, 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 target data corresponding to the specified data operation Index range; control the B-tree corresponding to the target data index range to be in a locked state.
进一步地,控制所述目标数据索引范围所对应的B树处于锁定状态包括:为所述目标数据索引范围所对应的B树设置锁定标识;根据所述锁定标识控制所述目标数据索引范围所对应的B树处于锁定状态。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; controlling the corresponding B-tree of the target data index range according to the lock flag The B-tree is locked.
第二方面,本发明实施例还提供了一种数据处理方法,包括:获取待读取数据的数据索引键值;根据所述数据索引键值在多个数据索引范围中确定第一目标数据索引范围,其中,每个数据索引范围包含数据库中各个数据的数据索引键值;每个数据索引范围对应一个B树;基于所述第一目标数据索引范围和其对应的第一目标B树确定所述待读取数据在数据库中的存储位置,并根据所述存储位置读取所述待读取数据。In a second aspect, an embodiment of the present invention further provides a data processing method, including: obtaining a data index key value of data to be read; determining a first target data index in a plurality of data index ranges according to the data index key value Scope, wherein each data index scope includes the data index key value of each data in the database; each data index scope corresponds to a B-tree; based on the first target data index scope and its corresponding first target B-tree the storage location of the data to be read in the database, and read the data to be read according to the storage location.
进一步地,所述每个数据索引范围对应一个B树指针;基于所述第一目标数据索引范围和其对应的第一目标B树确定所述待读取数据在数据库中的存储位置包括:根据所述第一目标数据索引范围的B树指针确定所述第一目标B树;基于所述第一目标B树确定所述待读取数据在数据库中的存储位置。Further, 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: according to The B-tree pointer of the first target data index range determines the first target B-tree; and the storage position of the data to be read in the database is determined based on the first target B-tree.
进一步地,在所述基于所述第一目标B树确定所述待读取数据在数据库中的存储位置之前,所述方法还包括:为所述第一目标B树设置锁定标识;根据所述锁定标识控制所述第一目标B树处于锁定状态。Further, before determining the storage location of the data to be read in the database based on the first target B-tree, the method further includes: setting a lock flag for the first target B-tree; according to the The lock flag controls the first target B-tree to be in a locked state.
第三方面,本发明实施例还提供了一种数据处理方法,包括:获取待更新数据的数据索引键值;根据所述数据索引键值在多个数据索引范围中确定所述待更新数据所属的第二目标数据索引范围,其中,每个数据索引范围包含数据库中各个数据的数据索引键值;每个数据索引范围对应一个B树;构建所述第二目标数据索引范围所对应的B树上的第二目标B树结点;根据所述第二目标B树结点的索引键值和所述第二目标B树结点所对应的存储位置,更新所述待更新数据。In a third aspect, an embodiment of the present invention further provides a data processing method, including: obtaining a data index key value of data to be updated; The second target data index range, 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; constructs the B-tree corresponding to the second target data index range The second target B-tree node on the second target B-tree node; 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, update the data to be updated.
进一步地,在构建所述第二目标数据索引范围所对应的B树上的第二目标B树结点之前,所述方法还包括:为所述第二目标数据索引范围所对应的B树设置锁定标识;根据所述锁定标识控制所述第二目标数据索引范围所对应的B树处于锁定状态。Further, before constructing the second target B-tree node on the B-tree corresponding to the second target data index range, the method further includes: setting the B-tree corresponding to the second target data index range Locking identifier; controlling the B-tree corresponding to the second target data index range to be in a locked state according to the locking identifier.
第四方面,本发明实施例还提供了一种数据处理装置,包括:第一获取单元,用于获取预设索引范围,其中,所述预设索引范围为预先设定的对数据库中的数据进行索引的索引键值的范围区间;划分单元,用于将所述预设索引范围划分为多个数据索引范围,并为每个所述数据索引范围构建相应的B树;操作执行单元,用于基于每个所述数据索引范围和每个所述数据索引范围所对应的B树对数据执行指定数据操作。In a fourth aspect, an embodiment of the present invention further provides a data processing device, including: a first obtaining unit, configured to obtain a preset index range, wherein the preset index range is a preset pair of data in a database The range interval of the index key value for indexing; the dividing unit is used to divide the preset index range into a plurality of data index ranges, and build a corresponding B-tree for each of the data index ranges; an operation execution unit, using for 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.
第五方面,本发明实施例还提供了一种数据处理装置,包括:第二获取单元,用于获取待读取数据的数据索引键值;第一确定单元,用于根据所述数据索引键值在多个数据索引范围中确定第一目标数据索引范围,其中,每个数据索引范围包含数据库中各个数据的数据索引键值;每个数据索引范围对应一个B树;第二确定单元,用于基于所述第一目标数据索引范围和其对应的第一目标B树确定所述待读取数据在数据库中的存储位置,并根据所述存储位置读取所述待读取数据。In a fifth aspect, an embodiment of the present invention further provides a data processing apparatus, including: a second obtaining unit, configured to obtain a data index key value of the data to be read; a first determining unit, configured to obtain a data index key according to the data index key The value determines the first target data index range in multiple 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 second determination unit, using The storage position of the data to be read in the database is determined based on the first target data index range and the corresponding first target B-tree, and the data to be read is read according to the storage position.
第六方面,本发明实施例还提供了一种数据处理装置,包括:第三获取单元,用于获取待更新数据的数据索引键值;第三确定单元,用于根据所述数据索引键值在多个数据索引范围中确定所述待更新数据所属的第二目标数据索引范围,其中,每个数据索引范围包含数据库中各个数据的数据索引键值;每个数据索引范围对应一个B树;构建单元,用于构建所述第二目标数据索引范围所对应的B树上的第二目标B树结点;更新单元,用于根据所述第二目标B树结点的索引键值和所述第二目标B树结点所对应的存储位置,更新所述待更新数据。In a sixth aspect, an embodiment of the present invention further provides a data processing device, comprising: a third obtaining unit, configured to obtain a data index key value of the data to be updated; a third determining unit, configured to obtain a data index key value according to the data index key value Determine the second target data index range to which the data to be updated 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 construction unit is used to construct the second target B-tree node on the B-tree corresponding to the second target data index range; the updating unit is used to construct the second target B-tree node according to the index key value and the The storage location corresponding to the second target B-tree node is updated, and the data to be updated is updated.
第七方面,本发明实施例还提供了一种电子设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述第一方面,或者,第二方面,或者,第三方面中任一项所述的方法。In a seventh aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and running on the processor, where the processor executes the computer program When the method described in any one of the first aspect, or the second aspect, or the third aspect is implemented.
第八方面,本发明实施例还提供了一种具有处理器可执行的非易失的程序代码的计算机可读介质,所述程序代码使所述处理器执行上述第一方面,或者,第二方面,或者第三方面中任一项所述的方法。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, the program code causing the processor to execute the first aspect above, or the second aspect, or the method of any one of the third aspects.
在本发明实施例中,首先,获取预设索引范围,其中,预设索引范围为预先设定的对数据库中的数据进行索引的索引键值的范围区间;将预设索引范围划分为多个数据索引范围,并为每个数据索引范围构建相应的B树;基于每个数据索引范围和每个数据索引范围所对应的B树对数据执行指定数据操作。通过上述描述可知,将预设索引范围划分为多个数据索引范围后,在对数据库中的数据执行指定数据操作时,能够分区并发执行,提高了数据处理的效率,节省了数据处理的时间,缓解了现有的数据处理方法效率低下,耗时严重的技术问题。In the embodiment of the present invention, first, a preset index range is obtained, where the preset index range is a preset range of index key values for indexing data in the database; the preset index range is divided into multiple The data index range is constructed, and a corresponding B-tree is constructed for each data index range; the 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 the specified data operation is performed on the data in the database, it can be executed concurrently by partition, which improves the efficiency of data processing and saves the time of data processing. The technical problems of low efficiency and serious time-consuming of the existing data processing methods are alleviated.
本发明的其他特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本发明而了解。本发明的目的和其他优点在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。Other features and advantages of the present invention will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the description, claims and drawings.
为使本发明的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。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 are described in detail as follows in conjunction with the accompanying drawings.
附图说明Description of drawings
为了更清楚地说明本发明具体实施方式或现有技术中的技术方案,下面将对具体实施方式或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the specific embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the specific embodiments or the prior art. Obviously, the accompanying drawings in the following description The drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.
图1为本发明实施例提供的一种数据处理方法的流程图;1 is a flowchart of a data processing method provided by an embodiment of the present invention;
图2为本发明实施例提供的链表的示意图;2 is a schematic diagram of a linked list provided by an embodiment of the present invention;
图3为本发明实施例提供的对数据库中的数据执行指定数据操作的流程图;3 is a flowchart of performing a specified data operation on data in a database provided by an embodiment of the present invention;
图4为本发明实施例提供的另一种对数据库中的数据执行指定数据操作的流程图;4 is another flowchart of performing a specified data operation on data in a database provided by an embodiment of the present invention;
图5为本发明实施例提供的又一种对数据库中的数据执行指定数据操作的流程图;5 is another flowchart of performing a specified data operation on data in a database provided by an embodiment of the present invention;
图6为本发明实施例提供的数据处理方法的流程图;6 is a flowchart of a data processing method provided by an embodiment of the present invention;
图7为本发明实施例提供的数据处理方法的流程图;7 is a flowchart of a data processing method provided by an embodiment of the present invention;
图8为本发明实施例提供的一种数据处理装置的示意图;FIG. 8 is a schematic diagram of a data processing apparatus according to an embodiment of the present invention;
图9为本发明实施例提供的另一种数据处理装置的示意图;9 is a schematic diagram of another data processing apparatus provided by an embodiment of the present invention;
图10为本发明实施例提供的又一种数据处理装置的示意图;10 is a schematic diagram of still another data processing apparatus provided by an embodiment of the present invention;
图11为本发明实施例提供的一种电子设备的示意图。FIG. 11 is a schematic diagram of an electronic device according to an embodiment of the present invention.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合附图对本发明的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of them. example. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
实施例一:Example 1:
根据本发明实施例,提供了一种数据处理方法的实施例,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。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 may be executed in a computer system such as a set of computer-executable instructions, and, although A logical order is shown in the flowcharts, but in some cases steps shown or described may be performed in an order different from that herein.
图1是根据本发明实施例的一种数据处理方法的流程图,如图1所示,该方法包括如下步骤:FIG. 1 is a flowchart of a data processing method according to an embodiment of the present invention. As shown in FIG. 1 , the method includes the following steps:
步骤S102,获取预设索引范围,其中,预设索引范围为预先设定的对数据库中的数据进行索引的索引键值的范围区间。Step S102 , obtaining a preset index range, wherein the preset index range is a preset range of index key values for indexing data in the database.
在本申请中,预设索引范围可以为用户自定义的对数据库中的数据进行索引的索引键值key的范围区间。In the present application, the preset index range may be a user-defined range of an index key value key for indexing data in the database.
为了便于理解,参考图2,对本发明的数据处理方法进行介绍:For ease of understanding, with reference to Figure 2, the data processing method of the present invention is introduced:
在图2中,0至10099的范围即为预设索引范围,当然,本发明实施例对上述预设索引范围不进行具体限定。In FIG. 2 , the range from 0 to 10099 is the preset index range. Of course, the above-mentioned preset index range is not specifically limited in this embodiment of the present invention.
步骤S104,将预设索引范围划分为多个数据索引范围,并为每个数据索引范围构建相应的B树。Step S104: Divide the preset index range into multiple data index ranges, and build a corresponding B-tree for each data index range.
在得到预设索引范围后,进一步将预设索引范围划分为多个数据索引范围。在进行数据索引范围的划分时,先获取预设范围划分区间,进而根据预设范围划分区间将预设索引范围划分为多个数据索引范围,其中,多个数据索引范围能够组成一个目标链表。After the preset index range is obtained, the preset index range is further divided into a plurality of data index ranges. When dividing the data index range, a preset range division interval is obtained first, 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.
需要说明的是,上述预设范围划分区间可以为一个,也可以为多个。当上述预设范围划分区间为多个时,可以定义各个预设范围划分区间所对应的待划分索引范围,进而按照各个预设范围划分区间对其对应的待划分索引范围进行划分。当预设范围划分区间为一个时,划分得到的各个数据索引范围的范围大小相等;当预设范围划分区间为多个时,按照相同预设范围划分区间划分得到的数据索引范围的范围大小相等,而按照不同预设范围划分区间划分得到的数据索引范围的范围大小不等。It should be noted that, the above-mentioned preset range division interval may be one or multiple. When there are multiple preset range division intervals, index ranges to be divided corresponding to each preset range division interval may be defined, and then the corresponding to-be-divided index ranges are divided according to each preset range division interval. When the preset range is divided into one interval, the divided data index ranges have the same size; when the preset range is divided into multiple intervals, the data index ranges obtained by dividing the interval according to the same preset range have the same size. , and the ranges of the data index ranges obtained by dividing the ranges according to different preset ranges are different in size.
如图2所示,预设范围划分区间为100,最终划分得到的数据索引范围包括:0~99,100~199,200~299,300~399,…,10000~10099,进而得到由多个数据索引范围所构成的目标链表。其中,目标链表的每个数据索引范围包含数据域和指针域,数据域中的数据用于表征索引范围,指针域包含有两个指针,其中一个指针指向该数据索引范围对应的B树(该指针可以称为B树指针),另外一个指针指向目标链表中的下一个节点。As shown in Figure 2, the preset range is divided into 100 intervals, and the final data index range obtained by division includes: 0~99, 100~199, 200~299, 300~399, ..., 10000~10099. The target linked list formed by the data index range. Among them, each data index range of the target linked list includes a data field and a pointer field, the data in the data field is used to represent the index range, and the pointer field contains two pointers, one of which points to the B-tree corresponding to the data index range (the The pointer can be called a B-tree pointer), and another pointer points to the next node in the target linked list.
步骤S106,基于每个数据索引范围和每个数据索引范围所对应的B树对数据执行指定数据操作。Step S106: Perform a specified data operation on the data based on each data index range and the B-tree corresponding to each data index range.
在得到多个数据索引范围后,就能基于每个数据索引范围和每个数据索引范围所对应的B树对数据库中的数据执行指定数据操作。在执行上述指定数据操作时,能够分区并发执行。例如,针对1000个数据索引范围,执行指定数据操作时,对应的数据索引范围都不同,那么可以同时对1000个数据索引范围内的数据进行指定数据操作,提高了数据处理的效率,节省了数据处理的时间。After multiple data index ranges are obtained, specified data operations 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 executing the above specified data operations, it can be executed concurrently by partition. For example, for 1000 data index ranges, when the specified data operation is performed, the corresponding data index ranges are different, then the specified data operation can be performed on the data within the 1000 data index range at the same time, which improves the efficiency of data processing and saves data. processing time.
在本发明实施例中,首先,获取预设索引范围,其中,预设索引范围为预先设定的对数据库中的数据进行索引的索引键值的范围区间;将预设索引范围划分为多个数据索引范围,并为每个数据索引范围构建相应的B树;基于每个数据索引范围和每个数据索引范围所对应的B树对数据执行指定数据操作。通过上述描述可知,将预设索引范围划分为多个数据索引范围后,在对数据库中的数据执行指定数据操作时,能够分区并发执行,提高了数据处理的效率,节省了数据处理的时间,缓解了现有的数据处理方法效率低下,耗时严重的技术问题。In the embodiment of the present invention, first, a preset index range is obtained, where the preset index range is a preset range of index key values for indexing data in the database; the preset index range is divided into multiple The data index range is constructed, and a corresponding B-tree is constructed for each data index range; the 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 the specified data operation is performed on the data in the database, it can be executed concurrently by partition, which improves the efficiency of data processing and saves the time of data processing. The technical problems of low efficiency and serious time-consuming of the existing data processing methods are alleviated.
上述内容对本发明的数据处理方法进行了简要介绍,下面对其中涉及的具体内容进行详细描述。The above content briefly introduces the data processing method of the present invention, and the specific content involved is described in detail below.
在本申请的一个可选的实施方式中,参考图3,上述步骤S106,基于每个数据索引范围和每个数据索引范围所对应的B树对数据执行指定数据操作包括如下步骤:In an optional embodiment of the present application, referring to FIG. 3 , in 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:
步骤S301,在指定数据操作为数据更新操作时,确定待更新数据的数据索引键值,得到第一数据索引键值;Step S301, when the specified data operation is a data update operation, determine the data index key value of the data to be updated, and obtain the first data index key value;
步骤S302,在多个数据索引范围中确定待更新数据的数据索引键值所属的数据索引范围;Step S302, in a plurality of data index ranges, determine the data index range to which the data index key value of the data to be updated belongs;
步骤S303,构建待更新数据的数据索引键值所属的数据索引范围所对应的B树上的第一目标B树结点;Step S303, constructing the 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;
步骤S304,根据第一目标B树结点的索引键值和第一目标B树结点所对应的存储位置,更新待更新数据。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.
下面以一个具体的实例对数据更新的过程进行说明:The following describes the process of data update with a specific example:
如果待更新数据的数据索引键值为201,根据预设范围划分区间划分得到的多个数据索引范围可以确定该数据索引键值201所属的数据索引范围为图2中的200~299的数据索引范围,进而在200~299的数据索引范围所对应的B树上建立相应的B树结点(即,第一目标B树结点),即根据B树的构建原理在B树中插入相应的结点。在建立第一目标B树结点之后,就可以根据第一目标B树结点的数据索引键值和第一目标B树结点所对应的存储位置,更新待更新数据。If the data index key value of the data to be updated is 201, it can be determined that the data index range to which the data index key value 201 belongs is the data index range from 200 to 299 in FIG. range, and then establish a corresponding B-tree node (ie, the first target B-tree node) on the B-tree corresponding to the data index range of 200 to 299, that is, according to the construction principle of the B-tree, insert the corresponding B-tree into the B-tree Node. 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.
在本申请的另一个可选的实施方式中,参考图4,上述步骤S106,基于每个数据索引范围和每个数据索引范围所对应的B树对数据执行指定数据操作还包括如下步骤:In another optional embodiment of the present application, referring to FIG. 4 , in 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 further includes the following steps:
步骤S401,在指定数据操作为数据读取操作时,确定待读取数据的数据索引键值;Step S401, when the specified data operation is a data read operation, determine the data index key value of the data to be read;
步骤S402,在多个数据索引范围中确定待读取数据的数据索引键值所属的数据索引范围;Step S402, in a plurality of data index ranges, determine the data index range to which the data index key value of the data to be read belongs;
步骤S403,确定待读取数据的数据索引键值所属的数据索引范围所对应的B树;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;
步骤S404,对待读取数据的数据索引键值所属的数据索引范围所对应的B树进行遍历查找,得到待读取数据在数据库中的存储位置,并根据存储位置读取待读取数据。Step S404, traverse 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.
下面以一个具体的实例对数据查询的过程进行说明:The following describes the process of data query with a specific example:
如果待读取数据的数据索引键值为201,根据预设范围划分区间划分得到的多个数据索引范围可以确定该数据索引键值201所属的数据索引范围为图2中的200~299的数据索引范围,进而对200~299的数据索引范围所对应的B树进行遍历查找,得到待读取数据在数据库中的存储位置,并读取存储在存储位置的待读取数据。If the data index key value of the data to be read is 201, it can be determined that the data index range to which the data index key value 201 belongs is the data from 200 to 299 in FIG. index range, and then traverse the B-tree corresponding to the data index range of 200 to 299 to obtain the storage location of the data to be read in the database, and read the data to be read stored in the storage location.
在本申请的另一个可选的实施方式中,参考图5,在基于每个数据索引范围和每个数据索引范围所对应的B树对数据执行指定数据操作之前,该方法还包括如下步骤:In another optional embodiment of the present application, referring to FIG. 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:
步骤S501,确定指定数据操作所对应的目标数据索引范围;Step S501, determining the target data index range corresponding to the specified data operation;
具体的,先根据预设范围划分区间划分得到多个数据索引范围,然后确定指定数据操作所对应的数据索引键值,进而在多个数据索引范围中确定该数据索引键值所属的目标数据索引范围,该目标数据索引范围即为指定数据操作所对应的目标数据索引范围。如图2所示,若预设范围划分区间为100,划分得到多个数据索引范围分别为0~99,100~199,200~299,300~399,…,10000~10099。若指定数据操作所对应的数据索引键值为201,那么可以确定201所属的目标数据索引范围为200~299,即指定数据操作所对应的目标数据索引范围为200~299的数据索引范围。Specifically, a plurality of data index ranges are obtained by dividing the interval according to a preset range, and then the data index key value corresponding to the specified data operation is determined, and then the target data index to which the data index key value belongs is determined in the plurality of data index ranges. range, the target data index range is the target data index range corresponding to the specified data operation. As shown in FIG. 2 , if the preset range division interval is 100, the divided data index ranges are respectively 0-99, 100-199, 200-299, 300-399, ..., 10000-10099. If the data index key value corresponding to the specified data operation is 201, 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 the data index range of 200-299.
步骤S502,控制目标数据索引范围所对应的B树处于锁定状态;Step S502, the B-tree corresponding to the control target data index range is in a locked state;
具体的,可以为目标数据索引范围所对应的B树设置锁定标识,其中,锁定标识用于表征目标数据索引范围所对应的B树处于锁定状态;进而根据锁定标识控制目标数据索引范围所对应的B树处于锁定状态。Specifically, a lock flag can 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; The B-tree is locked.
在目标数据索引范围所对应的B树处于锁定状态时,就可以基于目标数据索引范围和其所对应的B树对数据库中的数据执行指定数据操作。When the B-tree corresponding to the target data index range is in a locked state, the specified data operation can be performed on the data in the database based on the target data index range and the corresponding B-tree.
如果指定数据操作为数据更新操作,那么在目标B树(即目标数据索引范围所对应的B树)上构建相应的B树节点;如果指定数据操作为数据读取操作,那么对目标B树(即目标数据索引范围所对应的B树)进行遍历查找,得到待读取数据在数据库中的存储位置,并根据该存储位置读取待读取数据。If the specified data operation is a data update operation, then construct the corresponding B-tree node on the target B-tree (that is, 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 ( That is, 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.
由上述执行指定数据操作的过程可以看出,在对数据进行处理时,只是控制目标数据索引范围所对应的B树处于锁定状态,而不需要使所有的数据索引范围所对应的B树都处于锁定状态。这样,当并行的多个目标数据索引范围都不同时,可以并发对多个相应的B树执行相应的操作,不会发生冲突,提高了数据处理的效率。It can be seen from the above process of performing 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 all the B-trees corresponding to the data index range in a locked state. locked state. In this way, when multiple parallel target data index ranges are different, corresponding operations can be performed concurrently on multiple corresponding B-trees without conflict, which improves the efficiency of data processing.
本发明的数据处理方法具有以下优点:可以对不同数据索引范围对应的B树同时进行操作,能够实现不同分区对应的数据并发处理,提高了数据处理效率;降低了B树的高度,减少了查询次数,进而避免了无用磁盘的查询,减少了IO的查询次数。The data processing method of the present invention has the following advantages: the B-tree 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, and the query is reduced. The number of times, thereby avoiding useless disk queries and reducing the number of IO queries.
实施例二:Embodiment 2:
图6是根据本发明实施例的数据处理方法的流程图,如图6所示,该方法包括如下步骤:FIG. 6 is a flowchart of a data processing method according to an embodiment of the present invention. As shown in FIG. 6 , the method includes the following steps:
步骤S602,获取待读取数据的数据索引键值;Step S602, obtaining the data index key value of the data to be read;
步骤S604,根据数据索引键值在多个数据索引范围中确定第一目标数据索引范围,其中,每个数据索引范围包含数据库中各个数据的数据索引键值;每个数据索引范围对应一个B树。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 includes the data index key value of each data in the database; each data index range corresponds to a B-tree .
参考图2,图2的第一行为目标链表,在该目标链表中包含上述所描述的多个数据索引范围。若数据索引键值为201,那么可以确定201的数据索引键值在目标链表中所属的第一目标数据索引范围即为图2中的200~299的数据索引范围。Referring to FIG. 2 , the first behavior of FIG. 2 is a target linked list, and the target linked list includes a plurality of data index ranges described above. If the data index key value is 201, it can be determined that the first target data index range to which the data index key value of 201 belongs in the target linked list is the data index range of 200 to 299 in FIG. 2 .
步骤S606,基于第一目标数据索引范围和其对应的第一目标B树确定待读取数据在数据库中的存储位置,并根据存储位置读取待读取数据。Step S606: Determine the storage location of the data to be read in the database based on the first target data index range and the corresponding first target B-tree, and read the data to be read according to the storage location.
在一个可选的实施方式中,若每个数据索引范围对应一个B树指针,那么基于第一目标数据索引范围和其对应的第一目标B树确定待读取数据在数据库中的存储位置包括如下过程:In an optional implementation manner, if each data index range corresponds to a B-tree pointer, then 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 the following steps: The process is as follows:
根据第一目标数据索引范围的B树指针确定第一目标B树;基于第一目标B树确定待读取数据在数据库中的存储位置。The first target B-tree is determined according to the B-tree pointer of the first target data index range; the storage position of the data to be read in the database is determined based on the first target B-tree.
在基于第一目标B树确定待读取数据在数据库中的存储位置之前,还可以为第一目标B树设置锁定标识,并根据锁定标识控制第一目标B树处于锁定状态。Before determining the storage location of the data to be read in the database based on the first target B-tree, a lock flag may also be set for the first target B-tree, and the first target B-tree is controlled to be in a locked state according to the lock flag.
在本发明的数据处理方法中,当待读取数据的数据索引键值在不同的数据索引范围时,能够并行执行数据读取的过程,提高了数据读取的效率。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 performed in parallel, thereby improving the data reading efficiency.
实施例三:Embodiment three:
图7是根据本发明实施例的数据处理方法的流程图,如图7所示,该方法包括如下步骤:FIG. 7 is a flowchart of a data processing method according to an embodiment of the present invention. As shown in FIG. 7 , the method includes the following steps:
步骤S702,获取待更新数据的数据索引键值;Step S702, obtaining the data index key value of the data to be updated;
步骤S704,根据数据索引键值在多个数据索引范围中确定待更新数据所属的第二目标数据索引范围,其中,每个数据索引范围包含数据库中各个数据的数据索引键值;每个数据索引范围对应一个B树。Step S704: 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 A range corresponds to a B-tree.
参考图2,图2的第一行为目标链表,在该目标链表中包含上述所描述的多个数据索引范围。若数据索引键值为201,那么可以确定数据索引键值201在目标链表中的第二目标数据索引范围即图2中的200~299的数据索引范围。Referring to FIG. 2 , the first behavior of FIG. 2 is a target linked list, and the target linked list includes a plurality of data index ranges described above. If the data index key value is 201, it can be determined that the second target data index range of the data index key value 201 in the target linked list is the data index range of 200-299 in FIG. 2 .
步骤S706,构建第二目标数据索引范围所对应的B树上的第二目标B树结点;具体地,可以在构建第二目标数据索引范围所对应的B树上的第二目标B树结点时,可以将第二目标B树结点的索引键值设置为待更新数据的数据索引键值,以及将第二目标B树结点所对应的存储位置设置为待更新数据在数据库中的存储位置,以实现对待更新数据执行数据更新操作。Step S706, constructing the second target B-tree node on the B-tree corresponding to the second target data index range; specifically, constructing the second target B-tree node on the B-tree corresponding to the second target data index range. point, 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 data to be updated in the database. The storage location for performing data update operations on the data to be updated.
步骤S708,根据第二目标B树结点的索引键值和第二目标B树结点所对应的存储位置,更新待更新数据。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.
其中,每个数据索引范围对应一个B树指针,具体的,可以根据第二目标数据索引范围的B树指针确定第二目标数据索引范围所对应的B树。Wherein, each data index range corresponds to a B-tree pointer. Specifically, the B-tree corresponding to the second target data index range may be determined according to the B-tree pointer of the second target data index range.
在本申请的一个可选实施方式中,在构建第二目标数据索引范围所对应的B树上的第二目标B树结点之前,该方法还包括:为第二目标数据索引范围所对应的B树设置锁定标识;根据锁定标识控制第二目标数据索引范围所对应的B树处于锁定状态。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 further includes: The B-tree is set with a lock flag; the B-tree corresponding to the index range of the second target data is controlled to be in a locked state according to the lock flag.
具体地,在本申请中,可以为第二目标数据索引范围所对应的B树设置锁定标识,其中,锁定标识用于表征第二目标数据索引范围所对应的B树处于锁定状态。然后,在处于锁定状态时,构建第二目标数据索引范围所对应的B树上的第二目标B树结点。Specifically, in the present application, a lock flag may be set for the B-tree corresponding to the second target data index range, where 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, in the locked state, construct a second target B-tree node on the B-tree corresponding to the second target data index range.
在本发明的数据处理方法中,当待更新数据的数据索引键值在不同的数据索引范围时,能够并行执行数据更新的过程,提高了数据更新的效率。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 update process can be performed in parallel, thereby improving the data update efficiency.
实施例四:Embodiment 4:
本发明实施例还提供了一种数据处理装置,该数据处理装置主要用于执行本发明上述实施例一所提供的数据处理方法,以下对本发明实施例提供的数据处理装置做具体介绍。An embodiment of the present invention further provides a data processing apparatus, which is mainly used to execute the data processing method provided by the first embodiment of the present invention. The data processing apparatus provided by the embodiment of the present invention is described in detail below.
图8是根据本发明实施例的一种数据处理装置的示意图,如图8所示,该数据处理装置主要包括:第一获取单元81,划分单元82和操作执行单元83,其中:FIG. 8 is a schematic diagram of a data processing apparatus according to an embodiment of the present invention. As shown in FIG. 8 , the data processing apparatus mainly includes: a first obtaining unit 81, a dividing unit 82 and an operation executing unit 83, wherein:
第一获取单元81,用于获取预设索引范围,其中,所述预设索引范围为预先设定的对数据库中的数据进行索引的索引键值的范围区间;The first obtaining unit 81 is configured to obtain a preset index range, wherein the preset index range is a preset range of index key values for indexing data in the database;
划分单元82,用于将所述预设索引范围划分为多个数据索引范围,并为每个所述数据索引范围构建相应的B树;a dividing 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;
操作执行单元83,用于基于每个所述数据索引范围和每个所述数据索引范围所对应的B树对数据执行指定数据操作。The operation execution unit 83 is configured to perform 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.
在本发明实施例中,首先,获取预设索引范围,其中,预设索引范围为预先设定的对数据库中的数据进行索引的索引键值的范围区间;将预设索引范围划分为多个数据索引范围,并为每个数据索引范围构建相应的B树;基于每个数据索引范围和每个数据索引范围所对应的B树对数据执行指定数据操作。通过上述描述可知,将预设索引范围划分为多个数据索引范围后,在对数据库中的数据执行指定数据操作时,能够分区并发执行,提高了数据处理的效率,节省了数据处理的时间,缓解了现有的数据处理方法效率低下,耗时严重的技术问题。In the embodiment of the present invention, first, a preset index range is obtained, where the preset index range is a preset range of index key values for indexing data in the database; the preset index range is divided into multiple The data index range is constructed, and a corresponding B-tree is constructed for each data index range; the 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 the specified data operation is performed on the data in the database, it can be executed concurrently by partition, which improves the efficiency of data processing and saves the time of data processing. The technical problems of low efficiency and serious time-consuming of the existing data processing methods are alleviated.
可选地,操作执行单元83还用于:在所述指定数据操作为数据更新操作时,确定待更新数据的数据索引键值;在所述多个数据索引范围中确定所述待更新数据的数据索引键值所属的数据索引范围;构建所述待更新数据的数据索引键值所属的数据索引范围所对应的B树上的第一目标B树结点;根据所述第一目标B树结点的索引键值和所述目标B树结点所对应的存储位置,更新所述待更新数据。Optionally, the operation execution unit 83 is further configured to: when the specified data operation is a data update operation, determine the data index key value of the data to be updated; The data index range to which the data index key value belongs; construct the 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; according to the first target B-tree node The index key value of the point and the storage location corresponding to the target B-tree node are used to update the data to be updated.
可选地,操作执行单元83还用于:在所述指定数据操作为数据读取操作时,确定待读取数据的数据索引键值;在所述多个数据索引范围中确定所述待读取数据的数据索引键值所属的数据索引范围;确定所述待读取数据的数据索引键值所属的数据索引范围所对应的B树;对所述待读取数据的数据索引键值所属的数据索引范围所对应的B树进行遍历查找,得到所述待读取数据在数据库中的存储位置,并根据所述存储位置读取所述待读取数据。Optionally, the operation execution unit 83 is further configured to: when the specified data operation is a data read operation, determine the data index key value of the data to be read; determine the to-be-read data in the multiple data index ranges Get the data index range to which the data index key value of the data 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 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.
可选地,该装置还用于:在基于每个所述数据索引范围和每个所述数据索引范围所对应的B树对数据执行指定数据操作之前,确定所述指定数据操作所对应的目标数据索引范围;控制所述目标数据索引范围所对应的B树处于锁定状态。Optionally, the device is further configured to: 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, determine a target corresponding to the specified data operation Data index range; control the B-tree corresponding to the target data index range to be in a locked state.
可选地,操作执行单元还用于:为所述目标数据索引范围所对应的B树设置锁定标识;根据所述锁定标识控制所述目标数据索引范围所对应的B树处于锁定状态。Optionally, the operation execution unit is further configured to: set a lock flag 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 flag.
实施例五:Embodiment 5:
本发明实施例还提供了一种数据处理装置,该数据处理装置主要用于执行本发明上述实施例二所提供的数据处理方法,以下对本发明实施例提供的数据处理装置做具体介绍。An embodiment of the present invention further provides a data processing apparatus, which is mainly used to execute the data processing method provided by the second embodiment of the present invention. The following describes the data processing apparatus provided by the embodiment of the present invention.
图9是根据本发明实施例的一种数据处理装置的示意图,如图9所示,该数据处理装置主要包括:第二获取单元91,第一确定单元92和第二确定单元93,其中:FIG. 9 is a schematic diagram of a data processing apparatus according to an embodiment of the present invention. As shown in FIG. 9 , the data processing apparatus mainly includes: a second obtaining unit 91, a first determining unit 92 and a second determining unit 93, wherein:
第二获取单元91,用于获取待读取数据的数据索引键值;The second obtaining unit 91 is used to obtain the data index key value of the data to be read;
第一确定单元92,用于根据所述数据索引键值在多个数据索引范围中确定第一目标数据索引范围,其中,每个数据索引范围包含数据库中各个数据的数据索引键值;每个数据索引范围对应一个B树;The first determining unit 92 is 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 the data index key value of each data in the database; each The data index range corresponds to a B-tree;
第二确定单元93,用于基于所述第一目标数据索引范围和其对应的第一目标B树确定所述待读取数据在数据库中的存储位置,并根据所述存储位置读取所述待读取数据。The second determining unit 93 is configured 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 storage location according to the storage location. Data to be read.
可选地,每个数据索引范围对应一个B树指针;第二确定单元93还用于:根据所述第一目标数据索引范围的B树指针确定所述第一目标B树;基于所述第一目标B树确定所述待读取数据在数据库中的存储位置。Optionally, each data index range corresponds to a B-tree pointer; the second determining unit 93 is further configured to: determine the first target B-tree according to the B-tree pointer of the first target data index range; A target B-tree determines the storage location of the data to be read in the database.
可选地,该装置还用于:在所述基于所述第一目标B树确定所述待读取数据在数据库中的存储位置之前,为所述第一目标B树设置锁定标识;根据所述锁定标识控制所述第一目标B树处于锁定状态。Optionally, the device is further configured to: before the storage location of the data to be read in the database is determined based on the first target B-tree, set a lock flag for the first target B-tree; The lock flag controls the first target B-tree to be in a locked state.
在本发明的数据处理装置中,当待读取数据的数据索引键值在不同的数据索引范围时,能够并行执行数据读取的过程,提高了数据读取的效率。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 performed in parallel, thereby improving the data reading efficiency.
实施例六:Embodiment 6:
本发明实施例还提供了一种数据处理装置,该数据处理装置主要用于执行本发明上述实施例三所提供的数据处理方法,以下对本发明实施例提供的数据处理装置做具体介绍。An embodiment of the present invention further provides a data processing apparatus, which is mainly used to execute the data processing method provided by the third embodiment of the present invention. The following describes the data processing apparatus provided by the embodiment of the present invention.
图10是根据本发明实施例的一种数据处理装置的示意图,如图10所示,该数据处理装置主要包括:第三获取单元101,第三确定单元102,构建单元103和更新单元104,其中:FIG. 10 is a schematic diagram of a data processing apparatus according to an embodiment of the present invention. As shown in FIG. 10 , the data processing apparatus mainly includes: a third acquisition unit 101, a third determination unit 102, a construction unit 103 and an update unit 104, in:
第三获取单元101,用于获取待更新数据的数据索引键值;The third obtaining unit 101 is used for obtaining the data index key value of the data to be updated;
第三确定单元102,用于根据所述数据索引键值在多个数据索引范围中确定所述待更新数据所属的第二目标数据索引范围,其中,每个数据索引范围包含数据库中各个数据的数据索引键值;每个数据索引范围对应一个B树;A third determining unit 102, configured to 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 of each data in the database Data index key value; each data index range corresponds to a B-tree;
构建单元103,用于构建所述第二目标数据索引范围所对应的B树上的第二目标B树结点;Construction unit 103, for constructing the second target B-tree node on the B-tree corresponding to the second target data index range;
更新单元104,用于根据所述第二目标B树结点的索引键值和所述第二目标B树结点所对应的存储位置,更新所述待更新数据。The updating unit 104 is configured 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.
可选地,该装置还用于:在构建所述第二目标数据索引范围所对应的B树上的第二目标B树结点之前,为所述第二目标数据索引范围所对应的B树设置锁定标识;根据所述锁定标识控制所述第二目标数据索引范围所对应的B树处于锁定状态。Optionally, the device is further configured to: before constructing the second target B-tree node on the B-tree corresponding to the second target data index range, create a B-tree corresponding to the second target data index range Setting a lock flag; controlling the B-tree corresponding to the second target data index range to be in a locked state according to the lock flag.
在本发明的数据处理装置中,当待更新数据的数据索引键值在不同的数据索引范围时,能够并行执行数据更新的过程,提高了数据更新的效率。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 update process can be performed in parallel, thereby improving the data update efficiency.
实施例七:Embodiment 7:
参见图11,本发明实施例还提供一种电子设备100,包括:处理器110,存储器111,总线112和通信接口113,处理器110、通信接口113和存储器111通过总线112连接;处理器110用于执行存储器111中存储的可执行模块,例如计算机程序。11, an embodiment of the present invention further provides an
其中,存储器111可能包含高速随机存取存储器(RAM,Random Access Memory),也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。通过至少一个通信接口113(可以是有线或者无线)实现该系统网元与至少一个其他网元之间的通信连接,可以使用互联网,广域网,本地网,城域网等。The
总线112可以是ISA总线、PCI总线或EISA总线等。所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图11中仅用一个双向箭头表示,但并不表示仅有一根总线或一种类型的总线。The bus 112 may be an ISA bus, a PCI bus, an EISA bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one bidirectional arrow is shown in FIG. 11, but it does not mean that there is only one bus or one type of bus.
其中,存储器111用于存储程序,所述处理器110在接收到执行指令后,执行所述程序,前述本发明实施例任一实施例揭示的流过程定义的装置所执行的方法可以应用于处理器110中,或者由处理器110实现。The
处理器110可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器110中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器110可以是通用处理器,包括中央处理器(Central Processing Unit,简称CPU)、网络处理器(Network Processor,简称NP)等;还可以是数字信号处理器(DigitalSignal Processing,简称DSP)、专用集成电路(Application Specific IntegratedCircuit,简称ASIC)、现成可编程门阵列(Field-Programmable Gate Array,简称FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本发明实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器111,处理器110读取存储器111中的信息,结合其硬件完成上述方法的步骤。The
另外,在本发明实施例的描述中,除非另有明确的规定和限定,术语“安装”、“相连”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体地连接;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本发明中的具体含义。In addition, in the description of the embodiments of the present invention, unless otherwise expressly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense, for example, it may be a fixed connection or a detachable connection , or integrally connected; 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 the internal communication between the two components. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood in specific situations.
在本发明的描述中,需要说明的是,术语“中心”、“上”、“下”、“左”、“右”、“竖直”、“水平”、“内”、“外”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本发明和简化描述,而不是指示或暗示所指的装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本发明的限制。此外,术语“第一”、“第二”、“第三”仅用于描述目的,而不能理解为指示或暗示相对重要性。In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. The indicated orientation or positional relationship is based on the orientation or positional relationship shown in the accompanying drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the indicated device or element must have a specific orientation or a specific orientation. construction and operation, and therefore should not be construed as limiting the invention. Furthermore, the terms "first", "second", and "third" are used for descriptive purposes only and should not be construed to indicate or imply relative importance.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described systems, devices and units may refer to the corresponding processes in the foregoing method embodiments, which will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. The apparatus embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces, indirect coupling or communication connection of devices or units, which may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。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 alone, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个处理器可执行的非易失的计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。The functions, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a processor-executable non-volatile computer-readable storage medium. Based on this understanding, the technical solution of the present invention can be embodied in the form of a software product in essence, or the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes .
最后应说明的是:以上所述实施例,仅为本发明的具体实施方式,用以说明本发明的技术方案,而非对其限制,本发明的保护范围并不局限于此,尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本发明实施例技术方案的精神和范围,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应所述以权利要求的保护范围为准。Finally, it should be noted that the above-mentioned embodiments are only specific implementations of the present invention, and are used to illustrate the technical solutions of the present invention, but not to limit them. The protection scope of the present invention is not limited thereto, although referring to the foregoing The embodiment has been described in detail the present invention, those of ordinary skill in the art should understand: any person skilled in the art who is familiar with the technical field within the technical scope disclosed by the present invention can still modify the technical solutions described in the foregoing embodiments. Or can easily think of changes, or equivalently replace some of the technical features; 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 covered in the present invention. within the scope of protection. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims (15)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010727974.5A CN111858606B (en) | 2020-07-24 | 2020-07-24 | Data processing method, device and electronic device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010727974.5A CN111858606B (en) | 2020-07-24 | 2020-07-24 | Data processing method, device and electronic device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN111858606A true CN111858606A (en) | 2020-10-30 |
| CN111858606B CN111858606B (en) | 2024-12-10 |
Family
ID=72950208
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202010727974.5A Active CN111858606B (en) | 2020-07-24 | 2020-07-24 | Data processing method, device and electronic device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111858606B (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114238704A (en) * | 2022-02-21 | 2022-03-25 | 北京金山云网络技术有限公司 | Tree index splitting method, data access method and device and electronic equipment |
| WO2024051271A1 (en) * | 2022-09-08 | 2024-03-14 | 华为技术有限公司 | Data processing method and device |
Citations (11)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6374232B1 (en) * | 1996-08-29 | 2002-04-16 | Oracle Corp. | Method and mechanism for retrieving values from a database |
| CN1666196A (en) * | 2002-05-10 | 2005-09-07 | 甲骨文国际公司 | Method and mechanism of storing and accessing data and improving performance of database query language statements |
| US20110238667A1 (en) * | 2010-03-29 | 2011-09-29 | Sybase, Inc. | B-Tree Ordinal Approximation |
| CN103745008A (en) * | 2014-01-28 | 2014-04-23 | 河海大学 | Sorting method for big data indexing |
| CN104112011A (en) * | 2014-07-16 | 2014-10-22 | 深圳市国泰安信息技术有限公司 | Method and device for extracting mass data |
| CN106503196A (en) * | 2016-10-26 | 2017-03-15 | 云南大学 | Construction and query method of scalable storage index structure in cloud environment |
| CN106657174A (en) * | 2015-10-28 | 2017-05-10 | 阿里巴巴集团控股有限公司 | Data synchronizing and updating methods and data synchronizing and updating devices |
| CN109117433A (en) * | 2017-06-23 | 2019-01-01 | 菜鸟智能物流控股有限公司 | Index tree object creation method and index method and related device thereof |
| CN110716933A (en) * | 2019-09-29 | 2020-01-21 | 浙江大学 | Novel urban rail train big data-oriented high-flexibility distributed index method |
| CN111008200A (en) * | 2019-12-18 | 2020-04-14 | 北京数衍科技有限公司 | Data query method, device and server |
| CN111125120A (en) * | 2019-12-30 | 2020-05-08 | 广州数锐智能科技有限公司 | Stream data-oriented fast indexing method, device, equipment and storage medium |
-
2020
- 2020-07-24 CN CN202010727974.5A patent/CN111858606B/en active Active
Patent Citations (11)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6374232B1 (en) * | 1996-08-29 | 2002-04-16 | Oracle Corp. | Method and mechanism for retrieving values from a database |
| CN1666196A (en) * | 2002-05-10 | 2005-09-07 | 甲骨文国际公司 | Method and mechanism of storing and accessing data and improving performance of database query language statements |
| US20110238667A1 (en) * | 2010-03-29 | 2011-09-29 | Sybase, Inc. | B-Tree Ordinal Approximation |
| CN103745008A (en) * | 2014-01-28 | 2014-04-23 | 河海大学 | Sorting method for big data indexing |
| CN104112011A (en) * | 2014-07-16 | 2014-10-22 | 深圳市国泰安信息技术有限公司 | Method and device for extracting mass data |
| CN106657174A (en) * | 2015-10-28 | 2017-05-10 | 阿里巴巴集团控股有限公司 | Data synchronizing and updating methods and data synchronizing and updating devices |
| CN106503196A (en) * | 2016-10-26 | 2017-03-15 | 云南大学 | Construction and query method of scalable storage index structure in cloud environment |
| CN109117433A (en) * | 2017-06-23 | 2019-01-01 | 菜鸟智能物流控股有限公司 | Index tree object creation method and index method and related device thereof |
| CN110716933A (en) * | 2019-09-29 | 2020-01-21 | 浙江大学 | Novel urban rail train big data-oriented high-flexibility distributed index method |
| CN111008200A (en) * | 2019-12-18 | 2020-04-14 | 北京数衍科技有限公司 | Data query method, device and server |
| CN111125120A (en) * | 2019-12-30 | 2020-05-08 | 广州数锐智能科技有限公司 | Stream data-oriented fast indexing method, device, equipment and storage medium |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114238704A (en) * | 2022-02-21 | 2022-03-25 | 北京金山云网络技术有限公司 | Tree index splitting method, data access method and device and electronic equipment |
| WO2024051271A1 (en) * | 2022-09-08 | 2024-03-14 | 华为技术有限公司 | Data processing method and device |
Also Published As
| Publication number | Publication date |
|---|---|
| CN111858606B (en) | 2024-12-10 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US9934324B2 (en) | Index structure to accelerate graph traversal | |
| CN111858607B (en) | Data processing method, device, electronic equipment and computer readable medium | |
| CN107729371B (en) | Data index and query method, device, equipment and storage medium of blockchain | |
| CN111651641B (en) | Graph query method, device and storage medium | |
| CN110704433B (en) | Brin index construction method of columnar storage data, data retrieval method and device | |
| WO2021068346A1 (en) | Method and device for location querying based on geohash algorithm, computer device, and storage medium | |
| JP2020123320A (en) | Method, apparatus, device and storage medium for managing index | |
| CN107229674A (en) | A kind of data migration device, server and method | |
| KR20190079354A (en) | Partitioned space based spatial data object query processing apparatus and method, storage media storing the same | |
| CN112231400B (en) | Access method, device, equipment and storage medium of distributed database | |
| CN115718819B (en) | An index construction method, data reading method and index construction device | |
| CN103065067B (en) | The filter method of sequence fragment and system in short sequence assembling | |
| CN111858606A (en) | Data processing method, apparatus and electronic equipment | |
| CN113704248A (en) | Block chain query optimization method based on external index | |
| US10558636B2 (en) | Index page with latch-free access | |
| EP3955256A1 (en) | Non-redundant gene clustering method and system, and electronic device | |
| US9471612B2 (en) | Data processing method, data query method in a database, and corresponding device | |
| EP3736705A1 (en) | Date query method and device | |
| CN117786237A (en) | Data processing methods and devices, electronic equipment, computer-readable storage media | |
| US20250390495A1 (en) | Database management apparatus and method | |
| CN115374129B (en) | Database joint index coding method and system | |
| CN114090837B (en) | Graph data query method and device, computer equipment and storage medium | |
| CN115880508A (en) | Image data processing method, device, equipment and storage medium | |
| CN115408428A (en) | Data query method and device | |
| CN112527950B (en) | Map data deleting method and system based on MapReduce |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |