Index page merging method, device, equipment and medium

Through the method of migration and logical position insertion, the problem of low consolidation efficiency of index pages in the existing technology in the existing technology, and achieved a more efficient index page merger process.

CN113656406BActive Publication Date: 2025-01-24BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110943414.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-17
Publication Date
2025-01-24
Estimated Expiration
2041-08-17

AI Technical Summary

Technical Problem

The prior art is less efficient when merging an index page with a right-side index page.

Method used

By migrating each indexing data to be merged to the right index page in batches, and based on the arrangement of the last index data of each batch of index data and the order of the arrangement of the first index data in the right index page Determine the logical position of the index data in the index page on the right, and insert the index data at the location.

Benefits of technology

The efficiency of the merger of the index page has been improved. By migration and logical position insertion methods, the method of comparison of the sequence of indexing data arrangement is reduced, thereby improving the combined efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113656406B_ABST
    Figure CN113656406B_ABST
Patent Text Reader

Abstract

The present application discloses an index page merging method, device, equipment and medium, which are applied in the field of computer technology to solve the problem of low efficiency of merging index pages into right index pages in the prior art. Specifically, each index data in the index page to be merged is migrated to the right index page in batches; for each batch of index data, based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page, the logical position of the batch of index data is determined, and the batch of index data is inserted at the logical position, thereby reducing the step of comparing the arrangement order of each index data in the index page to be merged with the arrangement order of each index data in the right index page, thereby improving the efficiency of index page merging.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an index page merging method, device, equipment and medium. Background Art

[0002] In a database, an index is a data structure that sorts one or more columns of data in a database base table. Usually, a database base table corresponds to an index tree, which includes multiple index pages. Each index page and the index data in each index page are arranged in sequence.

[0003] In actual applications, due to the characteristics of indexing and data writing, the space utilization rates of two adjacent index pages may not be high. When the space utilization rate of an index page is lower than a set threshold, an attempt will be made to merge the index page with the adjacent left index page or right index page. However, in the current index page merging method, the efficiency is low when merging an index page with the adjacent right index page. Summary of the invention

[0004] The embodiments of the present application provide an index page merging method, apparatus, device and medium to solve the problem of low efficiency in the prior art when merging an index page with a right index page.

[0005] The technical solutions provided by the embodiments of this application are as follows:

[0006] On the one hand, an embodiment of the present application provides an index page merging method, including:

[0007] Migrate each index data in the index page to be merged to the right index page of the index page to be merged in batches; wherein the number of batches is less than the total number of index data in the index page to be merged;

[0008] For each batch of index data migrated from the index page to be merged to the right index page, based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page, determine the logical position of the batch of index data relative to the first index data in the right index page, and insert the batch of index data at the logical position.

[0009] In a possible implementation manner, before each index data in the to-be-merged index page is migrated in batches to the right index page of the to-be-merged index page, the method further includes:

[0010] Determine whether the right index page of the index page to be merged meets the index page merge condition.

[0011] In a possible implementation, migrating each index data in the to-be-merged index page to the right index page of the to-be-merged index page in batches includes:

[0012] According to the set batching method, each index data in the index page to be merged is batched to obtain each batch of index data;

[0013] For each batch of index data, the current free offset in the right index page is determined, and based on the current free offset, the batch of index data is written to the right index page.

[0014] In a possible implementation, determining the logical position of the batch of index data relative to the first index data in the right index page based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page includes:

[0015] If the number of batches is 1, when it is determined that the arrangement order of the last index data in the batch of index data is smaller than the arrangement order of the first index data in the right index page, the position before the first index data in the right index page is determined as the logical position of the batch of index data relative to the first index data in the right index page;

[0016] If the number of batches is greater than 1 and less than the total number of index data in the index page to be merged, then when the batch of index data is the first batch of index data, when it is determined that the arrangement order of the last index data in the batch of index data is less than the arrangement order of the first index data in the right index page, the position in front of the first index data in the right index page is determined as the logical position of the batch of index data relative to the first index data in the right index page; when the batch of index data is not the first batch of index data, when it is determined that the arrangement order of the last index data in the batch of index data is less than the arrangement order of the first index data in the right index page, and the arrangement order of the first index data in the batch of index data is greater than the arrangement order of the last index data in the previous batch of index data, the position in front of the first index data in the right index page and behind the last index data in the previous batch of index data is determined as the logical position of the batch of index data relative to the first index data in the right index page.

[0017] In a possible implementation, inserting the batch of index data at a logical location includes:

[0018] The linked list pointer corresponding to the last index data in the batch of index data and used to point to the next index data is pointed to the offset corresponding to the logical position.

[0019] In a possible implementation, the index page merging method provided in the embodiment of the present application further includes:

[0020] In the hash index table, the index value of each index data in the index page to be merged is deleted; wherein the hash index table is a data table established based on the index values ​​corresponding to each index data whose access frequency is not less than a set threshold.

[0021] In a possible implementation, the index page merging method provided in the embodiment of the present application further includes:

[0022] Point the linked list pointer for pointing to the next index page corresponding to the left index page of the index page to be merged to the offset of the right index page of the index page to be merged;

[0023] Point the linked list pointer corresponding to the right index page of the index page to be merged and used to point to the previous index page to the offset of the left index page of the index page to be merged;

[0024] The linked list pointer corresponding to the parent node of the index page to be merged and used to point to the index page to be merged is pointed to the offset of the right index page of the index page to be merged, and the parent node of the right index page of the index page to be merged is deleted.

[0025] On the other hand, an embodiment of the present application provides an index page merging device, including:

[0026] A data migration unit, used to migrate each index data in the index page to be merged to the right index page of the index page to be merged in batches; wherein the number of batches is less than the total number of index data in the index page to be merged;

[0027] A data insertion unit is used to determine, for each batch of index data migrated from the index page to be merged to the right index page, a logical position of the batch of index data relative to the first index data in the right index page based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page, and insert the batch of index data at the logical position.

[0028] In a possible implementation manner, the index page merging device provided in the embodiment of the present application further includes:

[0029] The merge determination unit is used to determine whether the right index page of the index page to be merged meets the index page merge condition before the data migration unit migrates the index data in the index page to be merged to the right index page of the index page to be merged in batches.

[0030] In a possible implementation manner, when migrating each piece of index data in the index page to be merged to the right index page of the index page to be merged in batches, the data migration unit is specifically used to:

[0031] According to the set batching method, each index data in the index page to be merged is batched to obtain each batch of index data;

[0032] For each batch of index data, the current free offset in the right index page is determined, and based on the current free offset, the batch of index data is written to the right index page.

[0033] In a possible implementation, when determining the logical position of the batch of index data relative to the first index data in the right index page based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page, the data insertion unit is specifically used to:

[0034] If the number of batches is 1, when it is determined that the arrangement order of the last index data in the batch of index data is smaller than the arrangement order of the first index data in the right index page, the position before the first index data in the right index page is determined as the logical position of the batch of index data relative to the first index data in the right index page;

[0035] If the number of batches is greater than 1 and less than the total number of index data in the index page to be merged, then when the batch of index data is the first batch of index data, when it is determined that the arrangement order of the last index data in the batch of index data is less than the arrangement order of the first index data in the right index page, the position in front of the first index data in the right index page is determined as the logical position of the batch of index data relative to the first index data in the right index page; when the batch of index data is not the first batch of index data, when it is determined that the arrangement order of the last index data in the batch of index data is less than the arrangement order of the first index data in the right index page, and the arrangement order of the first index data in the batch of index data is greater than the arrangement order of the last index data in the previous batch of index data, the position in front of the first index data in the right index page and behind the last index data in the previous batch of index data is determined as the logical position of the batch of index data relative to the first index data in the right index page.

[0036] In a possible implementation, when inserting the batch of index data at the logical position, the data inserting unit is specifically used to:

[0037] The linked list pointer corresponding to the last index data in the batch of index data and used to point to the next index data is pointed to the offset corresponding to the logical position.

[0038] In a possible implementation manner, the index page merging device provided in the embodiment of the present application further includes:

[0039] The hash table update unit is used to delete the index value of each index data in the index page to be merged in the hash index table; wherein the hash index table is a data table established based on the index value corresponding to each index data with an access frequency not less than a set threshold.

[0040] In a possible implementation manner, the index page merging device provided in the embodiment of the present application further includes:

[0041] An index page removal unit is used to point the linked list pointer corresponding to the left index page of the index page to be merged and used to point to the next index page to the offset of the right index page of the index page to be merged; point the linked list pointer corresponding to the right index page of the index page to be merged and used to point to the offset of the left index page of the index page to be merged; point the linked list pointer corresponding to the parent node of the index page to be merged and used to point to the index page to be merged to the offset of the right index page of the index page to be merged, and delete the parent node of the right index page of the index page to be merged.

[0042] On the other hand, an embodiment of the present application provides an index page merging device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the index page merging method provided in the embodiment of the present application is implemented.

[0043] On the other hand, an embodiment of the present application further provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed by a processor, the index page merging method provided in the embodiment of the present application is implemented.

[0044] The beneficial effects of the embodiments of the present application are as follows:

[0045] In an embodiment of the present application, by migrating each index data in the index page to be merged in batches, the migration efficiency of each index data in the index page to be merged can be improved, thereby improving the efficiency of merging the index page to be merged into the right index page. Moreover, by utilizing the arrangement order of the last index data in each batch of index data to determine the logical position of the batch of index data in the right index page, the step of comparing the arrangement order of each index data in the index page to be merged with the arrangement order of each index data in the right index page can be reduced, thereby further improving the efficiency of merging the index page to be merged into the right index page.

[0046] Other features and advantages of the present application will be described in the subsequent description, and in part, will become apparent from the description, or will be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0048] Figure 1 This is a schematic diagram of a traditional process of the index page merging method in an embodiment of the present application;

[0049] Figure 2 Schematic diagram of the overall framework of the index page merging method in the embodiment of the present application;

[0050] Figure 3 This is a schematic diagram of the overview flow of the index page merging method in an embodiment of the present application;

[0051] Figure 4 This is a schematic diagram of a specific process of the index page merging method in an embodiment of the present application;

[0052] Figure 5 This is a functional structure diagram of an index page merging device in an embodiment of the present application;

[0053] Figure 6 Schematic diagram of the hardware structure of the index page merging device in the embodiment of the present application. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and beneficial effects of this application clearer, the technical solution in the embodiment of this application will be clearly and completely described below in conjunction with the drawings in the embodiment of this application. Obviously, the described embodiment is only a part of the embodiment of this application, not all the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0055] In order to facilitate those skilled in the art to better understand the present application, the technical terms involved in the present application are briefly introduced below.

[0056] 1. The index page to be merged is an index page whose space usage rate is lower than a set threshold among the multiple index pages contained in the index tree corresponding to the database base table. In the embodiment of the present application, the index page to be merged can be but is not limited to: an index page whose space usage rate is lower than 50% among the multiple index pages contained in the index tree corresponding to the database base table, etc.

[0057] 2. Index page merging conditions are conditions under which the index pages to be merged can be merged. In the embodiment of the present application, the index page merging conditions may be, but are not limited to, the remaining storage space is not less than the space occupied by the index pages to be merged, etc.

[0058] 3. Setting a batching mode is a method of batching the index data in the merged index page. In the embodiment of the present application, the batching mode may be, but is not limited to, an average batching mode, a gradually increasing batching mode, a gradually decreasing batching mode, etc.

[0059] After introducing the technical terms involved in this application, the application scenarios and design concepts of the embodiments of this application are briefly introduced.

[0060] Currently, see Figure 1 As shown, when a mobile phone, tablet computer, computer, server or other index page merging device merges an index page to be merged into the right index page of the index page to be merged, each index data in the index page to be merged is usually migrated to the right index page in sequence. When each index data is migrated, the arrangement order of the index data is compared with the arrangement order of each index data in the right index page, so as to determine the logical position of the index data in the right index page, and insert the batch of index data at the logical position. In the above index page merging method, the speed of migrating each index data in the index page to be merged to the right index page is slow, and the merging efficiency of the index pages to be merged is also low.

[0061] To this end, in an embodiment of the present application, when merging the index page to be merged into the right index page of the index page to be merged, the index page merging device can first migrate each index data in the index page to be merged to the right index page of the index page to be merged in batches, and then for each batch of index data migrated from the index page to be merged to the right index page, based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page, determine the logical position of the batch of index data relative to the first index data in the right index page, and insert the batch of index data at the logical position. In this way, by migrating each index data in the index page to be merged in batches, the migration efficiency of each index data in the index page to be merged can be improved, thereby improving the efficiency of merging the index page to be merged to the right index page, and by using the arrangement order of the last index data in each batch of index data to determine the logical position of the batch of index data in the right index page, the step of comparing the arrangement order of each index data in the index page to be merged with the arrangement order of each index data in the right index page can be reduced, thereby further improving the efficiency of merging the index page to be merged to the right index page.

[0062] After introducing the application scenarios and design concepts of the embodiments of the present application, the technical solutions provided by the embodiments of the present application are described in detail below.

[0063] In an embodiment of the present application, when the index page merging device detects that there is an index page whose space usage rate is lower than a set threshold (for example, 50%) among multiple index pages contained in the index tree corresponding to the database base table, the index page can be determined as an index page to be merged, and an attempt can be made to merge the index page to be merged with the adjacent left index page or right index page.

[0064] In actual applications, the index page merging device can first detect whether the left index page of the index page to be merged meets the index page merging condition. For example, it can detect whether the free storage space of the left index page of the index page to be merged is not less than the space occupied by the index page to be merged. When it is detected that the free storage space of the left index page is not less than the space occupied by the index page to be merged, it can be determined that the left index page of the index page to be merged meets the index page merging condition. In this case, the index page to be merged can be merged into the left index page of the index page to be merged. When it is detected that the free storage space of the left index page is less than the space occupied by the index page to be merged, it can be determined that the left index page of the index page to be merged does not meet the index page merging condition. In this case, it can be further checked. Test whether the right index page of the index page to be merged meets the index page merge condition, for example, detect whether the free storage space of the right index page of the index page to be merged is not less than the space occupied by the index page to be merged. When it is detected that the free storage space of the right index page is less than the space occupied by the index page to be merged, it can be determined that the right index page of the index page to be merged does not meet the index page merge condition. In this case, it can be determined that this index page merge has failed and the index page merge process is exited. When it is detected that the free storage space of the right index page is not less than the space occupied by the index page to be merged, it can be determined that the right index page of the index page to be merged meets the index page merge condition. In this case, the index page to be merged can be merged into the right index page of the index page to be merged.

[0065] For specific implementation, see Figure 2 As shown, the general process of the index page merging device merging the to-be-merged index page into the right index page of the to-be-merged index page is as follows:

[0066] Step 201: Migrate each index data in the index page to be merged to the right index page of the index page to be merged in batches; wherein the number of batches is smaller than the total number of index data in the index page to be merged.

[0067] In actual applications, when the index page merging device migrates each index data in the index page to be merged to the right index page of the index page to be merged in batches, the following methods may be used, but are not limited to:

[0068] First, the index page merging device batches the index data in the index page to be merged according to the set batching method to obtain batches of index data.

[0069] Optionally, in one embodiment, the index page merging device may divide each index data in the index page to be merged into a batch of index data. For example, assuming that the total number of index data in the index page to be merged is 100, the index page merging device may divide the 100 index data in the index page to be merged into only one batch, and the number of index data in the batch is 100.

[0070] In another embodiment, the index page merging device may further divide each index data in the index page to be merged into at least two batches of index data. For example, assuming that the total number of index data in the index page to be merged is 100, the index page merging device may evenly divide the 100 index data in the index page to be merged into 4 batches, with each batch containing 25 index data.

[0071] Then, the index page merging device determines the current free offset in the right index page for each batch of index data, and writes the batch of index data into the right index page based on the current free offset.

[0072] Step 202: For each batch of index data migrated from the index page to be merged to the right index page, based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page, determine the logical position of the batch of index data relative to the first index data in the right index page, and insert the batch of index data at the logical position.

[0073] In the embodiment of the present application, when the index page merging device determines the logical position of the batch of index data relative to the first index data in the right index page based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page, there may be but are not limited to the following two situations:

[0074] The first case: the batch quantity is 1.

[0075] In this case, when the index page merging device determines that the arrangement order of the last index data in the batch of index data is less than the arrangement order of the first index data in the right index page, it can determine the position in front of the first index data in the right index page as the logical position of the batch of index data relative to the first index data in the right index page.

[0076] The second case: the batch number is greater than 1 and less than the total number of index data in the index page to be merged.

[0077] In this case, if the batch of index data is the first batch of index data, the index page merging device may determine the position before the first index data in the right index page as the logical position of the batch of index data relative to the first index data in the right index page when determining that the arrangement order of the last index data in the batch of index data is smaller than the arrangement order of the first index data in the right index page;

[0078] If the batch of index data is not the first batch of index data, the index page merging device can determine the position in front of the first index data in the right index page and behind the last index data in the previous batch of index data as the logical position of the batch of index data relative to the first index data in the right index page when it is determined that the arrangement order of the last index data in the batch of index data is smaller than the arrangement order of the first index data in the right index page, and the arrangement order of the first index data in the batch of index data is greater than the arrangement order of the last index data in the previous batch of index data.

[0079] Furthermore, for each batch of index data migrated from the index page to be merged to the right index page, the index page merging device determines the logical position of the batch of index data relative to the first index data in the right index page based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page, and then inserts the batch of index data at the logical position. Specifically, the index page merging device may point the linked list pointer corresponding to the last index data in the batch of index data and used to point to the next index data to the offset corresponding to the logical position, thereby merging the batch of index data into the right index page.

[0080] In practical applications, in order to improve the efficiency of database access, the various index data with access frequencies not less than a set threshold in the multiple index pages contained in the index tree corresponding to the database base table can also be cached. Specifically, the hash algorithm can be used to calculate the index values ​​of the various index data with access frequencies not less than the set threshold, and then the index values ​​of the various index data with access frequencies not less than the set threshold can be cached in the hash index table, so that these index data can be directly retrieved from the hash index table later, thereby improving the efficiency of database access. Furthermore, in order to improve the accuracy and real-time performance of the hash index table, in the embodiment of the present application, after the index page merging device merges all the index data in the index page to be merged into the right index page, it can also delete the index values ​​of the various index data in the index page to be merged in the hash index table.

[0081] In actual applications, after the index page merging device merges all the index data in the index page to be merged into the right index page, it can also remove the index page to be merged from the index tree corresponding to the database base table. Specifically, the index page merging device can point the linked list pointer corresponding to the left index page of the index page to be merged, which is used to point to the next index page, to the offset of the right index page of the index page to be merged, and point the linked list pointer corresponding to the right index page of the index page to be merged, which is used to point to the previous index page, to the offset of the left index page of the index page to be merged, and point the linked list pointer corresponding to the parent node of the index page to be merged, which is used to point to the index page to be merged, to the offset of the right index page of the index page to be merged, and delete the parent node of the right index page of the index page to be merged, thereby achieving the purpose of removing the index page to be merged from the index tree corresponding to the database base table, and further ensuring the accuracy of the index tree corresponding to the database base table.

[0082] The following uses "MySQL database" as a specific application scenario and "batch number is 1" as an example to further describe the index page merging method provided in the embodiment of the present application. Figure 3 As shown, in the embodiment of the present application, when the index page merging device merges the index page to be merged in the index tree corresponding to the base table of the MySQL database into the right index page, each index data in the index page to be merged can be migrated in batches to the right index page of the index page to be merged, and the arrangement order of the last index data in the index page to be merged and the arrangement order of the first index data in the right index page can be used to directly determine the logical position of each index data in the index page to be merged in the right index page, thereby inserting each index data in the index page to be merged into the logical position, thereby realizing the merging of the index pages to be merged. For details, refer to Figure 4 As shown, the specific process of the index page merging method provided in the embodiment of the present application is as follows:

[0083] Step 401: When the index page merging device detects that there is an index page with a space usage rate lower than 50% among multiple index pages included in the index tree corresponding to the MySQL database base table, the index page is determined as an index page to be merged.

[0084] Step 402: the index page merging device detects whether the free storage space of the left index page of the index page to be merged is not less than the space occupied by the index page to be merged. If so, step 403 is executed; if not, step 404 is executed.

[0085] Step 403: the index page merging device merges the index page to be merged into the left index page of the index page to be merged.

[0086] Step 404: the index page merging device detects whether the free storage space of the right index page of the index page to be merged is not less than the space occupied by the index page to be merged. If so, execute step 406; if not, execute step 405.

[0087] Step 405: the index page merging device determines that the current index page merging fails, and exits the index page merging process.

[0088] Step 406: the index page merging device determines the current free offset in the right index page, and based on the current free offset, writes each index data in the index page to be merged into the right index page.

[0089] Step 407: When the index page merging device determines that the arrangement order of the last index data in the index page to be merged is smaller than the arrangement order of the first index data in the right index page, the position before the first index data in the right index page is determined as the logical position of each index data in the index page to be merged in the right index page.

[0090] Step 408: the index page merging device points the linked list pointer corresponding to the last index data in the index page to be merged and used to point to the next index data to the offset corresponding to the logical position, so as to merge all the index data in the index page to be merged into the right index page.

[0091] Step 409: The index page merging device deletes the index value of each index data in the index page to be merged in the hash index table corresponding to the MySQL database base table.

[0092] Step 410: the index page merging device points the linked list pointer for pointing to the next index page corresponding to the left index page of the index page to be merged to the offset of the right index page of the index page to be merged.

[0093] Step 411: the index page merging device points the linked list pointer corresponding to the right index page of the index page to be merged and used to point to the previous index page to the offset of the left index page of the index page to be merged.

[0094] Step 412: the index page merging device points the linked list pointer corresponding to the parent node of the index page to be merged and used to point to the index page to be merged to the offset of the right index page of the index page to be merged, and deletes the parent node of the right index page of the index page to be merged.

[0095] In summary, in an embodiment of the present application, in the process of merging the index page to be merged in the index tree corresponding to the base table of the MySQL database into the right index page, by migrating each index data in the index page to be merged to the right index page of the index page to be merged at one time, the migration efficiency of each index data in the index page to be merged can be effectively improved, thereby improving the efficiency of merging the index page to be merged into the right index page, and, by utilizing the arrangement order of the last index data in the index page to be merged and the arrangement order of the first index data in the right index page, determining the logical position of each index data in the index page to be merged relative to the first index data in the right index page, can effectively reduce the step of comparing the arrangement order of each index data in the index page to be merged with the arrangement order of each index data in the right index page, thereby further improving the efficiency of merging the index page to be merged into the right index page.

[0096] Based on the above embodiments, the present application provides an index page merging device. Figure 5 As shown, the index page merging device 500 provided in the embodiment of the present application at least includes:

[0097] The data migration unit 501 is used to migrate each index data in the index page to be merged to the right index page of the index page to be merged in batches; wherein the number of batches is less than the total number of index data in the index page to be merged;

[0098] The data insertion unit 502 is used to determine, for each batch of index data migrated from the index page to be merged to the right index page, the logical position of the batch of index data relative to the first index data in the right index page based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page, and insert the batch of index data at the logical position.

[0099] In a possible implementation, in a possible implementation, the index page merging device 500 provided in the embodiment of the present application further includes:

[0100] The merge determination unit 503 is used to determine whether the right index page of the index page to be merged meets the index page merge condition before the data migration unit 501 migrates the index data in the index page to be merged to the right index page of the index page to be merged in batches.

[0101] In a possible implementation manner, when migrating each index data in the to-be-merged index page to the right index page of the to-be-merged index page in batches, the data migration unit 501:

[0102] According to the set batching method, each index data in the index page to be merged is batched to obtain each batch of index data;

[0103] For each batch of index data, the current free offset in the right index page is determined, and based on the current free offset, the batch of index data is written to the right index page.

[0104] In a possible implementation, when determining the logical position of the batch of index data in the right index page based on the arrangement order of the last index data in the batch of index data, the data inserting unit 502 is specifically configured to:

[0105] If the number of batches is 1, when it is determined that the arrangement order of the last index data in the batch of index data is smaller than the arrangement order of the first index data in the right index page, the position before the first index data in the right index page is determined as the logical position of the batch of index data relative to the first index data in the right index page;

[0106] If the number of batches is greater than 1 and less than the total number of index data in the index page to be merged, then when the batch of index data is the first batch of index data, when it is determined that the arrangement order of the last index data in the batch of index data is less than the arrangement order of the first index data in the right index page, the position in front of the first index data in the right index page is determined as the logical position of the batch of index data relative to the first index data in the right index page; when the batch of index data is not the first batch of index data, when it is determined that the arrangement order of the last index data in the batch of index data is less than the arrangement order of the first index data in the right index page, and the arrangement order of the first index data in the batch of index data is greater than the arrangement order of the last index data in the previous batch of index data, the position in front of the first index data in the right index page and behind the last index data in the previous batch of index data is determined as the logical position of the batch of index data relative to the first index data in the right index page.

[0107] In a possible implementation, when inserting the batch of index data at the logical position, the data inserting unit 502 is specifically configured to:

[0108] The linked list pointer corresponding to the last index data in the batch of index data and used to point to the next index data is pointed to the offset corresponding to the logical position.

[0109] In a possible implementation manner, the index page merging device 500 provided in the embodiment of the present application further includes:

[0110] The hash table updating unit 504 is used to delete the index value of each index data in the index page to be merged in the hash index table; wherein the hash index table is a data table established based on the index value corresponding to each index data with an access frequency not less than a set threshold.

[0111] In a possible implementation manner, the index page merging device 500 provided in the embodiment of the present application further includes:

[0112] The index page removal unit 505 is used to point the linked list pointer corresponding to the left index page of the index page to be merged and used to point to the next index page to the offset of the right index page of the index page to be merged; point the linked list pointer corresponding to the right index page of the index page to be merged and used to point to the previous index page to the offset of the left index page of the index page to be merged; point the linked list pointer corresponding to the parent node of the index page to be merged and used to point to the index page to be merged to the offset of the right index page of the index page to be merged, and delete the parent node of the right index page of the index page to be merged.

[0113] It should be noted that the principle of solving the technical problem by the index page merging device 500 provided in the embodiment of the present application is similar to the index page merging method provided in the embodiment of the present application. Therefore, the implementation of the index page merging device 500 provided in the embodiment of the present application can refer to the implementation of the index page merging method provided in the embodiment of the present application, and the repeated parts will not be repeated.

[0114] After introducing the index page merging method and apparatus provided in the embodiment of the present application, the index page merging device provided in the embodiment of the present application is briefly introduced next.

[0115] See also Figure 6 As shown, the index page merging device 600 provided in the embodiment of the present application includes at least: a processor 601, a memory 602, and a computer program stored in the memory 602 and executable on the processor 601. When the processor 601 executes the computer program, the index page merging method provided in the embodiment of the present application is implemented.

[0116] The index page merging device 600 provided in the embodiment of the present application may also include a bus 603 connecting different components (including the processor 601 and the memory 602). The bus 603 represents one or more of several types of bus structures, including a memory bus, a peripheral bus, a local bus, and the like.

[0117] The memory 602 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 6021 and / or a cache memory 6022 , and may further include a read-only memory (ROM) 6023 .

[0118] The memory 602 may also include a program tool 6025 having a set (at least one) of program modules 6024, including but not limited to: an operating subsystem, one or more applications, other program modules and program data, each of which or some combination may include the implementation of a network environment.

[0119] The index page merging device 600 may also communicate with one or more external devices 604 (e.g., keyboards, remote controls, etc.), may also communicate with one or more devices that enable a user to interact with the index page merging device 600 (e.g., mobile phones, computers, etc.), and / or, may communicate with any device that enables the index page merging device 600 to communicate with one or more other index page merging devices 600 (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 605. In addition, the index page merging device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 606. Figure 6 As shown, the network adapter 606 communicates with other modules of the index page merging device 600 via the bus 603. It should be understood that although Figure 6 Not shown, other hardware and / or software modules may be used in conjunction with the index page merging device 600, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, disk arrays (Redundant Arrays of Independent Disks, RAID) subsystems, tape drives, and data backup storage subsystems.

[0120] It should be noted that Figure 6 The index page merging device 600 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0121] Based on the above embodiments, the embodiments of the present application further provide a computer-readable storage medium, which stores computer instructions, and when the computer instructions are executed by a processor, the index page merging method provided in the embodiments of the present application is implemented. Specifically, the computer instructions can be built-in or installed in the index page merging device 600, so that the index page merging device 600 can implement the index page merging method provided in the embodiments of the present application by executing the built-in or installed computer instructions.

[0122] In addition, the index page merging method provided in the embodiment of the present application can also be implemented as a program product, which includes a program code. When the program product can be run on the index page merging device 600, the program code is used to enable the index page merging device 600 to execute the index page merging method provided in the embodiment of the present application.

[0123] The program product provided in the embodiments of the present application may adopt any combination of one or more readable media, wherein the readable medium may be a readable signal medium or a readable storage medium, and the readable storage medium may be but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination of the above. Specifically, more specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, RAM, ROM, Erasable Programmable Read Only Memory (EPROM), optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0124] The program product provided in the embodiment of the present application may adopt a CD-ROM and include program code, and may also be run on a computing device. However, the program product provided in the embodiment of the present application is not limited thereto. In the embodiment of the present application, the readable storage medium may be any tangible medium containing or storing a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.

[0125] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.

[0126] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0127] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0128] Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the embodiments of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A method for merging index pages, characterized in that: include: When an index page whose space usage is lower than a set threshold is detected, the index page is determined as an index page to be merged; Detecting whether the left index page of the index page to be merged meets the index page merging condition; If it is determined that the left index page of the index page to be merged meets the index page merge condition, then merge the index page to be merged into the left index page of the index page to be merged; If it is determined that the left index page of the index page to be merged does not meet the index page merge condition, detecting whether the right index page of the index page to be merged meets the index page merge condition; If it is determined that the right index page of the index page to be merged meets the index page merge condition, each index data in the index page to be merged is migrated to the right index page of the index page to be merged in batches; wherein the number of batches is less than the total number of index data in the index page to be merged; For each batch of index data migrated from the index page to be merged to the right index page, based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page, determine the logical position of the batch of index data relative to the first index data in the right index page, and insert the batch of index data at the logical position.

2. The index page merging method according to claim 1, characterized in that: Migrating each index data in the index page to be merged to the right index page of the index page to be merged in batches, including: According to the set batching method, each index data in the to-be-merged index page is batched to obtain each batch of index data; For each batch of index data, a current free offset in the right index page is determined, and based on the current free offset, the batch of index data is written into the right index page.

3. The index page merging method according to claim 1, characterized in that: Determining a logical position of the batch of index data relative to the first index data in the right index page based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page includes: If the number of batches is 1, when it is determined that the arrangement order of the last index data in the batch of index data is smaller than the arrangement order of the first index data in the right index page, the position before the first index data in the right index page is determined as the logical position of the batch of index data relative to the first index data in the right index page; If the number of batches is greater than 1 and less than the total number of index data in the index page to be merged, then when the batch of index data is the first batch of index data, when it is determined that the arrangement order of the last index data in the batch of index data is less than the arrangement order of the first index data in the right index page, the position in front of the first index data in the right index page is determined as the logical position of the batch of index data relative to the first index data in the right index page; when the batch of index data is not the first batch of index data, when it is determined that the arrangement order of the last index data in the batch of index data is less than the arrangement order of the first index data in the right index page, and the arrangement order of the first index data in the batch of index data is greater than the arrangement order of the last index data in the previous batch of index data, the position in front of the first index data in the right index page and behind the last index data in the previous batch of index data is determined as the logical position of the batch of index data relative to the first index data in the right index page.

4. The index page merging method according to claim 1, characterized in that: Inserting the batch of index data at the logical position includes: The linked list pointer corresponding to the last index data in the batch of index data and used to point to the next index data is pointed to the offset corresponding to the logical position.

5. The index page merging method according to any one of claims 1 to 4, characterized in that: Also includes: In the hash index table, the index value of each index data in the index page to be merged is deleted; wherein the hash index table is a data table established based on the index values ​​corresponding to each index data whose access frequency is not less than a set threshold.

6. The index page merging method according to any one of claims 1 to 4, characterized in that: Also includes: Point the linked list pointer for pointing to the next index page corresponding to the left index page of the index page to be merged to the offset of the right index page of the index page to be merged; Point the linked list pointer corresponding to the right index page of the index page to be merged and used to point to the previous index page to the offset of the left index page of the index page to be merged; The linked list pointer corresponding to the parent node of the index page to be merged and used to point to the index page to be merged is pointed to the offset of the right index page of the index page to be merged, and the parent node of the right index page of the index page to be merged is deleted.

7. An index page merging device, characterized in that: include: The data migration unit is used to determine the index page as the index page to be merged when detecting the index page whose space usage rate is lower than the set threshold; Detecting whether the left index page of the index page to be merged meets the index page merging condition; If it is determined that the left index page of the index page to be merged meets the index page merge condition, then merge the index page to be merged into the left index page of the index page to be merged; If it is determined that the left index page of the index page to be merged does not meet the index page merge condition, detecting whether the right index page of the index page to be merged meets the index page merge condition; If it is determined that the right index page of the index page to be merged meets the index page merge condition, each index data in the index page to be merged is migrated to the right index page of the index page to be merged in batches; wherein the number of batches is less than the total number of index data in the index page to be merged; A data insertion unit is used to determine, for each batch of index data migrated from the index page to be merged to the right index page, a logical position of the batch of index data relative to the first index data in the right index page based on the arrangement order of the last index data in the batch of index data and the arrangement order of the first index data in the right index page, and insert the batch of index data at the logical position.

8. An index page merging device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the index page merging method according to any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the index page merging method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • File system, main storage and flash storage for progressive indexing and data management method using the progressive indexing

    KR1020090099390A