Data positioning method and device, equipment and storage medium
By orderly dividing the database data and recording historical search information, the problem of the B+ tree structure taking a long time to process data in batches is solved, and the performance of data batch operations is improved.
Patent Information
- Application Number
- CN202411105909.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-12-03
AI Technical Summary
In a database system, when processing data in batches, when using the B+ tree structure to insert, delete or update data, each row of data needs to be searched in a complete manner, resulting in a long time.
By dividing the data in an orderly manner and recording the historical search information of the data, the historical search information is used to reduce the number of data comparisons in the tree structure during the search process, and improve the performance of data batch operations.
It effectively reduces the time-consuming operation of batch insertion, deletion, update, etc. of data, and improves the performance of the database system.
Smart Images

Figure CN119066067A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of database technology, and in particular to a data locating method, device, equipment and storage medium. Background Art
[0002] In database systems, B+ trees are often used as index structures to store data in tables. The B+ tree structure can be used to quickly retrieve the data page address where a row of data in a table is located. When inserting, deleting, or updating data in a data table, you first need to search the B+ tree to locate the leaf-level data page where the data to be inserted, deleted, or updated is located, and then insert, delete, or update the data in the data page. When batch processing data, the B+ tree needs to be completely searched from top to bottom for each row of data, which is a very time-consuming process. Summary of the invention
[0003] The embodiments of the present invention provide a data positioning method, device, equipment and storage medium. When processing data in batches, the data is divided into orderly groups and historical search information of the data is recorded. The historical search information is used to reduce the number of comparisons of data in the tree structure during the retrieval process, thereby improving the performance of operations such as batch insertion, deletion and update of data.
[0004] In a first aspect, an embodiment of the present invention provides a data positioning method, the method comprising:
[0005] Acquire a plurality of data to be processed; the data to be processed includes an index value;
[0006] Dividing the data to be processed based on the index value to obtain at least one subset;
[0007] Determine whether there is historical search information in the subset;
[0008] If it exists, obtain the historical search information;
[0009] The location information of the data to be processed is determined based on the historical search information and the index value of the data to be processed, and the location information is saved in the historical search information.
[0010] In a second aspect, an embodiment of the present invention further provides a data locating device, the device comprising:
[0011] A data acquisition module, used to acquire a plurality of data to be processed; the data to be processed includes an index value;
[0012] A data partitioning module, used for partitioning the data to be processed based on the index value to obtain at least one subset;
[0013] A judgment module, used for judging whether there is historical search information in the subset;
[0014] A historical search information module, used to obtain the historical search information when it exists;
[0015] A data locating module is used to determine the location information of the data to be processed based on the historical search information and the index value of the data to be processed, and save the location information into the historical search information.
[0016] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0017] one or more processors;
[0018] a storage device for storing one or more programs,
[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the data positioning method provided by the embodiment of the present disclosure.
[0020] In a fourth aspect, the embodiments of the present disclosure further provide a storage medium containing computer executable instructions, which, when executed by a computer processor, are used to implement the data locating method provided by the embodiments of the present disclosure.
[0021] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, the computer program product including a computer program, and when the computer program is executed by a processor, the data positioning method provided in the embodiment of the first aspect is implemented.
[0022] The present invention discloses a data positioning method, device, equipment and storage medium, the method comprising: obtaining a plurality of data to be processed; the data to be processed include an index value; dividing the data to be processed based on the index value to obtain at least one subset; judging whether there is historical search information in the subset; if there is, obtaining the historical search information; determining the location information of the data to be processed based on the historical search information and the index value of the data to be processed, and saving the location information to the historical search information. Utilizing this method: when batch processing data, by orderly dividing the data and recording the historical search information of the data, the historical search information is used to reduce the number of comparisons of data in the tree structure during the retrieval process, thereby improving the performance of operations such as batch insertion, deletion, and update of data. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0024] Figure 1 A flow chart of a data positioning method provided by an embodiment of the present disclosure;
[0025] Figure 2 An example diagram of data partitioning provided by an embodiment of the present disclosure;
[0026] Figure 3 An example diagram of a B+ tree structure provided by an embodiment of the present disclosure;
[0027] Figure 4 A schematic diagram of the structure of a data positioning device provided by an embodiment of the present disclosure;
[0028] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0029] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0030] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0031] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0032] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0033] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0034] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0035] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0036] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0037] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0038] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0039] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0040] Embodiment 1
[0041] Figure 1 A flowchart of data positioning is provided in an embodiment of the present disclosure. The embodiment of the present disclosure is applicable to providing solutions to problems of batch data insertion, deletion, update and other operations. The method can be executed by a data positioning device, which can be implemented in the form of software and / or hardware, and optionally, by an electronic device, which can be a mobile terminal, a PC or a server, etc.
[0042] like Figure 1As shown, a data positioning method provided by an embodiment of the present disclosure may specifically include the following steps:
[0043] S110: Acquire a plurality of data to be processed.
[0044] The data to be processed includes index values.
[0045] In this embodiment, the data to be processed is data that needs to be located at the data tree position. The data tree can be a tree-type data structure such as a B+ tree. The index value is the value of the index column of the data to be processed. For example, assuming that there is a TEST table, which contains three columns C1, C2 and C3, the C1 column can be used as the index column, and the value on the C1 column of the data to be processed is used as the index value of the data to be processed.
[0046] S120. Divide the data to be processed based on the index value to obtain at least one subset.
[0047] The subsets include: the subset with increasing index value and the subset with decreasing index value.
[0048] In this embodiment, the subset with increasing index value may be a subset of the data to be processed arranged in ascending order according to the index value. Similarly, the subset with decreasing index value may be a subset of the data to be processed arranged in descending order according to the index value.
[0049] Specifically, the data is segmented according to the index value of the data to be processed, and the data is divided into different data subsets according to the sequence.
[0050] Based on the above embodiment: the processing method of any data to be processed is as follows:
[0051] a1) Determine whether the index value of the current data to be processed is consistent with the arrangement of the current subset.
[0052] In this embodiment, the arrangement direction is that the index value increases or decreases. The arrangement mode of the current subset is consistent with that the index value is greater than the index value of the previous data to be processed when increasing, and is less than the index value of the previous data to be processed when decreasing.
[0053] b1) If they are consistent, the current data to be processed is added to the current subset.
[0054] c1) If they are inconsistent, stop adding the data to be processed to the current subset, and use the current data to be processed as the starting position of the new subset.
[0055] Specifically, determine whether the index value of the current data to be processed is consistent with the arrangement of the current subset. If it is consistent, add the current data to be processed to the current subset. If it is inconsistent, stop adding the data to be processed to the current subset and use the current data to be processed as the starting position of the new subset.
[0056] Figure 2 This is an example diagram of data division provided by the embodiment of the present disclosure. Figure 2 As shown, for example: 10 rows of data need to be inserted into the TEST table, where the values of the index column are 14, 16, 22, 65, 73, 7, 6, 4, 20, and 54, respectively. After data division, three subsets are obtained.
[0057] On the basis of the above embodiment, before dividing the data to be processed based on the index value, the method further includes: sorting the data to be processed from small to large or from large to small according to the index value.
[0058] Specifically, in this embodiment, in order to make the data to be processed orderly, all the data may be directly sorted so that all the data to be processed are arranged from small to large or from large to small.
[0059] S130: Determine whether there is historical search information in the subset.
[0060] In this embodiment, the historical search information is the location information of the data processed in the subset before the data to be processed in the processing subset, or the search information.
[0061] Specifically, this step is mainly used to determine whether there is search location information of the data to be processed in the subset. It can also be said that it is to determine whether it is the first data to be processed in the current subset. The initial historical search information of the current subset is an empty set. When the data to be processed in the subset is located, the location results are stored in the historical search information in sequence.
[0062] S140. If available, obtain historical search information.
[0063] Specifically, this step is used to obtain historical search information when historical search information exists.
[0064] S150 . Determine location information of the data to be processed based on the historical search information and the index value of the data to be processed, and save the location information in the historical search information.
[0065] In this embodiment, the location information of the data to be processed needs to include the level of each data page, the data page identifier and the slot number (the leaf layer does not record the slot number). In each data page, a storage space is used to record the offset position of each data in the page. The storage space includes multiple slots, each slot corresponds to a slot number, and all slots record the offset position of each data in the order of the data in the page from small to large. The data page identifier can include the data file number and the data page number where the data page is located.
[0066] For example, Figure 3This is an example diagram of the B+ tree structure provided by the embodiment of the present disclosure, such as Figure 3 As shown, for example: in the page slot of page2: slot 1 records the offset position of data 8 in the current data page, and slot 2 records the offset position of data 12 in the current data page. In the page slot of page5: slot 1 records the offset position of data 3 in the current data page, and slot 2 records the offset position of data 5 in the current data page.
[0067] In this embodiment, the slot number registration method is: if the current interval is an increasing interval, the smaller one of the two slot numbers is registered; if the current interval is a decreasing interval, the larger one of the two slot numbers is registered.
[0068] For example, Figure 3 As shown, assuming that the index value of the current data to be processed is 14, there are slots 1 and 2 on the first-level root page, and the binary search slot number range is [0,3], where the data corresponding to slot 0 is considered to be smaller than 14, and the data corresponding to slot 3 is considered to be larger than 14. According to the binary search method, it can be located between [0,1], and the interval where 14 is located is an increasing interval, so the smaller of the two slot numbers is registered, which is slot 0. Similarly, in the second layer, according to the binary search method, it can be located between [2,3], which is slot 2. After the positioning is completed, the search information of the current data is added to the historical search information. The search information of the current data is as follows:
[0069] Layer 1 (root page layer): data page identifier of page1, slot 0
[0070] Layer 2: data page identifier of page2, slot 2
[0071] Layer 3 (leaf layer): data page identifier of page7.
[0072] In this embodiment, since the historical search information is mainly used to assist in quickly locating the leaf layer nodes corresponding to the data to be processed, and the historical search information mainly contains information on layers other than the leaf layer, the leaf layer information may not be recorded in the data search information, and only the search information on layers other than the leaf layer may be recorded.
[0073] Specifically, according to the different situations of the latest positioning information in the historical search information, it is divided into multiple situations. The current latest positioning information is judged to meet the situation and compared with the index value of the data to be processed. The location information of the data to be processed is determined according to the comparison result and the binary search method, and the location information is saved in the historical search information.
[0074] Based on the above embodiment, determining the location information of the data to be processed based on the historical search information and the index value of the data to be processed may include the following steps:
[0075] a2) Determine the retrieval page based on the historical search information and the index value of the data to be processed.
[0076] b2) Determine the location information of the data to be processed based on the search page.
[0077] In this embodiment, the search page is the data page from which the search starts.
[0078] Specifically, according to the different situations of the latest positioning information in the historical search information, it is divided into multiple situations. The situation that the current latest positioning information meets is judged and compared with the index value of the data to be processed to determine the retrieval page, and then the binary search method is used to continue to locate the location information of the subsequent data pages from the retrieval page.
[0079] Based on the above embodiment, the steps of determining the search page based on the historical search information and the index value of the data to be processed are as follows:
[0080] a21) When there is a first data page that has been hit continuously for a first set number of times in the historical search information, it is determined whether the index value of the data to be processed is within the index value range of the first data page.
[0081] a22) If the index value is within the index value range of the first data page, the first data page is used as the search page; otherwise, the root page of the data tree is used as the search page.
[0082] a23) If the first data page that has been hit for a set number of consecutive times does not exist in the historical search information, the root page is used as the search page.
[0083] In this embodiment, the first set number of times may be a pre-set number of times, which is set according to actual needs and is not specifically limited in this embodiment. The first data page may be a data page of other layers except the root page layer and the leaf layer.
[0084] In this implementation, the historical search information needs to be judged from the latest positioning information in sequence, that is, the data positioning information closest to the data to be processed is first judged.
[0085] Specifically, when there is a first data page that has been hit for a first set number of consecutive times in the historical search information, it is determined whether the index value of the data to be processed is within the index value range of the first data page. If the index value is within the index value range of the first data page, the first data page is used as the search page, otherwise the root page of the data tree is used as the search page. If there is no first data page that has been hit for a set number of consecutive times in the historical search information, the root page is used as the search page.
[0086] Based on the above embodiment, the steps of determining the location information of the data to be processed based on the search page are as follows:
[0087] b21) Obtain the second data page in the historical search information at the same level as the search page
[0088] b22) Match the second data page with the search page
[0089] b23) If there is no match, the location information of the data to be processed is determined in sequence based on the binary search method
[0090] b24) If a match is found, obtain the first slot number information corresponding to the search page in the historical search information
[0091] b25) Determine the second slot number information of the data to be processed on the retrieval page according to the first slot number information.
[0092] b26) Take the next-level data page corresponding to the second slot number information of the retrieval page as the retrieval page, and return to execute the step of obtaining the second data page with the same level as the retrieval page in the historical search information, and stop when the level of the retrieval page is the leaf layer, and obtain the location information of the data to be processed.
[0093] In this embodiment, the second data page is a data page at the same level as the search page in the historical search information. The first slot number information may be the slot number information corresponding to the level of the second data page. The second slot number information may be the slot number information corresponding to the level of the search page where the data to be processed is located.
[0094] Obtain the second data page at the same level as the retrieval page in the historical search information, and match the second data page with the retrieval page. If there is no match, determine the location information of the data to be processed in sequence based on the binary search method. If there is a match, obtain the first slot number information corresponding to the retrieval page in the historical search information, determine the second slot number information according to the hit situation of the first slot number information, use the next-level data page corresponding to the second slot number information of the retrieval page as the retrieval page, and return to execute the step of obtaining the second data page at the same level as the retrieval page in the historical search information, and stop when the level of the retrieval page is a leaf layer to obtain the location information of the data to be processed.
[0095] On the basis of the above embodiment, the second slot number information of the to-be-processed data on the search page is determined according to the first slot number information by the following steps:
[0096] b251) When there is first slot number information that is hit continuously for a second set number of times in the historical search information, determine whether the index value is within the index value range interval of the first slot number information and the third slot number information that is continuously set to increase or decrease for a third time.
[0097] b252) If the index value is within the index value range, the data within the range is compared with the data to be processed to determine the second slot number information of the data to be processed on the search page.
[0098] b253) If the index value is not within the index value range, the slot number information retrieval range is determined based on the current subset, and the second slot number information of the data to be processed on the retrieval page is determined using the binary search method.
[0099] b254) When there is no first slot number information that has been hit continuously for a second set number of times in the historical search information, the steps of determining the slot number information retrieval range according to the current subset and determining the second slot number information of the data to be processed on the retrieval page by using a binary search method are executed.
[0100] In this embodiment, the second set number of times can be a pre-set number, which is set according to actual needs and is not specifically limited in this embodiment. The third continuous setting of increasing or decreasing can be a pre-set number, which is set according to actual needs and is not specifically limited in this embodiment.
[0101] Specifically, when there is first slot number information that has been hit continuously for a second set number of times in the historical search information, the third consecutive set slot number is taken forward (i.e., in the direction of decreasing slot number, forward when the index value is a decreasing subset) or backward (i.e., in the direction of increasing slot number, backward when the index value is an increasing subset), and R+1 data corresponding to the first slot number and the third consecutive set slot number R are taken out to determine whether the index value is within the index value range interval defined by the above R+1 data; if the index value is within the index value range interval, the data in the range interval is compared with the data to be processed, and based on the slot number registration method, the second slot number information of the data to be processed on the retrieval page is determined.
[0102] For example, assuming that the first slot number = 5, R = 2, and the current index value is an increasing subset, then determine whether the current index value is in the index value range corresponding to slots 5 and 7. If so, then the data corresponding to slots 5, 6, and 7 can be taken out, compared with the current index value, and the second slot number is determined according to the slot number registration method. That is, if the current index value is between the data range corresponding to slots 5 and 6, the second slot number is determined to be 5; if the current index value is between the data range corresponding to slots 6 and 7, the second slot number is determined to be 6.
[0103] If the index value is not within the index value range, the slot number information search range is determined according to the current subset, and the second slot number information of the data to be processed on the search page is determined by using a binary search method. When there is no first slot number information that hits the second set number of consecutive times in the historical search information, the steps of determining the slot number information search range according to the current subset and determining the second slot number information of the data to be processed on the search page by using a binary search method are performed.
[0104] Exemplarily, for example, if the second set number of times is 3, there is a search page slot number 4 in the historical search information, there is a search page slot number 4 in the previous search information_2 in the historical search information, and there is a search page slot number 3 in the previous search information, then it is considered that the consecutive slot numbers of slot number 4 are hit 3 times in a row. If the second set number of times is not hit in a row, the binary search slot number range is determined according to the current subset type: if it is an index value increasing subset, the binary search slot number range is determined to be [first slot number, maximum slot number on the search page + 1]; if it is a decreasing interval, the binary search slot number range is determined to be [0, first slot number]. Then, a search is performed based on binary search within the binary search slot number range until the next layer of data page is located. If the data page of the current level in the historical search information is not a search page, the binary search slot number range is determined to be [0, maximum slot number on the search page + 1], and a search is performed based on binary search within the binary search slot number range until the next layer of data page is located.
[0105] Based on the above embodiment, it also includes:
[0106] a3) If there is no historical search information, the location information of the data to be processed is determined in sequence using the binary search method.
[0107] b3) If there are concurrent operations to modify the search page, the binary search method is used to determine the location information of the data to be processed in turn.
[0108] c3) Save the location information to the historical search information.
[0109] Specifically, if there is no historical search information or there is a concurrent operation to modify the search page, data is retrieved from the root page from top to bottom according to the binary search method.
[0110] The binary search method is as follows: For example, for the root page, assuming that there are 100 slots 1-100 on it, the binary search slot number range is [0,101], where the data corresponding to slot 0 must be smaller than the index value of the data to be processed, and the data corresponding to slot 101 must be larger than the index value of the data to be processed. In the first binary search, the data corresponding to slot 50 is taken and compared with the index value of the data to be processed. If the index value of the data to be processed is larger, the data corresponding to slot 76 in the middle of [51,101] is taken and compared with the index value of the data to be processed, until the index value of the data to be processed is located in the middle of the data corresponding to two consecutive slots (for example, greater than or equal to the data corresponding to slot 60 and less than the data corresponding to slot 61). At this time, the next layer of data page of the root page can be located, and the next layer of data page can continue to be searched based on the binary search method. For example, there are slots 1 and 2 on the root page, and the binary search slot number range is [0,3]. The index value of the data to be processed can be located between the data corresponding to two consecutive slots, thereby locating the next layer of data pages until the leaf layer data page corresponding to the data to be processed is located. During the entire search process, it is necessary to record the location results of each layer of data pages, use the location results of each layer of data pages as the search information of the current data, and add the search information of the current data to the historical search information.
[0111] Based on the above embodiment, the method further includes: clearing the historical search information of a subset after processing the data in the subset, and then continuing to process the data in the next subset until all subsets are processed.
[0112] The present invention discloses a data location method, which includes: obtaining a plurality of data to be processed; the data to be processed include index values; dividing the data to be processed based on the index values to obtain at least one subset; judging whether there is historical search information in the subset; if there is, obtaining the historical search information; determining the location information of the data to be processed based on the historical search information and the index value of the data to be processed, and saving the location information to the historical search information. Using this method: when batch processing data, by dividing the data in an orderly manner and recording the historical search information of the data, using the historical search information, the number of comparisons of the tree structure in the retrieval process is reduced, and the performance of operations such as batch insertion, deletion, and update of data is improved.
[0113] Embodiment 2
[0114] Figure 4 The present invention also provides a data positioning device structure diagram, such as Figure 4 As shown, the device includes: a data acquisition module 210, a data division module 220, a judgment module 230, a history search information module 240 and a data positioning module 250.
[0115] The data acquisition module 210 is used to acquire a plurality of data to be processed; the data to be processed includes an index value;
[0116] A data partitioning module 220, configured to partition the data to be processed based on the index value to obtain at least one subset;
[0117] A determination module 230, configured to determine whether there is historical search information in the subset;
[0118] A historical search information module 240, for obtaining the historical search information when it exists;
[0119] The data positioning module 250 is used to determine the location information of the data to be processed based on the historical search information and the index value of the data to be processed, and save the location information into the historical search information.
[0120] The technical solution provided by the embodiment of the present disclosure utilizes this method: when processing data in batches, the data is divided into orderly groups and historical search information of the data is recorded. The historical search information is used to reduce the number of comparisons of data in the tree structure during the retrieval process, thereby improving the performance of operations such as batch insertion, deletion, and update of data.
[0121] Furthermore, the data partitioning module 220 may be used to:
[0122] The subsets include: an index value increasing subset and an index value decreasing subset;
[0123] The processing method for any data to be processed is as follows:
[0124] Determine whether the index value of the current data to be processed is consistent with the arrangement of the current subset;
[0125] If they are consistent, adding the current data to be processed to the current subset;
[0126] If not, stop adding the data to be processed to the current subset, and use the current data to be processed as the starting point of the new subset.
[0127] Furthermore, the data location module 250 may also be used to:
[0128] Determine a retrieval page based on the historical search information and the index value of the data to be processed;
[0129] The location information of the data to be processed is determined based on the search page.
[0130] Furthermore, the data location module 250 may be used to:
[0131] When the historical search information contains the first data page that has been hit continuously for a first set number of times, determining whether the index value of the data to be processed is within the index value range of the first data page;
[0132] If the index value is within the index value range of the first data page, the first data page is used as the search page; otherwise, the root page of the data tree is used as the search page;
[0133] If the historical search information does not contain the first data page that has been hit continuously for a set number of times, the root page is used as the search page.
[0134] Furthermore, the data location module 250 may be used to:
[0135] Acquire a second data page in the historical search information at the same level as the search page;
[0136] matching the second data page with the search page;
[0137] If there is no match, determining the location information of the data to be processed in sequence based on a binary search method;
[0138] If there is a match, obtaining the first slot number information corresponding to the search page in the historical search information;
[0139] Determine the second slot number information of the to-be-processed data on the search page according to the first slot number information;
[0140] Take the next-level data page corresponding to the slot number information of the retrieval page as the retrieval page, and return to execute the step of obtaining the second data page with the same level as the retrieval page in the historical search information, and stop when the level of the retrieval page is a leaf layer, so as to obtain the location information of the data to be processed.
[0141] Furthermore, the data location module 250 may be used to:
[0142] When the first slot number information that is hit continuously for a second set number of times exists in the historical search information, determining whether the index value is within the index value range interval of the first slot number information and the third slot number information that is set to increase or decrease continuously for a third time;
[0143] If the index value is within the index value range, compare the data within the index value range with the data to be processed to determine the second slot number information of the data to be processed in the search page;
[0144] If the index value is not within the index value range, determining the slot number information search range according to the current subset, and using a binary search method to determine the second slot number information of the to-be-processed data on the search page;
[0145] When the first slot number information that has been hit continuously for a second set number of times does not exist in the historical search information, the steps of determining the slot number information retrieval range according to the current subset and determining the second slot number information of the data to be processed on the retrieval page by using binary search are executed.
[0146] The device may also include:
[0147] The data to be processed are sorted from small to large or from large to small according to the index values.
[0148] The device may also include:
[0149] If the historical search information does not exist, the location information of the data to be processed is determined in sequence by using a binary search method;
[0150] If there is a concurrent operation to modify the search page, the location information of the data to be processed is determined in sequence using a binary search method;
[0151] The location information is saved in the historical search information.
[0152] The above device can execute the methods provided by all the above embodiments of the present invention, and has the corresponding functional modules and beneficial effects of executing the above methods. For technical details not described in detail in this embodiment, please refer to the methods provided by all the above embodiments of the present invention.
[0153] Embodiment 3
[0154] Figure 5 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is given. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0155] like Figure 5As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0156] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0157] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a data positioning method.
[0158] In some embodiments, the data location method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the data location method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the data location method in any other appropriate manner (e.g., by means of firmware).
[0159] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0160] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0161] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0162] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0163] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0164] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0165] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0166] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A data positioning method, It is characterized in that include: Get multiple data to be processed; The data to be processed includes an index value; Dividing the data to be processed based on the index value to obtain at least one subset; Determine whether there is historical search information in the subset; If it exists, obtain the historical search information; The location information of the data to be processed is determined based on the historical search information and the index value of the data to be processed, and the location information is saved in the historical search information.
2. The method according to claim 1, It is characterized in that Before dividing the data to be processed based on the index value, the method further includes: The data to be processed are sorted from small to large or from large to small according to the index values.
3. The method according to claim 1, It is characterized in that The subsets include: an index value increasing subset and an index value decreasing subset; accordingly, the to-be-processed data is divided based on the index value to obtain at least one subset, including: The processing method for any data to be processed is as follows: Determine whether the index value of the current data to be processed is consistent with the arrangement of the current subset; If they are consistent, adding the current data to be processed to the current subset; If they are inconsistent, stop adding the data to be processed to the current subset, and use the current data to be processed as the starting position of the new subset.
4. The method according to claim 1, It is characterized in that The determining the location information of the data to be processed based on the historical search information and the index value of the data to be processed includes: Determine a retrieval page based on the historical search information and the index value of the data to be processed; The location information of the data to be processed is determined based on the search page.
5. The method according to claim 4, It is characterized in that The determining of the retrieval page based on the historical search information and the index value of the data to be processed includes: When the historical search information contains the first data page that has been hit continuously for a first set number of times, determining whether the index value of the data to be processed is within the index value range of the first data page; If the index value is within the index value range of the first data page, the first data page is used as the search page; otherwise, the root page of the data tree is used as the search page; If the historical search information does not contain the first data page that has been hit continuously for a set number of times, the root page is used as the search page.
6. The method according to claim 5, It is characterized in that The determining the location information of the data to be processed based on the search page includes: Acquire a second data page in the historical search information at the same level as the search page; matching the second data page with the search page; If there is no match, determining the location information of the data to be processed in sequence based on a binary search method; If there is a match, obtaining the first slot number information corresponding to the search page in the historical search information; Determine the second slot number information of the to-be-processed data on the search page according to the first slot number information; Take the next-level data page corresponding to the second slot number information of the retrieval page as the retrieval page, and return to execute the step of obtaining the second data page with the same level as the retrieval page in the historical search information, and stop when the level of the retrieval page is a leaf layer, so as to obtain the location information of the data to be processed.
7. The method according to claim 6, It is characterized in that The determining, according to the first slot number information, the second slot number information of the to-be-processed data on the search page includes: When the first slot number information that is hit continuously for a second set number of times exists in the historical search information, determining whether the index value is within the index value range interval of the first slot number information and the third slot number information that is set to increase or decrease continuously for a third time; If the index value is within the index value range, compare the data within the index value range with the data to be processed to determine the second slot number information of the data to be processed in the search page; If the index value is not within the index value range, determining the slot number information search range according to the current subset, and using a binary search method to determine the second slot number information of the to-be-processed data on the search page; When the first slot number information that has been hit continuously for a second set number of times does not exist in the historical search information, the steps of determining the slot number information retrieval range according to the current subset and determining the second slot number information of the data to be processed on the retrieval page by using binary search are executed.
8. The method according to claim 4, It is characterized in that Also includes: If the historical search information does not exist, the location information of the data to be processed is determined in sequence by using a binary search method; If there is a concurrent operation to modify the search page, the location information of the data to be processed is determined in sequence using a binary search method; The location information is saved in the historical search information.
9. A data locating device, It is characterized in that include: A data acquisition module, used for acquiring a plurality of data to be processed; The data to be processed includes an index value; A data partitioning module, used for partitioning the data to be processed based on the index value to obtain at least one subset; A judgment module, used for judging whether there is historical search information in the subset; A historical search information module, used to obtain the historical search information when it exists; A data locating module is used to determine the location information of the data to be processed based on the historical search information and the index value of the data to be processed, and save the location information into the historical search information.
10. An electronic device, It is characterized in that The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the data locating method according to any one of claims 1 to 8.
11. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data locating method according to any one of claims 1 to 8 when executed.
Citation Information
Cited By
Record positioning method and device, equipment, storage medium and program product
CN121166737A
