Data block splitting method and device, equipment, medium and product
By modifying the meta information of the intermediate file and migrating part of the data to the next data layer during the data block splitting process, the problem of read and write amplification in the prior art is solved, and the efficiency of data block splitting is improved.
Patent Information
- Application Number
- CN202410917850.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-09
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-07-09
AI Technical Summary
The prior art has large read and write amplification during data block splitting, resulting in inefficiency.
By determining the data block to be split and the key interval, the meta information of the intermediate file is modified to the target data block identification, and partial keys and data are migrated to the next data layer, reducing unnecessary data read and write operations.
It significantly reduces read and write amplification during data block splitting, and improves splitting speed and efficiency.
Smart Images

Figure CN118885113A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of data processing technology, and in particular, to a data block splitting method, device, equipment, medium and product. Background Art
[0002] Existing key-value storage systems, such as the key-value storage system built on RocksDB, divide the entire data range into a series of continuous data blocks according to the prefix range of the key. Each data block is described by a left-closed and right-open interval, such as [start key, split key). Each data block includes several data files, and each data file corresponds to a key interval. When the amount of data in a data block increases to a certain extent, it is necessary to perform a split operation on the data block, that is, find a split key in the middle of the data block and split the data between the start key and the split key from the original data block.
[0003] However, in the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0004] When performing data block splitting, the existing technology needs to read all data files within [start key, split key), and then perform recursive merging, redundant deletion and other operations on the data in this range to obtain new data blocks. Therefore, this process will cause large read and write amplification. Summary of the invention
[0005] Embodiments of the present invention provide a data block splitting method, device, equipment, medium and product to reduce the read-write amplification generated during the data block splitting process.
[0006] In a first aspect, an embodiment of the present invention provides a data block splitting method, the method comprising:
[0007] Determine a first data block to be split in the current data layer, and a first data file combination and a first split key interval corresponding to the first data block to be split;
[0008] For the first data file combination, a data file in which all keys are distributed in the first split key interval is used as a first intermediate file, and a data file in which some keys are distributed in the first split key interval is used as a first end file;
[0009] Modify the data block identifier in the meta information of the first intermediate file to the first target data block identifier;
[0010] Migrate some keys in the first end file that belong to the first split key interval and the data corresponding to the some keys to the corresponding file of the next data layer, and set the data block identifier in the metadata of the file to the first target data block identifier.
[0011] In a second aspect, an embodiment of the present invention further provides a data block splitting device, including:
[0012] A first response module, configured to determine a first data block to be split in a current data layer, and a first data file combination and a first split key interval corresponding to the first data block to be split;
[0013] A first file determination module is used for, for the first data file combination, taking a data file whose keys are all distributed in the first split key interval as a first intermediate file, and taking a data file whose keys are partially distributed in the first split key interval as a first end file;
[0014] A first identifier modification module, used to modify the data block identifier in the meta information of the first intermediate file to a first target data block identifier;
[0015] The first compaction module is used to migrate some keys in the first split key interval and the data corresponding to the some keys in the first end file to the corresponding file of the next data layer, and set the data block identifier in the metadata of the file to the first target data block identifier.
[0016] In a third aspect, an embodiment of the present invention provides an electronic device, the electronic device comprising:
[0017] one or more processors;
[0018] A memory 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 block splitting method provided by any embodiment of the present invention.
[0020] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a data block splitting method as provided in any embodiment of the present invention.
[0021] In a fifth aspect, an embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements a data block splitting method as provided in any embodiment of the present invention.
[0022] The embodiments of the above invention have the following advantages or beneficial effects:
[0023] After the first data file combination and the first split key interval corresponding to the first data block to be split are determined, for each data file in the first data file combination, if all its keys are distributed in the first split key interval, it is used as an intermediate file and retained in the current data layer, and only the data block identifier in its meta information is modified to the target data block identifier; since the intermediate file does not need to be read during the meta information modification process of the intermediate file, no read-write amplification will occur; if only part of the keys in the data file are distributed in the first split key interval, the part of the keys distributed in the first split key partial interval and the data corresponding to the part of the keys are migrated to the corresponding file of the next data layer, and the data block identifier in the meta information of the file is modified to the first target data block identifier. Since each data file in the key-value storage system is small, the first end file is also small, and the data corresponding to the data in the split key interval in the first end file is smaller. Compared with the existing data block splitting method that needs to read all the split data, this embodiment only needs to perform compaction operations on the data in the split key interval in the first end file, so the read-write amplification in the data block splitting process can be greatly reduced, and the data block splitting speed can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is a flowchart of a data block splitting method provided by an embodiment of the present invention;
[0025] Figure 2 It is another flow chart of the data block splitting method provided by an embodiment of the present invention;
[0026] Figure 3 is a schematic diagram of the structure of a data block splitting device provided by an embodiment of the present invention;
[0027] Figure 4 It is another structural schematic diagram of a data block splitting device provided by an embodiment of the present invention;
[0028] Figure 5 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0029] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0030] Figure 1The flowchart of the data block splitting method provided by the embodiment of the present invention is applicable to the case of automatically completing the data block splitting operation of the key-value storage system. The method can be executed by a data block splitting device integrated in an electronic device, and the device can be implemented by software and / or hardware. Figure 1 As shown, the method specifically comprises the following steps:
[0031] S110, determining a first data block to be split in the current data layer, and a first data file combination and a first split key interval corresponding to the first data block to be split.
[0032] A key-value storage system stores data as a collection of key-value pairs, where the key acts as a unique identifier for the value. Both the key and the value can be objects of any type. A key-value storage system usually includes multiple data layers, such as L0, L1, L2, etc.
[0033] In this embodiment, a data layer is used to store one or more complete data blocks and / or partial data in one or more complete data blocks. The data of a data block can be stored in one or more data layers. A data block usually includes multiple data files, and different data files correspond to different key intervals. Among them, the data file is a file used by the data block to store data. The data storage capacity of any data file cannot exceed the corresponding file data volume threshold, and the data storage capacity of each data layer cannot exceed the corresponding layer data volume threshold. The layer data volume thresholds of different data layers are different. For example, as the data layer identifier is larger, the layer data volume threshold corresponding to its corresponding data layer is larger.
[0034] The splitting instruction for triggering the corresponding data block splitting operation can be manually triggered by the user or automatically triggered by the key-value storage system. For the latter, the existing data block splitting triggering condition can be used to trigger the splitting instruction, which is not specifically limited in this embodiment.
[0035] The split key interval can be understood as the key interval corresponding to the data to be split from the first data block to be split. The split key interval can be expressed as [start key, end key).
[0036] After the first data block to be split is determined, the first data file combination and the first split key interval corresponding to the first data block to be split are determined. The first data file combination includes at least one data file. The larger the split key interval, the more corresponding data files will be. Conversely, the smaller the split key interval, the smaller the corresponding data files will be.
[0037] S120. For the first data file combination, a data file in which all keys are distributed in the first split key interval is used as a first intermediate file, and a data file in which some keys are distributed in the first split key interval is used as a first end file.
[0038] In a key-value storage system, the keys in each data file are stored in order, such as in ascending order. Therefore, if some keys are distributed in the first split key interval, it means that some keys are not distributed in the first split key interval, and there is a clear split key between the part of the key and the remaining part of the key, and the split key is the start key or end key of the first split key interval.
[0039] In one embodiment, the first end file includes a first starting file and / or a first ending file; the starting key and the ending key of the first split key interval are determined; the data file corresponding to the key interval spanning the starting key is used as the first starting file, and the data file corresponding to the key interval spanning the ending key is used as the first ending file.
[0040] Among them, crossing can be understood as crossing the set limit. In this embodiment, it means crossing the start key or the end key. Taking the start key as an example, for a data file including a start key or an end key, if the start key is located at the starting end point of the key interval corresponding to a certain data file, then the data file should not be considered to have crossed the start key, so it is the first intermediate file, not the first start file. If the start key is located in the middle of the key interval corresponding to a certain data file, it is determined that the data file has crossed the start key and is the first start file.
[0041] In one embodiment, the starting key and the ending key of the first split key interval, as well as the minimum key and the maximum key of each data file are determined; the data file whose minimum key is smaller than the starting key and the maximum key is larger than the ending key is used as the first starting file; the data file whose minimum key is smaller than the ending key and the maximum key is larger than the ending key is used as the first ending file.
[0042] Specifically, the minimum key of the first split key interval is used as the starting key, and the maximum key of the first split key interval is used as the ending key. Determine the file identifier of each data file and the key interval corresponding to each data file. The left-end key of the key interval is used as the minimum key, and the right-end key of the key interval is used as the maximum key. The file identifier of each data file, the minimum key and the maximum key of the key interval corresponding to each data file are used as an element, and the elements corresponding to each data file in the first data block to be split are summarized into an array, and the array is used as the target array. Exemplarily, the target array can be expressed as [(1, key11, key12), (2, key21, key21)…(n, keyn1, keyn2)]. Among them, (n, keyn1, keyn2) is an element, in which n is the data file identifier, keyn1 represents the minimum key of the key interval corresponding to the data file identified as n, and keyn2 represents the minimum key of the key interval corresponding to the data file identified as n.
[0043] Traverse the target array. If the minimum key of the data file corresponding to any file identifier is less than the start key, and the maximum key is greater than the start key, it indicates that the key range corresponding to the data file spans the start key. This also makes all keys between the start key and the maximum key belong to the first split key range. Therefore, this data file is used as the first start file. If the minimum key of the data file corresponding to any file identifier is less than the end key, and the maximum key is greater than the end key, it indicates that the key range corresponding to the data file spans the end key. This also makes all keys between the minimum key and the end key belong to the first split key range. Therefore, this data file is used as the first end file.
[0044] In one embodiment, a data file with both the minimum key and the maximum key distributed between the start key and the end key is used as the first intermediate file.
[0045] Exemplarily, the current file identifier is n, the corresponding minimum key is keyn1, and the maximum key corresponding to the current file identifier is keyn2. If start key ≤ keyn1 < keyn2 ≤ end key is satisfied, it is determined that the data file with the identifier n is the intermediate file.
[0046] By summarizing the file identifiers of each data file in the first data block to be split, the minimum key and the maximum key of each data file corresponding to the key range into a target array, the query speed of the minimum key and the maximum key of each data file is improved; by comparing the size relationship between the maximum key and the minimum key corresponding to each data file in the first data block to be split with the start key and the end key of the first split key range respectively, the first start file and / or the first end file in the first data block to be split are determined, and when necessary, the first intermediate file is determined, which improves the determination speed and accuracy of the first intermediate file and the first end file.
[0047] S130. Modify the data block identifier in the meta information of the first intermediate file to the first target data block identifier.
[0048] Since the key range corresponding to the first intermediate file is within the first split key range, before and after the data block split, except for the change of the data block identifier, the first intermediate file does not change in other aspects. For this reason, in this embodiment, the intermediate file is not read, and only the data block identifier in the meta information of the first intermediate file is modified to the first target data block identifier to reduce unnecessary data reading and writing during the data block split, thereby reducing the read / write amplification during the data block split.
[0049] It can be understood that the larger the first split key interval is, the greater the number of corresponding first intermediate files will be. The greater the number of first intermediate files is, the greater the reduction in read-write amplification in the data block splitting process compared with the prior art, because the prior art needs to read all the data that needs to be split out in the first data block to be split, that is, it needs to read all the first intermediate files and the first end files.
[0050] Among them, read and write amplification includes read amplification and write amplification. Read amplification can be understood as: when performing a read operation in flash memory, additional operations may be involved to meet specific read requirements. For example, when a certain data needs to be read, if there is other irrelevant data in the storage unit where the data is located, in order to read the data, the entire storage unit must be read at the same time, and subsequent operations also need to process the redundant irrelevant data. In this case, read amplification occurs. Among them, the storage unit is the smallest data storage unit in the corresponding data processing scenario.
[0051] Write amplification can be understood as: when performing a write operation in flash memory, additional operations may be required before actually writing a piece of data. For example, before writing a new piece of data in flash memory, the old data to be replaced must be erased first. In this way, multiple erase and write operations may be involved before actually writing a new piece of data, which leads to the problem of write amplification.
[0052] In one embodiment, setting the data block identifier in the metadata of the first intermediate file as the target data block identifier is completed by the following steps:
[0053] Step a1: Delete the meta information of the first intermediate file from the manifest file.
[0054] The list file records the meta information of each data file, and the meta information of each data file includes the latest status information of the corresponding data file, such as the data layer where the data file is located, the corresponding data block identifier, the latest modification time, etc. In this embodiment, the meta information of the first intermediate file is first deleted from the list file to update the list file. It can be understood that the updated list file does not include the meta information of the first intermediate file.
[0055] Step a2: modify the data block identifier in the meta-information of the first intermediate file to the first target data block identifier, so as to update the meta-information of the first intermediate file.
[0056] Since the first intermediate file does not need to be read during the process of modifying the first to-be-split data block identifier in the meta-information of the first intermediate file to the first target data block identifier, there is no read-write amplification in the process.
[0057] Step a3: Add the updated meta information of the first intermediate file to the manifest file to update the manifest file.
[0058] Since the updated meta information of the first intermediate file includes the target data block identifier, the updated meta information of the first intermediate file is added to the manifest file and persisted in the manifest file. In this way, the manifest file records the latest status of the first intermediate file, which facilitates the status tracing of the first intermediate file and subsequent data use.
[0059] S140. Migrate some keys and data corresponding to some keys in the first end file that belong to the first split key interval to the corresponding file of the next data layer, and set the data block identifier in the meta information of the file to the first target data block identifier.
[0060] The keys in the first split key interval in the first end file can be understood as the keys between the start key and the maximum key in the first end file, wherein the start key is the minimum key in the first key interval, and the maximum key is the maximum key in the first end file.
[0061] In one embodiment, the keys in the first end file that belong to the first split key interval are used as the key combination to be migrated; the data file in the next data layer corresponding to the current data layer that has keys overlapping with the key combination to be migrated is used as the target file; the merge sort algorithm is used to merge the key to be migrated with all the keys in the target file to obtain a merge result; the merge result is stored in the target file of the next data layer. This embodiment uses the merge sort algorithm to merge the key to be migrated with all the keys in the target file, so that the data to be migrated is stored in the target file in an orderly manner, which helps to improve the key query speed, thereby improving the key value reading speed.
[0062] It should be noted that if the first data file combination includes only the first end file but not the first intermediate file, the data in the first end file that is within the first split key interval is directly migrated to the next data layer corresponding to the value.
[0063] In this embodiment, the data block identifiers of the first intermediate file and the first end file are both target data block identifiers, the first intermediate file is located in the current data layer, and the first end file is located in the next data layer, completing the data splitting operation of splitting the data block corresponding to the target data identifier from the above-mentioned first data block to be split.
[0064] In one embodiment, the target data block identifier is determined based on the first data block identifier to be split. The target data block identifier includes a first field and a second field, the first field is a target field inherited from the first data block identifier to be split, and the target field includes the second field in the first data block identifier to be split. Therefore, the data block identifier can reflect the relationship between data blocks, or the early and late relationship between the generation times of different data blocks. For example, the target data block is split from the first data block to be split, and can be regarded as a sub-data block of the first data block to be split, and the generation time of the target data block is later than that of the first data block to be split.
[0065] According to the technical solution provided by the embodiment of the present invention, after the first data file combination and the first split key interval corresponding to the first data block to be split are determined, for each data file in the first data file combination, if all its keys are distributed in the first split key interval, it is used as an intermediate file and retained in the current data layer, and only the data block identifier in its meta information is modified to the target data block identifier; since the intermediate file does not need to be read during the meta information modification process of the intermediate file, no read-write amplification will be generated; if only part of the keys in the data file are distributed in the first split key interval, the part of the keys distributed in the first split key part interval and the data corresponding to the part of the keys are migrated to the corresponding file of the next data layer, and the data block identifier in the meta information of the file is modified to the first target data block identifier; since each data file in the key-value storage system is small, the first end file is also small, and the data corresponding to the data in the first split key interval in the first end file is smaller. Compared with the existing data block splitting method that needs to read all the split data, this embodiment only needs to perform a compaction operation on the data in the first split key interval in the first end file, so the read-write amplification in the data block splitting process can be greatly reduced, and the data block splitting speed can be improved.
[0066] Figure 2 Another flow chart of the data block splitting method provided by an embodiment of the present invention. This embodiment adds an automatic completion of the data block splitting operation of the next data layer corresponding to the current data layer on the basis of the previous embodiment. Figure 2 As shown, the method includes:
[0067] S210. Determine a first data block to be split in the current data layer, and a first data file combination and a first split key interval corresponding to the first data block to be split.
[0068] S220. For the first data file combination, a data file in which all keys are distributed in the first split key interval is used as a first intermediate file, and a data file in which some keys are distributed in the first split key interval is used as a first end file.
[0069] S230: Modify the data block identifier in the meta-information of the first intermediate file to the first target data block identifier.
[0070] S240. Migrate some keys and data corresponding to some keys in the first end file that belong to the first split key interval to the corresponding file of the next data layer, and set the data block identifier in the meta information of the file to the first target data block identifier.
[0071] S250. If the data migrated to the next data layer makes the next data layer meet the predetermined data block splitting condition, then determine the second data block to be split in the next data layer, and the second data file combination and the second split key interval corresponding to the second data block to be split. The second split key interval is greater than or equal to the partial key interval. The partial key interval is the key interval of some keys in the first end file distributed in the first split key interval.
[0072] The data block splitting condition is set as an existing data block splitting triggering condition, such as the scheduled splitting time reaching, the data layer score reaching a set threshold, etc. The score of each data block is based on the number of files or the amount of stored data in each data layer.
[0073] Since part of the data is merged into the next data layer during the data block splitting process of the current data layer, this will inevitably lead to a change in the number of files or data storage volume of the next data layer, and this change may cause the data score of the next data layer to reach a set threshold. In one embodiment, when it is detected that the data score of the next data layer reaches the set threshold, it is determined that the next data layer meets the set data splitting condition, and thus a second splitting instruction for the second data block in the next data layer is generated, and the second splitting key interval corresponding to the second splitting instruction is greater than or equal to the partial key interval, and the partial key interval is the key interval of the partial key distributed in the first end file in the first splitting key interval. Among them, the splitting key interval corresponding to any splitting instruction needs to make the two data blocks obtained after the corresponding data block is split meet the set data block conditions, such as the set data volume, the set number of data files, etc. To this end, when necessary, it is necessary to enlarge the splitting key interval corresponding to the received data so that each data block after the split meets the set data block conditions.
[0074] S260. For the second data file combination, a data file in which all keys are distributed in the second split key interval is used as a second intermediate file, and a data file in which some keys are distributed in the second split key interval is used as a second end file.
[0075] S270: Modify the second data block identifier in the meta information of the second intermediate file to the second target data block identifier.
[0076] S280. Migrate some keys and data corresponding to some keys in the second split key interval in the second end file to the corresponding file of the next data layer, and set the data block identifiers in the meta-information of the file to the second target data block identifiers.
[0077] In this embodiment, the specific implementation of steps S260-S280 is the same as that of S120-S140 in the above-mentioned embodiment.
[0078] It can be understood that if the data splitting of the first data block to be split does not cause a significant change in the data amount of the next data layer, for example, the data layer score of the next data layer does not reach a set threshold, etc., then there is no need to perform a data block splitting operation on the corresponding data block in the next data layer.
[0079] In the embodiment of the present invention, after a data block in any data layer is subjected to a data block splitting operation, if the data block splitting result causes the next data layer to meet the set data block splitting condition, the data splitting operation of the corresponding data block of the next data layer is automatically triggered, and the data splitting operation of the next data layer is completed based on the same data splitting method, thereby ensuring the accuracy and thoroughness of the data block splitting.
[0080] The following is an embodiment of a data block splitting device provided in an embodiment of the present invention. The device and the data block splitting method in the above-mentioned embodiment belong to the same inventive concept. For details not described in detail in the embodiment of the data block splitting device, reference can be made to the contents of the above-mentioned embodiments.
[0081] Figure 3 A schematic diagram of the structure of a device provided in an embodiment of the present invention, the device comprising:
[0082] A first response module 310 is used to determine a first data block to be split in the current data layer, and a first data file combination and a first split key interval corresponding to the first data block to be split;
[0083] A first file determination module 320 is used for, for the first data file combination, taking a data file whose keys are all distributed in the first split key interval as a first intermediate file, and taking a data file whose keys are partially distributed in the first split key interval as a first end file;
[0084] A first identifier modification module 330, configured to modify the data block identifier in the meta-information of the first intermediate file to a first target data block identifier;
[0085] The first compaction module 340 is used to migrate some keys in the first split key interval and the data corresponding to the some keys in the first end file to the corresponding file of the next data layer, and set the data block identifier in the metadata of the file to the first target data block identifier.
[0086] In one embodiment, Figure 4 As shown, the device also includes:
[0087] The second response module 350 is configured to determine a second data block to be split in the next data layer, and a second data file combination and a second split key interval corresponding to the second data block to be split, if the data migrated to the next data layer makes the next data layer meet the predetermined data block splitting condition, the second split key interval being greater than or equal to a partial key interval, and the partial key interval being a key interval of a partial key in the first end file distributed within the first split key interval;
[0088] A second file determination module 360 is used to, for the second data file combination, use the data file whose keys are all distributed in the second split key interval as the second intermediate file, and use the data file whose keys are partially distributed in the second split key interval as the second end file;
[0089] A second identifier modification module 370, configured to modify the second data block identifier in the meta-information of the second intermediate file to a second target data block identifier;
[0090] The second compaction module 380 is used to migrate some keys in the second split key interval and the data corresponding to the some keys in the second end file to the corresponding file of the next data layer, and set the data block identifiers in the metadata of the file to the second target data block identifier.
[0091] In one embodiment, the first compaction module 340 is specifically used to:
[0092] Using the keys in the first split key interval in the first end file as key combinations to be migrated;
[0093] Taking a data file in a next data layer corresponding to the current data layer, which has a key overlap with the key combination to be migrated, as a target file;
[0094] Using a merge sort algorithm to merge the key to be migrated with all the keys in the target file to obtain a merge result;
[0095] The merge result is stored in the target file of the next data layer.
[0096] In one embodiment, the first file determination module 320 is specifically used to:
[0097] Determine the start key and the end key of the first split key interval, and the minimum key and the maximum key of each data file;
[0098] The data file whose minimum key is smaller than the start key and whose maximum key is larger than the end key is used as the first start file;
[0099] The data file whose minimum key is smaller than the end key and whose maximum key is larger than the end key is used as the first end file.
[0100] In one embodiment, the first file determination module 320 is specifically used to:
[0101] A data file in which both the minimum key and the maximum key are distributed between the start key and the end key is used as the first intermediate file.
[0102] In one embodiment, the identification modification module 330 is specifically used to:
[0103] Deleting the meta information of the first intermediate file from the manifest file;
[0104] Modify the data block identifier in the meta information of the first intermediate file to the first target data block identifier, so as to update the meta information of the first intermediate file;
[0105] The updated meta information of the first intermediate file is added to the manifest file to update the manifest file.
[0106] The technical solution provided by the embodiment of the present invention is that after the first data file combination and the first split key interval corresponding to the first data block to be split are determined, for each data file in the first data file combination, if all its keys are distributed in the first split key interval, it is used as an intermediate file and retained in the current data layer, and only the data block identifier in its meta information is modified to the target data block identifier; since the intermediate file does not need to be read during the meta information modification process of the intermediate file, no read-write amplification will be generated; if only part of the keys in the data file are distributed in the first split key interval, the part of the keys distributed in the first split key partial interval and the data corresponding to the part of the keys are migrated to the corresponding file of the next data layer, and the data block identifier in the meta information of the file is modified to the first target data block identifier. Since each data file in the key-value storage system is small, the first end file is also small, and the data corresponding to the data in the split key interval in the first end file is smaller. Compared with the existing data block splitting method that needs to read all the split data, this embodiment only needs to perform compaction operations on the data in the split key interval in the first end file, so the read-write amplification in the data block splitting process can be greatly reduced, and the data block splitting speed can be improved.
[0107] The data block splitting device provided in the embodiment of the present invention can execute the data block splitting method provided in the embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the data block splitting method.
[0108] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 5 A block diagram of an exemplary server 12 suitable for use in implementing embodiments of the present invention is shown. Figure 5 The server 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0109] like Figure 5 As shown, the server 12 is in the form of a general purpose computing device. The components of the server 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0110] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0111] The server 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the server 12, including volatile and non-volatile media, removable and non-removable media.
[0112] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The server 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 not shown, usually called a "hard drive"). Although Figure 5 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0113] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0114] The server 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the server 12, and / or may communicate with any device that enables the server 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. In addition, the server 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the server 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the server 12, including, but not limited to, microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0115] The processing unit 16 executes various functional applications and data processing by running the program stored in the system memory 28, for example, implementing a data block splitting method provided by the embodiment of the present invention, the method comprising:
[0116] Determine a first data block to be split in the current data layer, and a first data file combination and a first split key interval corresponding to the first data block to be split;
[0117] For the first data file combination, a data file in which all keys are distributed in the first split key interval is used as a first intermediate file, and a data file in which some keys are distributed in the first split key interval is used as a first end file;
[0118] Modify the data block identifier in the meta information of the first intermediate file to the first target data block identifier;
[0119] Migrate some keys in the first end file that belong to the first split key interval and the data corresponding to the some keys to the corresponding file of the next data layer, and set the data block identifier in the metadata of the file to the first target data block identifier.
[0120] Of course, those skilled in the art can understand that the processor can also implement the technical solution of the data block splitting method provided by any embodiment of the present invention.
[0121] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the steps of the data block splitting method provided in the above embodiment of the present invention are implemented. The method includes:
[0122] Determine a first data block to be split in the current data layer, and a first data file combination and a first split key interval corresponding to the first data block to be split;
[0123] For the first data file combination, a data file in which all keys are distributed in the first split key interval is used as a first intermediate file, and a data file in which some keys are distributed in the first split key interval is used as a first end file;
[0124] Modify the data block identifier in the meta information of the first intermediate file to the first target data block identifier;
[0125] Migrate some keys in the first end file that belong to the first split key interval and the data corresponding to the some keys to the corresponding file of the next data layer, and set the data block identifier in the metadata of the file to the first target data block identifier.
[0126] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, 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 above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0127] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0128] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0129] Computer program code for performing the operations of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0130] An embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements a method as provided in any embodiment of the present application. . .
[0131] In the process of implementation, the computer program product can be written in one or more programming languages or a combination thereof to perform the computer program code of the present invention, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0132] It should be understood by those skilled in the art that the modules or steps of the present invention described above can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented by a program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0133] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A data block splitting method, characterized in that: The method comprises: Determine a first data block to be split in the current data layer, and a first data file combination and a first split key interval corresponding to the first data block to be split; For the first data file combination, a data file in which all keys are distributed in the first split key interval is used as a first intermediate file, and a data file in which some keys are distributed in the first split key interval is used as a first end file; Modify the data block identifier in the meta information of the first intermediate file to the first target data block identifier; Migrate some keys in the first end file that belong to the first split key interval and the data corresponding to the some keys to the corresponding file of the next data layer, and set the data block identifier in the metadata of the file to the first target data block identifier.
2. The method according to claim 1, characterized in that After migrating the partial keys and the data corresponding to the partial keys in the first end file that belong to the first split key interval to the corresponding files of the next data layer, the method further includes: If the data migrated to the next data layer makes the next data layer meet the predetermined data block splitting condition, then determine a second data block to be split in the next data layer, and a second data file combination and a second split key interval corresponding to the second data block to be split, wherein the second split key interval is greater than or equal to a partial key interval, and the partial key interval is a key interval of a partial key in the first end file that is distributed in the first split key interval; For the second data file combination, a data file in which all keys are distributed in the second split key interval is used as a second intermediate file, and a data file in which some keys are distributed in the second split key interval is used as a second end file; Modify the second data block identifier in the meta information of the second intermediate file to the second target data block identifier; Migrate some keys in the second split key interval and the data corresponding to the some keys in the second end file to the corresponding file of the next data layer, and set the data block identifiers in the metadata of the file to the second target data block identifiers.
3. The method according to claim 1, characterized in that The step of migrating the data in the first split key interval in the first end file to a corresponding file in the next data layer includes: Using the keys in the first split key interval in the first end file as key combinations to be migrated; Taking a data file in a next data layer corresponding to the current data layer, which has a key overlap with the key combination to be migrated, as a target file; Using a merge sort algorithm to merge the key to be migrated with all the keys in the target file to obtain a merge result; The merge result is stored in the target file of the next data layer.
4. The method according to claim 1, characterized in that: The first end file includes a first start file and / or a first end file, and the data file in which some keys are distributed in the first split key interval as the first end file includes: Determine the start key and the end key of the first split key interval, and the minimum key and the maximum key of each data file; The data file whose minimum key is smaller than the start key and whose maximum key is larger than the end key is used as the first start file; The data file whose minimum key is smaller than the end key and whose maximum key is larger than the end key is used as the first end file.
5. The method according to claim 4, characterized in that The data file in which all keys are distributed in the first split key interval is used as a first intermediate file, including: A data file in which both the minimum key and the maximum key are distributed between the start key and the end key is used as the first intermediate file.
6. The method according to claim 1, characterized in that The step of modifying the data block identifier in the meta information of the first intermediate file to the first target data block identifier includes: Deleting the meta information of the first intermediate file from the manifest file; Modify the data block identifier in the meta information of the first intermediate file to the first target data block identifier, so as to update the meta information of the first intermediate file; The updated meta information of the first intermediate file is added to the manifest file to update the manifest file.
7. A data block splitting device, characterized in that: include: A first response module, configured to determine a first data block to be split in a current data layer, and a first data file combination and a first split key interval corresponding to the first data block to be split; A first file determination module is used for, for the first data file combination, taking a data file whose keys are all distributed in the first split key interval as a first intermediate file, and taking a data file whose keys are partially distributed in the first split key interval as a first end file; A first identifier modification module, used to modify the data block identifier in the meta information of the first intermediate file to a first target data block identifier; The first compaction module is used to migrate some keys in the first split key interval and the data corresponding to the some keys in the first end file to the corresponding file of the next data layer, and set the data block identifier in the metadata of the file to the first target data block identifier.
8. An electronic device, characterized in that: The electronic device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the data block splitting method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, it implements the data block splitting method as described in any one of claims 1-6.
10. A computer program product, comprising a computer program, characterized in that When executed by a processor, the computer program implements the data block splitting method as described in any one of claims 1-6.
Citation Information
Patent Citations
Light-weight combination method based on log combination tree structure
CN106682184A
MongoDB data migration monitoring method and device based on log analysis
CN110147353A
File system embedded with transverse extension key value storage system and file management method
CN110347852A
Data storage method and device based on LSM, storage medium and computer equipment
CN111352908A
Method, processor readable medium and system for partition splitting and merging
CN113297432A
