A data merging method, device, storage medium and electronic equipment
By identifying data in secondary data files and macroblocks within a specified time period and snapshot location, and reclaiming or merging data that does not meet the conditions, the problem of redundant storage of multiple versions of secondary data files is solved, and efficient utilization of storage space is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING OCEANBASE TECHNOLOGY CO LTD
- Filing Date
- 2023-01-09
- Publication Date
- 2026-04-10
AI Technical Summary
In existing technologies, multiple versions of minor data files lead to redundant storage. How can we reduce redundant storage to save storage space?
By determining a specified time period and a specified snapshot location, it is determined whether the data in secondary data files and macroblocks meets the reclamation conditions. If they do, the storage space is reclaimed; otherwise, the data that does not meet the conditions is retained or merged.
It effectively reduces redundant storage of secondary data files, balances efficiency, merges data that cannot be fully recovered, and saves storage space.
Smart Images

Figure CN116226059B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the computer field, and in particular, to a data merging method and device, a storage medium, and an electronic device. BACKGROUND
[0002] With the continuous development of Internet technology and database technology, the data volume of a database is becoming larger and larger.
[0003] There are mainly two kinds of files for storing data in a database, one is a major SSTable and the other is a minor SSTable.
[0004] The major SSTable is a data file corresponding to a snapshot point. For each snapshot point, the major SSTable corresponding to the snapshot point stores the latest data related to transactions with a submission time not exceeding the snapshot point. Specifically, a time point is determined every preset period, and this time point is referred to as a snapshot point. For each snapshot point, the database node stores the latest data related to transactions with a submission time not exceeding the snapshot point in the major SSTable. For example, 5:00 pm is a snapshot point, at 4:00 pm, the primary key key1 corresponds to the key value value1, and at 4:30 pm, the primary key key1 corresponds to the key value value2. Therefore, for key1, the major SSTable corresponding to 5:00 pm only stores value2, which is the latest data at 5:00 pm.
[0005] The major SSTable only stores the latest data related to transactions with a submission time not exceeding the snapshot point. To facilitate rollback, the other kind of file for storing data in the database, i.e., the minor SSTable, stores all the changed data during the execution of each transaction by the database node within a period of time. The minor SSTable can be divided into multiple macroblocks according to the data size. For example, within one hour from 3:00 pm to 4:00 pm, the database node executes ten transactions and changes data during the execution of the transactions. Therefore, the minor SSTable within one hour from 3:00 pm to 4:00 pm stores all the changed data during the execution of the ten transactions by the database node, and the minor SSTable can be divided into multiple macroblocks with a size of 2 Mb. The database stores multiple versions of the minor SSTable, and the multiple versions of the minor SSTable contain a large amount of repeated or committed data, which causes redundant storage.
[0006] Therefore, how to reduce the redundant storage caused by the multiple versions of the minor SSTable and save storage space is an urgent problem to be solved. SUMMARY
[0007] The present specification provides a data merging method, device, storage medium and electronic equipment to at least partially solve the above problems existing in the prior art.
[0008] The present specification adopts the following technical solutions:
[0009] The present specification provides a data merging method, which comprises:
[0010] determining a specified time period;
[0011] According to the specified time period, a specified snapshot point is determined in each snapshot point, and a specified file to be merged is selected from each secondary data file according to the specified time period;
[0012] For each specified file, it is determined whether the specified file meets a preset recycling condition according to the statistical information of each data in the specified file. If it meets, the storage space occupied by the secondary data file is recycled;
[0013] If it does not meet, for each macro block in the specified file, when it is determined that all the data in the macro block are submitted and the maximum submission time of each data in the macro block is not later than the specified snapshot point according to the statistical information of each data in the macro block, the storage space occupied by the macro block is recycled;
[0014] When it is determined that the data in the macro block are not all submitted or the maximum submission time of each data in the macro block is later than the specified snapshot point according to the statistical information of each data in the macro block, the macro block is retained;
[0015] The retained macro blocks in the specified file that does not meet the recycling condition are merged.
[0016] Optionally, the specified time period is determined, and specifically comprises:
[0017] A preset revocation retention duration is obtained;
[0018] A time period with the current time as the termination time and the duration as the revocation retention duration is determined as the specified time period.
[0019] Optionally, the specified snapshot point is determined in each snapshot point according to the specified time period, and specifically comprises:
[0020] The starting time of the specified time period is determined;
[0021] The snapshot point closest to and earlier than the starting time is determined as the specified snapshot point.
[0022] Optionally, the secondary data file to be merged is selected from each secondary data file according to the specified time period, and specifically comprises:
[0023] determining a start time of the specified time period;
[0024] for each secondary data file, determining whether the earliest write time of data in the secondary data file is earlier than the start time;
[0025] if yes, determining the secondary data file as a secondary data file to be merged.
[0026] Optionally, the statistical information of each data in the specified file at least includes whether all data in the specified file is committed, and the maximum commit time of each data in the specified file.
[0027] for each specified file, determining whether the specified file meets a preset recycling condition according to the statistical information of each data in the specified file, specifically including:
[0028] for each specified file, when all data in the specified file is committed, and the maximum commit time of each data in the specified file is not later than the specified snapshot point, determining that the specified file meets the preset recycling condition;
[0029] when all data in the specified file is not committed, or the maximum commit time of each data in the specified file is later than the specified snapshot point, determining that the specified file does not meet the recycling condition.
[0030] Optionally, merging the retained macroblocks in the specified file that does not meet the recycling condition, specifically including:
[0031] determining each microblock contained in the macroblock in the specified file that does not meet the recycling condition as a microblock to be processed;
[0032] for each microblock to be processed, determining the statistical information of each data in the microblock to be processed;
[0033] when it is determined according to the statistical information of each data in the microblock to be processed that all data in the microblock to be processed is committed, and the maximum commit time of each data in the microblock to be processed is not later than the specified snapshot point, deleting the microblock to be processed;
[0034] when it is determined according to the statistical information of each data in the microblock to be processed that all data in the microblock to be processed is not committed, or the maximum commit time of each data in the microblock to be processed is later than the specified snapshot point, retaining the microblock to be processed;
[0035] merging the retained microblocks to be processed.
[0036] Optionally, merging the retained microblocks to be processed, specifically including:
[0037] For each data in the micro-block to be processed, determine the attribute of the data;
[0038] When it is determined according to the attribute of the data that the data is committed, and the commit time of the data is not later than the specified snapshot point, delete the data;
[0039] When it is determined according to the attribute of the data that the data is not committed, or the commit time of the data is later than the specified snapshot point, retain the data;
[0040] Merge the retained data in the micro-block to be processed.
[0041] The present specification provides an apparatus for data merging, the apparatus comprising:
[0042] A first determining module is configured to determine a specified time period;
[0043] A second determining module is configured to determine a specified snapshot point among snapshot points according to the specified time period, and determine a selected secondary data file to be merged among secondary data files as a specified file according to the specified time period;
[0044] A judging module is configured to determine, for each specified file, whether the specified file meets a preset recycling condition according to statistical information of data in the specified file, and recycle the storage space occupied by the secondary data file if the specified file meets the recycling condition;
[0045] A recycling module is configured to, when the result of the judgment of the judging module is no, recycle, for each macro-block in the specified file, the storage space occupied by the macro-block when it is determined according to the statistical information of data in the macro-block that all data in the macro-block are committed, and the maximum commit time of the data in the macro-block is not later than the specified snapshot point;
[0046] A retaining module is configured to retain the macro-block when it is determined according to the statistical information of data in the macro-block that not all data in the macro-block are committed, or the maximum commit time of the data in the macro-block is later than the specified snapshot point;
[0047] A merging module is configured to merge the retained macro-blocks in the specified file that do not meet the recycling condition.
[0048] Optionally, the first determining module is specifically configured to acquire a preset revocation retention duration, and determine a time period with a current time as a terminal time and a duration of the revocation retention duration as the specified time period.
[0049] Optionally, the second determining module is specifically configured to determine a starting time of the specified time period, and determine a snapshot point closest to and earlier than the starting time as the specified snapshot point.
[0050] Optionally, the second determining module is specifically configured to determine a starting time point of the specified time period; for each secondary data file, determine whether the earliest writing time of the data in the secondary data file is earlier than the starting time point; if yes, determine that the secondary data file is a secondary data file to be merged.
[0051] Optionally, the statistical information of each data in the specified file at least includes whether the data in the specified file is all submitted, and the maximum submission time of each data in the specified file.
[0052] The judging module is specifically configured to, for each specified file, when the data in the specified file is all submitted, and the maximum submission time of each data in the specified file is not later than the specified snapshot point, determine that the specified file meets the preset recycling condition; when the data in the specified file is not all submitted, or the maximum submission time of each data in the specified file is later than the specified snapshot point, determine that the specified file does not meet the recycling condition.
[0053] Optionally, the merging module is specifically configured to determine each microblock contained in the macroblock in the specified file which does not meet the recycling condition as a microblock to be processed; for each microblock to be processed, determine the statistical information of each data in the microblock to be processed; when it is determined according to the statistical information of each data in the microblock to be processed that the data in the microblock to be processed is all submitted, and the maximum submission time of each data in the microblock to be processed is not later than the specified snapshot point, delete the microblock to be processed; when it is determined according to the statistical information of each data in the microblock to be processed that the data in the microblock to be processed is not all submitted, or the maximum submission time of each data in the microblock to be processed is later than the specified snapshot point, retain the microblock to be processed; and merge the retained microblocks to be processed.
[0054] Optionally, the merging module is specifically configured to, for each data in the microblock to be processed, determine the attribute of the data; when it is determined according to the attribute of the data that the data is submitted, and the submission time of the data is not later than the specified snapshot point, delete the data; when it is determined according to the attribute of the data that the data is not submitted, or the submission time of the data is later than the specified snapshot point, retain the data; and merge the retained data in the microblock to be processed.
[0055] The specification provides a computer readable storage medium, the storage medium stores a computer program, the computer program is executed by the processor to realize the above method.
[0056] The specification provides an electronic device, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor executes the program to realize the above method.
[0057] The above at least one technical solution adopted by the specification can achieve the following beneficial effects:
[0058] In the method provided by the present application, a specified time period is determined, a specified snapshot point and a specified file are determined according to the specified time period, and then it is judged whether the specified file meets the recycling condition. If yes, the storage space occupied by the secondary data file is recycled. If no, it is judged whether the data in the macro block that does not meet the recycling condition has been submitted completely and the maximum submission time is not later than the specified snapshot point. If yes, the storage space occupied by the macro block is recycled. If no, the macro block is retained.
[0059] The present method first judges whether the specified file can be merged in the granularity of file. If the specified file cannot be merged because it contains part of data that has not been submitted or the submission time of which is later than the specified snapshot point, then it is judged whether the data in each macro block can be merged in the granularity of macro block that is finer than file. This method not only takes efficiency into account, but also can merge part of data in the specified file that cannot be merged. BRIEF DESCRIPTION OF DRAWINGS
[0060] The accompanying drawings, which are incorporated herein and form a part of the specification, illustrate the embodiments of the present specification and, together with the description, further serve to explain the principles of the present specification and to enable a person skilled in the art to make and use the present specification. In the drawings:
[0061] Figure 1 A flowchart of a data merging method provided by the present specification;
[0062] Figure 2 A schematic diagram of determining a specified time period provided by the present specification;
[0063] Figure 3 A schematic diagram of determining a specified snapshot point provided by the present specification;
[0064] Figure 4 A schematic diagram of a data merging device provided by the present specification;
[0065] Figure 5 A schematic diagram of an electronic device corresponding to Figure 1 provided by the present specification. DETAILED DESCRIPTION
[0066] To make the objectives, technical solutions and advantages of the present specification clearer, the technical solutions of the present specification will be described below in conjunction with the embodiments of the present specification and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present specification, but not all the embodiments. Based on the embodiments in the present specification, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the scope of the present application.
[0067] The technical solutions provided in the various embodiments of this specification are described in detail below with reference to the accompanying drawings.
[0068] Figure 1 This document provides a flowchart illustrating a data merging method, which includes the following steps:
[0069] S100: Specify a time period.
[0070] The data merging method provided in this manual is mainly applied to merging data from multiple versions of secondary data files in a database. The executing entity can be an electronic device implementing the database. When the database is a distributed database, the executing entity can be a database node within that distributed database. The database node can be any electronic device with computing capabilities, such as a server or terminal. For ease of explanation, the following description will use the database node as the executing entity. Specifically, the database node first determines a specified time period to prepare for the following steps of determining the specified snapshot point and the specified file.
[0071] The specified time period can be determined based on the current time and the preset cancellation retention duration. First, the preset cancellation retention duration is obtained, and then the time period with the current time as the end time and the duration being the preset cancellation retention duration is determined as the specified time period.
[0072] The preset undo retention period is a hyperparameter designed to facilitate rollback. If a transaction's commit time falls within the undo retention period, data associated with that transaction cannot be deleted, nor can data associated with uncommitted transactions. Data associated with transactions whose commit times fall outside the undo retention period can be overwritten or deleted. Therefore, a specified time period can be determined based on the current time and the preset undo retention period.
[0073] For example, such as Figure 2 As shown, the current time is 8:00 pm, and the preset undo retention period is two hours. Therefore, if the specified time period is from 6:00 pm to 8:00 pm, then data related to all transactions committed after 6:00 pm cannot be deleted.
[0074] S102: Based on the specified time period, determine the specified snapshot location in each snapshot location, and based on the specified time period, select the secondary data file to be merged from each secondary data file as the specified file.
[0075] As described above, the data related to the transaction at the submission time within the specified time period cannot be deleted, and the data related to the transaction with the submission time earlier than the start time of the specified time period in each secondary file can be deleted, i.e., whether the submission time of the transaction is earlier than the start time of the specified time period is taken as a condition for judging whether the data related to the transaction can be deleted.
[0076] If the data related to the transaction with the submission time earlier than the start time of the specified time period in each secondary file is deleted, the data related to the transaction with the un-submitted time and the submission time within the specified time period is retained in the secondary data file, and the earliest version of the data to which the rollback operation can be rolled back is the data related to the transaction with the submission time being the start time of the specified time period.
[0077] To ensure that each transaction is in a unified state before and after the rollback, one snapshot point before the specified time period can be taken as a condition for judging whether the data related to the transaction can be deleted, each snapshot point corresponds to a primary data file storing the latest data related to the transaction with the submission time not exceeding the snapshot point, if one snapshot point before the specified time period is taken as a condition for judging whether the data related to the transaction can be deleted, and the data related to the transaction with the submission time not later than the specified snapshot point in each secondary file is deleted, the earliest version of the data to which the rollback operation can be rolled back, i.e., the data in the primary data file corresponding to the snapshot point, can ensure that each transaction is in a unified state before and after the rollback.
[0078] Specifically, a snapshot point earlier than the specified time period is determined as the specified snapshot point.
[0079] Different secondary data files are distinguished according to the writing time, and the multi-version secondary data files written in a period of time can be selected, and the multi-version secondary data files written in the period of time are merged.
[0080] Because the core idea of the data merging method provided in the present specification is to delete the data related to the transaction with the submission time not later than the specified snapshot point in the secondary data file (i.e., to recycle the storage space occupied by the data related to the transaction with the submission time not later than the specified snapshot point in the secondary data file), and to retain and merge the data related to the transaction with the un-submitted time or the submission time later than the specified snapshot point, and the submission time of each data in the secondary data file is later than the earliest writing time, in order to make the method meaningful, the secondary data file with the earliest writing time earlier than the start time of the specified time period can be selected as the specified file.
[0081] When the earliest write time of the multi-version secondary data file written in a period of time is earlier than the start time of the specified time period, the multi-version secondary data file written in the period of time is determined as a to-be-merged condition, that is, the multi-version secondary data file written in the period of time is the secondary data file to be merged.
[0082] S104: For each specified file, it is judged whether the specified file meets the preset recycling condition according to the statistical information of each data in the specified file. If yes, step S106 is executed; otherwise, step S108 is executed.
[0083] S106: The storage space occupied by the secondary data file is recycled.
[0084] The statistical information of each data in the specified file at least includes the maximum commit time of each data in the specified file, that is, the commit time of the latest committed data in the specified file, and whether all data in the specified file is committed.
[0085] From the core idea of the method described in step S102, it is judged whether the specified file meets the preset recycling condition, that is, when all data in the specified file is committed, and the maximum commit time of each data in the specified file is not later than the specified snapshot point, it is determined that the specified file meets the preset recycling condition. When all data in the specified file is not committed, or the maximum commit time of each data in the specified file is later than the specified snapshot point, it is determined that the specified file does not meet the recycling condition.
[0086] If it is determined that the specified file meets the recycling condition, the storage space occupied by the specified file can be recycled, that is, the file can be deleted.
[0087] S108: If not, it is judged for each macro block in the specified file whether all data in the macro block is committed and the maximum commit time of each data in the macro block is not later than the specified snapshot point. If yes, step S110 is executed; otherwise, step S112 is executed.
[0088] S110: The storage space occupied by the macro block is recycled.
[0089] When it is determined from the statistical information of each data in the macro block that all data in the macro block is committed, and the maximum commit time of each data in the macro block is not later than the specified snapshot point, the storage space occupied by the macro block is recycled.
[0090] From the core idea of the method, it is known that after judging whether the secondary file meets the recycling condition in the granularity of file, the specified file which does not meet the recycling condition is the secondary data file containing the transaction-related data which is not committed or has a commit time later than the specified snapshot point.
[0091] The secondary data file can be divided into multiple macroblocks according to data size, so when judging whether the data in the specified file that does not meet the recycling condition is committed and the commit time is not later than the specified snapshot point, the judgment can be performed in macroblock granularity, for each macroblock, statistical information of each data in the macroblock is determined, the statistical information of each data in the macroblock at least includes whether all the data in the macroblock is committed, and the maximum commit time of each data in the macroblock, when the statistical information of each data in the macroblock is determined that all the data in the macroblock is committed, and the maximum commit time of each data in the macroblock is not later than the specified snapshot point, the storage space occupied by the macroblock is recycled, that is, the macroblock can be deleted.
[0092] S112: Reserve the macroblock.
[0093] When the data in the macroblock is not all committed, and the maximum commit time of each data in the macroblock is later than the specified snapshot point, it is indicated that the data in the macroblock contains uncommitted data or contains data with commit time later than the specified snapshot point, so the macroblock cannot be deleted and needs to be reserved.
[0094] S114: Merge the reserved macroblocks in the specified file that does not meet the recycling condition.
[0095] The reserved macroblocks in the specified file that does not meet the recycling condition can be written into a new file, or the reserved macroblocks in the specified file that does not meet the recycling condition can be directly stored.
[0096] As can be seen from the above method, the method first determines a specified time period, then determines a specified snapshot point and a specified file according to the specified time period, and then judges whether the specified file meets the recycling condition, if yes, the storage space occupied by the specified file is recycled, that is, the specified file can be deleted, if not, when the data in the macroblock that does not meet the recycling condition is all committed and the maximum commit time is not later than the specified snapshot point, the storage space occupied by the macroblock is recycled, that is, the macroblock can be deleted, and when the data in the macroblock that does not meet the recycling condition is not all committed and the maximum commit time is later than the specified snapshot point, the macroblock is reserved. The method first judges whether the specified file can be merged in file granularity, if the specified file cannot be merged because it contains part of uncommitted or committed data later than the specified snapshot point, then the data in each macroblock is judged whether it can be merged in macroblock granularity, which not only considers efficiency, but also can merge part of the data in the specified file that cannot be merged.
[0097] Optionally, as described in step S102 above, to merge as much data in the secondary data file as possible, a snapshot point closest to and earlier than the start time of the specified time period can be determined as the specified snapshot point. In the above example, the snapshot point 1 is closest to and earlier than the start time of the specified time period, so the snapshot point 1 is determined as the specified snapshot point. Figure 3As shown, 5:00pm is a snapshot point, 7:00pm is another snapshot point, 5:00pm is the snapshot point closest to and earlier than the start time 6:00pm of the specified time period, so 5:00pm is determined as the specified snapshot point.
[0098] Further, the retained macroblock can include data not committed or data committed later than the specified snapshot point, or data committed not later than the specified snapshot point. The data merging method provided in the present specification can further subdivide each macroblock in the secondary data file into multiple microblocks, and the microblock can be variable length and have a size of about 16Kb.
[0099] After the secondary data file is divided into multiple macroblocks according to size, and each macroblock is divided into multiple microblocks according to size, the retained macroblock in the specified file not meeting the recycling condition is merged as described in step S114, and the retained macroblock in the specified file not meeting the recycling condition can be further judged at the granularity of the microblock whether the storage space occupied by each microblock in the retained macroblock in the specified file not meeting the recycling condition can be recycled (i.e., whether each microblock in the retained macroblock in the specified file not meeting the recycling condition can be deleted), specifically, each microblock contained in the macroblock in the specified file not meeting the recycling condition is determined as a to-be-processed microblock, for each to-be-processed microblock, statistical information of each data in the to-be-processed microblock is determined, the statistical information of each data in the to-be-processed microblock at least includes whether all the data in the to-be-processed microblock is committed, and the maximum commit time of each data in the to-be-processed microblock, when it is determined according to the statistical information of each data in the to-be-processed microblock that all the data in the to-be-processed microblock is committed, and the maximum commit time of each data in the to-be-processed microblock is not later than the specified snapshot point, the storage space occupied by the to-be-processed microblock is recycled, specifically, the to-be-processed microblock can be deleted, when it is determined according to the statistical information of each data in the to-be-processed microblock that all the data in the to-be-processed microblock is not committed, or the maximum commit time of each data in the to-be-processed microblock is later than the specified snapshot point, the to-be-processed microblock is retained. Finally, the retained to-be-processed microblocks are merged.
[0100] Further, the reserved to-be-processed microblocks can include data that is not submitted or data that is submitted later than the specified snapshot point, and can also include data that is not submitted later than the specified snapshot point, so whether each data in the microblock can be deleted can be determined according to the attribute of the data, and the reserved to-be-processed microblocks are merged, specifically, for each data in the to-be-processed microblock, the attribute of the data is determined, the attribute of the data at least includes whether the data is submitted, and the submission time of the data, when it is determined according to the attribute of the data that the data is submitted and the submission time of the data is not later than the specified snapshot point, the data is deleted, when it is determined according to the attribute of the data that the data is not submitted or the submission time of the data is later than the specified snapshot point, the data is reserved, and finally the reserved data in the to-be-processed microblock is merged.
[0101] After the secondary data file is divided into a plurality of macroblocks according to size, and each macroblock is divided into a plurality of microblocks according to size, each microblock contains a plurality of data, that is, the smallest granularity of the secondary data file is data.
[0102] It should be noted that the data of the secondary data file is stored according to the primary key, that is, a plurality of data corresponding to one primary key is continuously stored in the secondary data file, and the secondary data file is subdivided into macroblocks according to data size, and each macroblock is subdivided into microblocks according to data size after data is written into the secondary data file, and not when the data is written into the secondary data file in the form of microblocks and macroblocks, so when the data in the reserved secondary data file is merged, it is not necessary to consider macroblocks and microblocks again, and a new secondary data file can be directly created, and the reserved data can be written into the new secondary data file.
[0103] Specifically, because the data in the secondary data file is stored according to the primary key, each data corresponds to a unique primary key, and there is a preset order between the primary keys. The attribute of each data at least includes the primary key corresponding to the data, whether the data is submitted, and the submission time of the data, so merging the reserved data in the to-be-processed microblock (that is, writing the data in the reserved secondary data file into a new secondary data file) can be specifically as follows:
[0104] First, the preset primary key order is obtained, and then the first primary key is taken as a to-be-merged primary key according to the preset primary key order; the reserved data corresponding to the to-be-merged primary key is taken as to-be-merged data, the to-be-merged data is sequentially written into a merged file according to the order from late to early of the submission time according to the attribute of the to-be-merged data, the next primary key of the to-be-merged primary key is taken as a new to-be-merged primary key, and the to-be-merged data corresponding to the new to-be-merged primary key is sequentially written into the merged file according to the order from late to early of the submission time, and this process continues until the to-be-merged primary key is the last primary key.
[0105] After the data reserved in the specified files is written into the new secondary data file, all the specified files are deleted to save the storage space of the database.
[0106] The present specification also provides a computer readable storage medium storing a computer program, which can be used to execute the above Figure 1 The provided method for data merging.
[0107] Based on the same idea, the present specification also provides a corresponding data merging device, as shown in the following Figure 4
[0108] Figure 4 A data merging device provided by the present specification includes the following specific steps:
[0109] The first determining module 401 is configured to determine a specified time period.
[0110] The second determining module 402 is configured to determine a specified snapshot site in each snapshot site according to the specified time period, and select a secondary data file to be merged as a specified file from each secondary data file according to the specified time period.
[0111] The judging module 403 is configured to determine, for each specified file, whether the specified file meets a preset condition according to the statistical information of each data in the specified file, and recycle the storage space occupied by the secondary data file if the specified file meets the condition.
[0112] The recycling module 404 is configured to recycle the storage space occupied by each macro block in the specified file when it is determined that all the data in the macro block are submitted and the maximum submission time of each data in the macro block is not later than the specified snapshot site according to the statistical information of each data in the macro block if the judging result of the judging module 403 is no.
[0113] The reservation module 405 is configured to reserve the macro block when it is determined that not all the data in the macro block are submitted or the maximum submission time of each data in the macro block is later than the specified snapshot site according to the statistical information of each data in the macro block.
[0114] The merging module 406 is configured to merge the reserved macro blocks in the specified file that does not meet the recycling condition.
[0115] Optionally, the first determining module 401 is specifically configured to acquire a preset reservation cancellation time length, and determine a time period with a current time as a terminal time and the time length being the reservation cancellation time length as the specified time period.
[0116] Optionally, the second determining module 402 is specifically configured to determine a starting time point of the specified time period; and determine a snapshot site closest to and earlier than the starting time point as a specified snapshot site.
[0117] Optionally, the second determining module 402 is specifically configured to determine a starting time point of the specified time period; and determine, for each secondary data file, whether the earliest write time of the data in the secondary data file is earlier than the starting time point; if yes, determine the secondary data file as a secondary data file to be merged.
[0118] Optionally, the statistical information of each data in the specified file at least includes whether the data in the specified file is all committed, and the maximum commit time of each data in the specified file.
[0119] The determining module 403 is specifically configured to, for each specified file, when the data in the specified file is all committed and the maximum commit time of each data in the specified file is not later than the specified snapshot site, determine that the specified file meets a preset recycling condition; and when the data in the specified file is not all committed, or the maximum commit time of each data in the specified file is later than the specified snapshot site, determine that the specified file does not meet the recycling condition.
[0120] Optionally, the merging module 406 is specifically configured to determine each microblock contained in a macroblock in the specified file that does not meet the recycling condition as a to-be-processed microblock; determine, for each to-be-processed microblock, the statistical information of each data in the to-be-processed microblock; when it is determined according to the statistical information of each data in the to-be-processed microblock that the data in the to-be-processed microblock is all committed and the maximum commit time of each data in the to-be-processed microblock is not later than the specified snapshot site, delete the to-be-processed microblock; when it is determined according to the statistical information of each data in the to-be-processed microblock that the data in the to-be-processed microblock is not all committed, or the maximum commit time of each data in the to-be-processed microblock is later than the specified snapshot site, retain the to-be-processed microblock; and merge the retained to-be-processed microblocks.
[0121] Optionally, the merging module 406 is specifically configured to determine, for each data in the to-be-processed microblock, the attribute of the data; when it is determined according to the attribute of the data that the data is committed and the commit time of the data is not later than the specified snapshot site, delete the data; when it is determined according to the attribute of the data that the data is not committed, or the commit time of the data is later than the specified snapshot site, retain the data; and merge the retained data in the to-be-processed microblock.
[0122] The specification also provides Figure 5 The structural schematic diagram of the electronic device is shown. As Figure 5At the hardware level, the unmanned device comprises a processor, an internal bus, a network interface, a memory and a non-volatile memory, and can also comprise other hardware required by the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs to realize the above Figure 1 The data merging method. Of course, in addition to the software implementation, the present specification does not exclude other implementation manners, such as a logic device or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or a logic device.
[0123] In the 1990s, it was relatively easy to distinguish whether an improvement in a technology was a hardware improvement (e.g., an improvement in the circuit structure of a diode, transistor, switch, etc.) or a software improvement (an improvement in a method flow). However, as technology has evolved, many improvements in method flows today can be considered as direct improvements in hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structures by programming the improved method flows into hardware circuits. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using hardware entity modules. For example, a programmable logic device (PLD) (e.g., a field programmable gate array (FPGA)) is an integrated circuit whose logic function is determined by user programming of the device. A digital system is "integrated" on a PLD by the designer programming the PLD, rather than by ordering a chip manufacturer to design and fabricate a custom integrated circuit chip. Moreover, instead of manually fabricating integrated circuit chips, this programming is now mostly implemented using "logic compiler" software, which is similar to software compilers used in program development, and the original code to be compiled is written in a specific programming language, which is called a hardware description language (HDL), and there are many such languages, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., and the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should be aware that, as long as the method flow is logically programmed in the above-mentioned hardware description languages and programmed into an integrated circuit, a hardware circuit implementing the logical method flow can be easily obtained.
[0124] The controller can be implemented in any suitable way, for example, the controller can take the form of a microprocessor or processor and a computer readable medium storing computer readable program code, such as software or firmware, executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that, in addition to being implemented in pure computer readable program code, the controller can equally well be implemented to perform the same functions using logic gates, switches, an application specific integrated circuit, a programmable logic controller and an embedded microcontroller, etc. by means of a logical programming of the method steps. The controller can thus be considered as a hardware component, and the means comprised therein for performing the various functions can be considered as structures within the hardware component. Alternatively, the means for performing the various functions can even be considered as both a software module implementing the method and a structure within the hardware component.
[0125] The systems, apparatuses, modules or units illustrated by the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0126] For the sake of description, the above apparatuses are described in various units by functions respectively. Of course, the functions of each unit can be implemented in one or more software and / or hardware in the implementation of the present specification.
[0127] Those skilled in the art will understand that the embodiments of the present application can be provided as a method, a system or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer usable program code.
[0128] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flow or blocks Figure 1 means for functionally implementing the steps listed in the flowchart block or blocks.
[0129] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart block or blocks. Figure 1 one or more flow or blocks Figure 1 means for functionally implementing the steps listed in the flowchart block or blocks.
[0130] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flow or blocks means for functionally implementing the steps listed in the flowchart block or blocks.
[0131] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0132] The memory can include non-persistent memory and / or volatile memory, such as random access memory (RAM) and / or cache memory, non-volatile memory, such as read-only memory (ROM), EPROM, and / or flash memory, etc. The memory is an example of computer-readable media.
[0133] Computer-readable media includes permanent and non-permanent, movable and non-movable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer-readable media does not include transitory media such as modulated data signals and carriers.
[0134] It should also be noted that the terms "comprising", "containing", or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article or apparatus that comprises a list of elements does not only include those elements, but also other elements not explicitly listed or inherent to such process, method, article or apparatus. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus that includes the element.
[0135] Those skilled in the art will appreciate that embodiments of the present specification can be provided as methods, systems or computer program products. Therefore, the present specification can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Moreover, the present specification can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0136] The present specification can be described in the general context of computer-executable instructions, such as program modules, executed by computers. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present specification can also be practiced in a distributed computing environment, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in both local and remote computer storage media, including storage devices.
[0137] In a distributed computing environment, program modules can be located in both local and remote computer storage media, including storage devices.
[0138] Each of the various embodiments described in this specification are described using a progressive format, with each embodiment building on the previous embodiments. The same or similar parts between embodiments are cross-referenced, and each embodiment highlights the differences from the other embodiments. In particular, the system embodiments are described more simply, as they are substantially similar to the method embodiments, and the relevant parts are cross-referenced to the method embodiment descriptions.
[0139] 0 The foregoing is merely illustrative of the embodiments of this specification, and is not intended to limit this specification. Any modifications, substitutions, improvements, and the like that are within the spirit and principle of this specification are intended to be included within the scope of the claims of this application.
[0140] Any modifications, substitutions, improvements, and the like that are within the spirit and principle of this specification are intended to be included within the scope of the claims of this application.
Claims
1. A method for data consolidation, the method comprising: determining a specified time period; determining a specified snapshot point in each snapshot point according to the specified time period, and selecting a specified file to be consolidated from each secondary data file according to the specified time period; for each specified file, determining whether the specified file meets a preset recycling condition according to statistical information of data in the specified file, specifically comprising: for each specified file, when all data in the specified file are committed and the maximum commit time of each data in the specified file is not later than the specified snapshot point, determining that the specified file meets the preset recycling condition; when the data in the specified file are not all committed, or the maximum commit time of each data in the specified file is later than the specified snapshot point, determining that the specified file does not meet the recycling condition; if yes, recycling storage space occupied by the secondary data file; if no, for each macro block in the specified file, when it is determined according to statistical information of data in the macro block that all data in the macro block are committed and the maximum commit time of each data in the macro block is not later than the specified snapshot point, recycling storage space occupied by the macro block; when it is determined according to statistical information of data in the macro block that the data in the macro block are not all committed, or the maximum commit time of each data in the macro block is later than the specified snapshot point, keeping the macro block; consolidating the macro blocks kept in the specified file which does not meet the recycling condition. 2.The method of claim 1, wherein the specified time period is determined, specifically comprising: obtaining a preset revocation keeping time; determining a time period with a current time as a terminal time and the revocation keeping time as a time length, as the specified time period. 3.The method of claim 1, wherein the specified snapshot point in each snapshot point is determined according to the specified time period, specifically comprising: determining a starting time of the specified time period; determining a snapshot point closest to and earlier than the starting time as the specified snapshot point. 4.The method of claim 1, wherein the secondary data file to be consolidated is selected from each secondary data file according to the specified time period, specifically comprising: determining a starting time of the specified time period; for each secondary data file, determining whether the earliest write time of data in the secondary data file is earlier than the starting time; if yes, determining that the secondary data file is the secondary data file to be consolidated.
5. The method of claim 1, wherein the statistical information of each data in the specified file comprises at least: whether all data in the specified file are committed, and the maximum commit time of each data in the specified file. 6.The method of claim 1, wherein the macro blocks kept in the specified file which does not meet the recycling condition are consolidated, specifically comprising: determining each micro block contained in the macro blocks in the specified file which does not meet the recycling condition as a micro block to be processed; for each micro block to be processed, determining statistical information of data in the micro block to be processed. when it is determined, according to the statistical information of the data in the to-be-processed microblock, that all the data in the to-be-processed microblock are committed and the maximum commit time of the data in the to-be-processed microblock is not later than the specified snapshot point, deleting the to-be-processed microblock; when it is determined, according to the statistical information of the data in the to-be-processed microblock, that not all the data in the to-be-processed microblock are committed or the maximum commit time of the data in the to-be-processed microblock is later than the specified snapshot point, retaining the to-be-processed microblock; merging the retained to-be-processed microblocks.
7. The method of claim 6, wherein the merging the retained to-be-processed microblocks comprises: determining, for each data in the to-be-processed microblock, an attribute of the data; when it is determined, according to the attribute of the data, that the data are committed and the commit time of the data is not later than the specified snapshot point, deleting the data; when it is determined, according to the attribute of the data, that the data are not committed or the commit time of the data is later than the specified snapshot point, retaining the data; merging the retained data in the to-be-processed microblock.
8. An apparatus for data merging, the apparatus comprising: a first determining module configured to determine a specified time period; a second determining module configured to determine, according to the specified time period, a specified snapshot point among snapshot points and select, according to the specified time period, a to-be-merged secondary data file among secondary data files as a specified file; a judging module configured to determine, for each specified file, whether the specified file meets a preset recycling condition according to statistical information of data in the specified file, wherein the judging module is specifically configured to, for each specified file, determine that the specified file meets the preset recycling condition when all the data in the specified file are committed and the maximum commit time of the data in the specified file is not later than the specified snapshot point, and determine that the specified file does not meet the recycling condition when not all the data in the specified file are committed or the maximum commit time of the data in the specified file is later than the specified snapshot point; and recycle storage space occupied by the secondary data file if the specified file meets the recycling condition; a recycling module configured to, when the judging module determines that the specified file does not meet the recycling condition, recycle, for each macroblock in the specified file, storage space occupied by the macroblock when it is determined, according to statistical information of data in the macroblock, that all the data in the macroblock are committed and the maximum commit time of the data in the macroblock is not later than the specified snapshot point; a retaining module configured to retain, for each macroblock in the specified file, the macroblock when it is determined, according to statistical information of data in the macroblock, that not all the data in the macroblock are committed or the maximum commit time of the data in the macroblock is later than the specified snapshot point; a merging module configured to merge retained macroblocks in the specified file that do not meet the recycling condition.
9. The apparatus of claim 8, wherein the first determining module is specifically configured to acquire a preset revocation retention duration, and determine, as the specified time period, a time period with a current time as a terminal time and a duration of the revocation retention duration.
10. The apparatus of claim 8, wherein the second determining module is specifically configured to determine a starting time point of the specified time period; and determine a snapshot point closest to and earlier than the starting time point as the specified snapshot point.
11. The apparatus of claim 8, wherein the second determining module is specifically configured to determine a starting time point of the specified time period; and for each secondary data file, determine whether the earliest write time of the data in the secondary data file is earlier than the starting time point; and if yes, determine the secondary data file as the secondary data file to be merged.
12. The apparatus of claim 8, wherein the statistical information of each data in the specified file comprises at least: whether all the data in the specified file is committed, and the maximum commit time of the data in the specified file.
13. The apparatus of claim 8, wherein the merging module is specifically configured to determine each microblock contained in the macroblock in the specified file that does not satisfy the recycling condition as a microblock to be processed; for each microblock to be processed, determine the statistical information of the data in the microblock to be processed; when it is determined according to the statistical information of the data in the microblock to be processed that all the data in the microblock to be processed is committed, and the maximum commit time of the data in the microblock to be processed is not later than the specified snapshot point, delete the microblock to be processed; when it is determined according to the statistical information of the data in the microblock to be processed that not all the data in the microblock to be processed is committed, or the maximum commit time of the data in the microblock to be processed is later than the specified snapshot point, retain the microblock to be processed; and merge the retained microblocks to be processed.
14. The apparatus of claim 13, wherein the merging module is specifically configured to, for each data in the microblock to be processed, determine the attribute of the data; when it is determined according to the attribute of the data that the data is committed, and the commit time of the data is not later than the specified snapshot point, delete the data; when it is determined according to the attribute of the data that the data is not committed, or the commit time of the data is later than the specified snapshot point, retain the data; and merge the retained data in the microblock to be processed.
15. A computer readable storage medium, the storage medium storing a computer program, the computer program being executed by a processor to implement the method of any one of claims 1-7.
16. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the method of any one of claims 1-7 when executing the program.
Citation Information
Patent Citations
Partition splitting method and device, electronic equipment and readable storage medium
CN110032549A
Data processing method and device for target database
CN115185922A