File migration comparison verification method and device and medium
By using bit arrays and hash functions in memory to determine file migration status, the problems of low efficiency and consistency of traditional file migration are solved, and the migration efficiency and storage efficiency are improved.
Patent Information
- Application Number
- CN202411095903.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-11-01
AI Technical Summary
Traditional file migration verification schemes are inefficient, which can easily lead to performance bottlenecks and data consistency problems, especially when large-scale file processing is high.
By creating a bit array in memory, using the hash function to determine the index information of the file, determine whether the file has been migrated, avoid database or file system metadata query, and directly store and update the migration status in memory.
Improve file migration efficiency, reduce communication delay and data consistency problems, save storage space, and avoid delays caused by external communication and IO operations.
Smart Images

Figure CN118885442A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer data management, and in particular to a file migration comparison and verification method, device and medium. Background Art
[0002] In the information age, file migration is one of the common requirements in data management. It is especially important in the provision of services such as data backup, data center migration, and cloud storage. In the process of file migration, migration verification is generally required to avoid duplicate migration and ensure the integrity and accuracy of file migration.
[0003] Traditional migration verification solutions usually rely on the metadata of the database or file system. Specifically: When performing the first file migration, use the database table to record the relevant information of the migrated files, such as modification time, file size, MD5 (Message Digest Algorithm MD5, a message digest algorithm) value, etc. When performing incremental migration later, query the relevant information of the migrated files from the database for comparison and verification to determine the files that have not been migrated for incremental migration. Alternatively, do not use database records and directly read the metadata information of the file system according to the destination file path for comparison and verification. This migration verification method requires an input / output (IO) operation to read the disk.
[0004] The above solution relies on the database or reading the metadata of the file system, which involves external communication and interaction, and there is a certain delay. Specifically, the query operation of the database may become very time-consuming when the amount of data increases, and the metadata update of the file system may also be delayed or erroneous, and an additional IO data read of the destination file system is required. Therefore, the above solution is inefficient when processing large-scale files, and is prone to performance bottlenecks and data consistency issues.
[0005] Therefore, technicians in this field are in urgent need of a file migration comparison and verification method to solve the problems of low efficiency, performance bottlenecks and data consistency of traditional solutions. Summary of the invention
[0006] The purpose of the present invention is to provide a file migration comparison and verification method, device and medium, which are used to solve the problems of low efficiency, easy to cause performance bottlenecks and data consistency of traditional solutions.
[0007] In order to solve the above technical problems, the present invention provides a file migration comparison and verification method, comprising:
[0008] Acquire unique file information of a file to be migrated; wherein the unique file information of different files to be migrated is different;
[0009] Determine corresponding index information through a hash function according to the unique file information;
[0010] According to the index information, query the setting state of the corresponding bit on the pre-created bit array in the memory to determine whether the file to be migrated has been migrated; wherein the setting state of each bit on the bit array includes a migrated state and a not-migrated state, and the initial state is the not-migrated state;
[0011] If the file to be migrated has been migrated, skip this migration;
[0012] If the file to be migrated has not been migrated, the current file to be migrated is put into a queue to be migrated, and after the migration is completed, the corresponding bit on the bit array is set to a migrated state.
[0013] In a possible embodiment, there are multiple hash functions;
[0014] Then, according to the unique file information, the corresponding index information is determined by a hash function, including:
[0015] According to the unique file information, determining corresponding multiple different index information by using multiple hash functions;
[0016] Then, according to the index information, querying the setting state of the corresponding bit on the pre-created bit array in the memory to determine whether the file to be migrated has been migrated includes:
[0017] According to the plurality of index information, querying the setting states of the corresponding plurality of bits on the bit array;
[0018] If the setting states of the multiple bits are all in the migrated state, it is determined that the file to be migrated has been migrated;
[0019] If the setting states of the multiple bits are all in the not-migrated state, it is determined that the to-be-migrated file has not been migrated;
[0020] After the migration is completed, the corresponding bit on the bit array is set to a migrated state, including:
[0021] After the migration is completed, all the corresponding multiple bits on the bit array are set to a migrated state.
[0022] In a possible embodiment, when the plurality of hash functions are created, different function numbers are assigned;
[0023] Then, according to the unique file information, determining the corresponding multiple different index information through multiple hash functions includes:
[0024] The plurality of hash functions respectively use the corresponding function numbers as function seed values to determine the index information.
[0025] In a possible embodiment, after querying the setting states of the corresponding multiple bits on the bit array according to the multiple index information, the method further includes:
[0026] If the setting state of some bits is the migrated state and the setting state of other bits is the unmigrated state, it is determined that the to-be-migrated file has a hash collision;
[0027] The method further comprises:
[0028] If a hash collision occurs in the file to be migrated, obtaining the unique file information of the file to be migrated;
[0029] According to the unique file information, query whether the metadata information of the file to be migrated exists in the destination file system; wherein the destination file system is the recipient of the file to be migrated during the migration process;
[0030] If it exists, it is determined that the file to be migrated has been migrated;
[0031] If it does not exist, it is determined that the file to be migrated has not been migrated.
[0032] In a possible embodiment, the unique file information is the destination file path of the file to be migrated;
[0033] The destination file path is a file path where the file to be migrated is stored in the destination file system.
[0034] In a possible embodiment, determining corresponding index information through a hash function according to the unique file information includes:
[0035] Determine the hash value corresponding to the destination file path by using the hash function;
[0036] Convert the hash value into integer form;
[0037] A modulo operation is performed on the hash value in integer form, and the result of the modulo operation is used as the corresponding index information.
[0038] In a possible embodiment, the process of pre-creating the bit array includes:
[0039] Obtain the expected number of migrated files and the allowable false positive rate during this file migration process;
[0040] Determining the number of the hash functions according to the allowable false positive rate; wherein the number of the hash functions is negatively correlated with the allowable false positive rate;
[0041] Determining an expected array length according to the product of the expected number of migration files and the number of hash functions;
[0042] Determine the actual array length according to the expected array length and the allowable false positive rate; wherein the actual array length is greater than the expected array length, and the difference between the actual array length and the expected array length is negatively correlated with the allowable false positive rate;
[0043] Create the bit array in memory with a length equal to the actual array length.
[0044] In order to solve the above technical problems, the present invention also provides a file migration comparison and verification device, comprising:
[0045] An information acquisition module, used for acquiring unique file information of a file to be migrated; wherein the unique file information of different files to be migrated is different;
[0046] An index determination module, used to determine corresponding index information through a hash function according to the unique file information;
[0047] A migration comparison module, used to query the setting state of the corresponding bit on the pre-created bit array in the memory according to the index information, so as to determine whether the file to be migrated has been migrated; wherein the setting state of each bit on the bit array includes a migrated state and a not-migrated state, and the initial state is the not-migrated state;
[0048] A migration skip module, used to skip the current migration if the file to be migrated has been migrated;
[0049] The file migration module is used for placing the current file to be migrated into a queue to be migrated if the file to be migrated has not been migrated, and setting the corresponding bit on the bit array to a migrated state after the migration is completed.
[0050] In order to solve the above technical problems, the present invention also provides a file migration comparison and verification device, comprising:
[0051] Memory for storing computer programs;
[0052] A processor is used to implement the steps of the file migration comparison and verification method as described above when executing the computer program.
[0053] In order to solve the above technical problem, the present invention also provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the file migration comparison and verification method as described above are implemented.
[0054] The present invention provides a file migration comparison and verification method, which implements the storage of file migration information through a bit array created in a memory. Specifically, whenever a file needs to be migrated, firstly, according to the unique file information of the file, the index information of the current file to be migrated, that is, the position of the file mapped on the bit array, is determined through a hash function; then, the data setting state of the corresponding bit in the bit array is queried according to the index information; the setting state includes two states, a migrated state and a non-migrated state, which indicate whether the current file to be migrated has been migrated in the previous file migration process; if it has been migrated, this migration is skipped; if it has not been migrated, the file to be migrated is normally migrated, and after the migration is completed, the corresponding bit on the bit array is set to ensure that the migration status of the bit array is synchronized with the actual file.
[0055] Based on the above, it is not difficult to see that this method only needs a bit array stored in the memory to determine whether each file to be migrated has been migrated, without accessing the database or the destination file system, thus avoiding the communication delay caused by external communication and access to IO, improving the efficiency of file migration, and reducing the possibility of performance bottlenecks and data consistency problems. In addition, the bit array implemented based on this method represents the migration status of the file, and usually only a few data bits (at least one bit) are required to achieve the representation and storage of the migration status of a file, saving space, so that the bit array can be stored in the same unit of storage size. The cost is higher, but the data reading efficiency is faster, so as to further improve the efficiency of file migration.
[0056] The file migration comparison and verification device and non-volatile storage medium provided by the present invention correspond to the above method and have the same effect as above. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0058] Figure 1 A flowchart of a file migration comparison and verification method provided by the present invention;
[0059] Figure 2 A schematic diagram of the overall process of a file migration comparison and verification method provided by the present invention;
[0060] Figure 3 A schematic diagram of a bit array of a file to be verified that has not been migrated provided by the present invention;
[0061] Figure 4 A schematic diagram of a bit array of a file to be verified that has been migrated provided by the present invention;
[0062] Figure 5 A structural diagram of a file migration comparison and verification device provided by the present invention;
[0063] Figure 6 A structural diagram of another file migration comparison and verification device provided by the present invention. DETAILED DESCRIPTION
[0064] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0065] The core of the present invention is to provide a file migration comparison and verification method, device and medium.
[0066] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0067] In related technologies, the migration status of files is usually stored in a database, or the metadata of the files to be migrated is accessed in the destination file system to avoid repeated migration of files. Both of the above solutions involve external communication. The query operation of the database may become very time-consuming when the amount of data increases; the metadata update of the file system may also be delayed or erroneous, and an additional input / output (IO) data read is required for the destination file system, which greatly increases the communication delay and affects the migration efficiency of the files.
[0068] Therefore, in order to solve the above problems, the present invention provides a file migration comparison verification method, such as Figure 1 As shown, including:
[0069] S11: Acquire unique file information of the file to be migrated.
[0070] Among them, the unique file information of different files to be migrated is different.
[0071] S12: Determine corresponding index information through a hash function according to the unique file information.
[0072] S13: According to the index information, query the setting state of the corresponding bit on the pre-created bit array in the memory to determine whether the file to be migrated has been migrated; if the file to be migrated has been migrated, go to step S14; if the file to be migrated has not been migrated, go to step S15.
[0073] The setting state of each bit in the bit array includes a migrated state and an unmigrated state, and the initial state is the unmigrated state.
[0074] S14: Skip this migration.
[0075] S15: The current file to be migrated is placed in a queue to be migrated, and after the migration is completed, the corresponding bit on the bit array is set to a migrated state.
[0076] Regarding step S11, it should be noted that the unique file information obtained in this step is used to determine the index information in the subsequent steps. In order to ensure that the mapping of the files to be migrated on the bit array does not conflict, the index information of each file to be migrated should be unique. Therefore, based on this, the unique file information obtained in this embodiment can be any unique information related to the file to be migrated.
[0077] Considering the implementation cost and difficulty, one of the existing relevant information of the file can be selected as the unique file information. The file information of the file to be migrated includes: modification time, file size, MD5 (Message Digest Algorithm MD5, a message digest algorithm) value, destination file path information, etc. Among them, the modification time and file size cannot guarantee the uniqueness of each file, so they cannot be used as the above-mentioned unique file information. In a possible implementation scheme, the destination file path information is the file path of the file to be migrated stored in the destination file system, which is generally unique and can be used as a possible implementation scheme for the unique file information in this step.
[0078] For step S12, the unique file information determined in the above step and uniquely corresponding to the file to be migrated is converted into discrete position information on the bit array, namely, index information. Based on the above conversion requirements from unique file information to index information, it can be achieved through a hash function. The hash function can use the keyword K (i.e., unique file information) of the data element as an independent variable, and map it into a discrete storage address (i.e., index information) through a certain functional relationship, meeting the requirements of the present invention. Similarly, other solutions that can convert unique file information into a unique corresponding discrete position on a bit array can replace the hash function in this method.
[0079] It should also be noted that there are currently a variety of mature implementation schemes for hash functions. Taking the Message Digest Algorithm as an example, there are currently a variety of calculation methods from MD2 to MD5 that can be used to implement the hash function in this step. In a possible implementation scheme, the hash function in this embodiment is implemented based on the MD5 algorithm.
[0080] Step S13 is a process of determining whether the current file to be migrated has been migrated by characterizing the pre-created bit array in the memory. The bit array is an integer array, and each bit of the integer represents an object. That is, each bit in the bit array can be used to characterize the migration status of a file, and the relationship between the file and each data bit in the bit array is established by using the index information.
[0081] Furthermore, in this method, the file migration status that needs to be represented by the bits on the bit array includes two states: migrated and unmigrated, which correspond to the two possibilities of 1-bit binary data: "0" and "1". According to behavioral habits, it is generally determined that binary data "0" represents the unmigrated state, and binary data "1" represents the migrated state. When the bit array is initially created, it is an array of all "0", that is, the initial state of all bits is the unmigrated state.
[0082] Based on this, step S14 can determine whether the binary data stored in the corresponding bit of the bit array in the memory is "0" or "1" according to the index information to determine whether the current file to be migrated has been migrated.
[0083] After determining whether the current file to be migrated has been migrated to the destination file system through step S13, there are two possible branches, namely step S14 and step S15. Among them, step S14 corresponds to the current file to be migrated having been migrated. At this time, in order to avoid repeated migration, this file migration process should be skipped. Step S15 corresponds to the current file to be migrated not being migrated, and the file to be migrated needs to be placed in the queue to be migrated to achieve normal file migration. In addition, after the file migration is completed, the state of the corresponding bit on the bit array needs to be set and updated to the migrated state to ensure state synchronization in preparation for the next file migration process.
[0084] Based on the above steps, this embodiment also provides a schematic diagram of the overall process of a file migration comparison and verification method. Figure 2 As shown in the figure: during a file migration process, all files to be migrated are respectively determined to have their positions on the bit array (i.e., the corresponding bits) through a hash function; based on the binary data at the corresponding positions on the bit array (i.e., the set state), it is determined whether the current file has been migrated; and migration is performed or skipped accordingly to avoid repeated migration of files.
[0085] It should be noted that Figure 2 The three hash functions shown in are only one possible implementation of the method. The hash function used in the method may also be one or another number, which is not limited in this embodiment.
[0086] In summary, the file migration comparison and verification method provided by the present invention can map the migration status of each file to the data stored in a specific position on the bit array for storage and characterization. This solution only requires one or several bits of data to characterize the migration status of a file, and occupies very little storage resources, so it can be stored in the memory, that is, the bit array is located in the memory. Based on this, the method does not need to communicate with the outside to obtain the migration status of the file, avoiding the delay caused by external communication and greatly improving the efficiency of file migration comparison. It also avoids the data consistency, integrity and performance bottleneck problems that may be caused by storing the data that can be used to judge the migration status in other terminals.
[0087] Furthermore, the above embodiments do not limit the number of hash functions used, and one hash function or multiple hash functions may be used. In this embodiment, a possible implementation scheme is provided: there are multiple hash functions.
[0088] Correspondingly, the above step S12 is specifically as follows:
[0089] According to the unique file information, corresponding multiple different index information is determined through multiple hash functions.
[0090] Accordingly, the above step S13 specifically includes:
[0091] S131: Query the setting states of the corresponding multiple bits in the bit array according to the multiple index information.
[0092] S132: If the setting states of the multiple bits are all in the migrated state, it is determined that the file to be migrated has been migrated.
[0093] S133: If the setting states of the multiple bits are all in the not-migrated state, it is determined that the file to be migrated has not been migrated.
[0094] Correspondingly, the above step S15: after the migration is completed, the corresponding bit on the bit array is set to the migrated state, specifically:
[0095] After the migration is completed, all the corresponding bits on the bit array are set to the migrated state.
[0096] That is, in this method, although the hash function is performed using different unique file information corresponding to each file to be migrated as a keyword, in the hope that each file to be migrated corresponds to a different position in the bit array (i.e., different index information), it is considered that hash functions inevitably have a hash collision phenomenon, i.e., two different input values get the same output value. This is reflected in this method, i.e., two different files to be migrated correspond to the same position in the bit array, which may lead to misjudgment.
[0097] Therefore, in this embodiment, multiple hash functions are used to reduce the adverse effects of hash collisions on the file migration and comparison process. Multiple different hash functions are used to map the same file to be migrated to discrete positions, that is, to obtain multiple different index information, which are mapped to different positions in the bit array. Figure 3 As shown in , only when the data on all bits are in the migrated state, it is determined that the current file to be migrated has been migrated; Figure 4 As shown, only when the data on all bits are in the unmigrated state, is it determined that the current file to be migrated has not been migrated; since the probability of a plurality of different hash functions having the same hash collision at the same time is much smaller than the probability of a hash collision occurring in one hash function, this embodiment can reduce the misjudgment rate caused by hash collision.
[0098] It is easy to understand that as the number of hash functions increases, the false positive rate caused by hash collisions will decrease, the computational complexity will increase, and the length of the bit array will increase. However, there is a marginal effect in reducing the false positive rate. When the number of hash functions grows to a certain extent, the effect of reducing the false positive rate brought about by increasing the number of hash functions will continue to decrease until it can be ignored. However, there is no marginal effect on the increase in computational complexity and the increase in the length of the bit array brought about by the increase in the number of hash functions. Therefore, the number of hash functions should not be selected blindly as a high value, but should be selected according to the actual false positive rate requirements. In one possible embodiment, Figure 2 As shown, the number of hash functions can be selected as 3.
[0099] On the basis of the above embodiment, in order to further reduce the possibility of hash collision, this embodiment also provides a further implementation scheme:
[0100] When multiple hash functions are created, they are assigned different function numbers;
[0101] Correspondingly, step S12: determining the corresponding multiple different index information through multiple hash functions according to the unique file information is specifically:
[0102] Multiple hash functions use corresponding function numbers as function seed values to determine index information.
[0103] For example, taking three hash functions as an example, when the hash functions are created, different function numbers 1, 2, and 3 are assigned to them respectively, that is, Figure 2 As shown, there are hash function 1, hash function 2 and hash function 3. When these three hash functions perform discrete mapping on the same unique file information, function numbers 1, 2 and 3 are used as function seed values to ensure that the hash values output by these three hash functions for the same unique file information are different, further reducing the probability of hash collision.
[0104] On the other hand, based on the above-mentioned embodiments using multiple hash functions, only when all bits on the bit array corresponding to the file to be migrated are set to the migrated state, is it determined that the file has been migrated, and only when all corresponding bits on the bit array are in the unmigrated state, is it determined that the file has not been migrated. However, in addition to these two situations, there is also a situation where some bits are set to the migrated state and other bits remain in the unmigrated state, that is, a scenario where a hash collision occurs. Regarding how to implement file migration comparison verification in the scenario where a hash collision occurs, this embodiment provides a possible implementation scheme. After step S131, this method also includes:
[0105] S134: If the setting status of some bits is the migrated status and the setting status of other bits is the unmigrated status, it is determined that a hash collision occurs in the file to be migrated.
[0106] Accordingly, the method further comprises:
[0107] S161: If a hash collision occurs in the file to be migrated, unique file information of the file to be migrated is obtained;
[0108] S162: According to the unique file information, query whether the metadata information of the file to be migrated exists in the destination file system; if so, go to step S163; if not, go to step S164.
[0109] The destination file system is the recipient of the files to be migrated during the migration process.
[0110] S163: Determine that the file to be migrated has been migrated.
[0111] At this time, step S14 is triggered accordingly.
[0112] S164: Determine that the file to be migrated has not been migrated.
[0113] At this time, step S15 is triggered accordingly.
[0114] That is, this embodiment provides a file migration comparison and verification scheme in the event of a hash collision. It queries the destination file system to see whether there is metadata of the current file to be migrated, so as to determine whether the current file to be migrated has been migrated to the destination file system, thereby deciding whether to migrate it, thereby ensuring the integrity of the file migration comparison and verification.
[0115] It should be noted that the solution of this embodiment, which determines whether the file to be migrated has been migrated by querying whether there is metadata of the data to be migrated in the destination file system, is a supplementary solution in the scenario of hash collision. Although external communication is required, considering the settings based on the above embodiment in actual application (unique file information and different function seed values, etc.), hash collision is a low-probability event. Therefore, the decrease in file migration efficiency brought about by this method is controllable and will not have a significant impact on the overall file migration efficiency, but the guarantee effect of file migration consistency brought about by the scheme of this embodiment is more significant, which is another important condition in the actual file comparison and verification implementation scenario.
[0116] In addition, based on the implementation scheme in the hash collision scenario provided in the above embodiment, this embodiment also provides a further implementation scheme:
[0117] S17: Mark all index information corresponding to the current file to be migrated as abnormal index information and output it.
[0118] That is, this embodiment provides a solution for exporting the abnormal bit array position in a hash collision scenario, which is convenient for relevant personnel to subsequently grasp the hash collision situation during the file migration process, and can adjust relevant parameters such as the number of hash functions, function seed values, selected file unique information and bit array length according to the abnormal position to improve the hash collision problem.
[0119] It is particularly important to note that, based on the above embodiments, this embodiment further provides a possible abnormal bit determination solution:
[0120] S21: taking the current file to be migrated as the target file, taking the file to be migrated before the current file to be migrated as the file to be tested, and initializing the bit array.
[0121] S22: re-performing file migration comparison and verification with the target file as the first file to be migrated and the file to be tested as the subsequent other files to be migrated.
[0122] Among them, this file migration comparison and verification only performs comparison and verification, and does not perform file migration.
[0123] S23: When a hash collision is determined to occur in a file to be migrated again, the same index information of the file to be migrated and the target file is used as abnormal index information.
[0124] That is, this embodiment provides a solution for re-comparison verification to determine abnormal index information. By determining the index information of all files to be migrated that have previously completed migration comparison verification, it is determined whether there is the same index information as the current file to be migrated; if so, the index information is determined to be abnormal index information.
[0125] In addition, this embodiment also provides another solution for determining abnormal index information, which, after step S161, further includes:
[0126] S165: Determine index information corresponding to bits in the migrated state among all bits on the bit array corresponding to the current file to be migrated, as abnormal index information.
[0127] In this embodiment, since the initial state of each bit in the bit array is the un-migrated state, it is set to the migrated state only when the corresponding file to be migrated is migrated. Therefore, when it is determined that a hash collision occurs in a file to be migrated, the bit set to the migrated state among all the corresponding bits is more likely to be set after the previous file to be migrated is migrated, so this bit is an abnormal bit, and the corresponding index information is abnormal index information.
[0128] It should be noted that compared with the abnormal index information determination scheme provided in the previous embodiment, this embodiment is easier to implement and more efficient, but the accuracy of judging abnormal index information is generally not as good as that of the previous embodiment. Therefore, a suitable abnormal index information determination scheme can be selected according to actual needs.
[0129] In addition, the above abnormal index information determination solution generally occurs after the file migration process is completed to avoid adverse effects on the file migration process and affect the file migration efficiency.
[0130] On the other hand, the above embodiment does not limit how to map the unique file information into discrete positions on the bit array through the hash function in the method, that is, to obtain the index information, but this embodiment provides a possible implementation scheme, taking the unique file information as the destination file path as an example, the above step S12 specifically includes:
[0131] S121: Determine a hash value corresponding to the destination file path through a hash function;
[0132] S122: converting the hash value into an integer form;
[0133] S123: Perform a modulo operation on the hash value in integer form, and use the result of the modulo operation as the corresponding index information.
[0134] It is easy to know that the hash value converted from the target file path by the hash function is a long string of outputs, which is not easy to directly map to a unique position on the bit array. Therefore, this embodiment converts the hash value output by the hash function into an integer form to meet the needs of the modulus operation, and then converts the hash value into an integer value through the modulus operation, so as to correspond to the unique one-bit data in the bit array, thereby ensuring that the file to be migrated can be smoothly and discretely mapped to the bit array.
[0135] On the other hand, it can be seen from the above embodiments that the number of hash functions will affect the length of the bit array. Similarly, the length of the bit array is also related to the number of files expected to be migrated and the allowable false positive rate. Based on this, this embodiment provides a possible bit array creation scheme:
[0136] S31: Obtain the expected number of migrated files and the allowable false positive rate in this file migration process.
[0137] S32: Determine the number of hash functions according to the allowed false positive rate.
[0138] Among them, the number of hash functions is negatively correlated with the allowable false positive rate.
[0139] S33: Determine the expected array length according to the product of the expected number of migration files and the number of hash functions.
[0140] S34: Determine the actual array length according to the expected array length and the allowable false positive rate.
[0141] Among them, the actual array length is greater than the expected array length, and the difference between the actual array length and the expected array length is negatively correlated with the allowable misjudgment rate.
[0142] S35: Create a bit array in memory with a length equal to the actual array length.
[0143] It should be noted that the above embodiments have illustrated that increasing the number of hash functions can reduce misjudgments caused by hash collisions. Therefore, the number of hash functions can be determined based on a preset allowable misjudgment rate. The specific selection rules or logic can be found in the above embodiments and will not be elaborated here.
[0144] It is also easy to know that based on the number of hash functions used, a file to be migrated will be mapped to a corresponding number of different positions on the bit array, so the product of the number of hash functions and the expected number of migrated files can determine the minimum bit array length required to satisfy the discrete mapping of all files to be migrated, that is, the expected array length.
[0145] Furthermore, since the longer the bit array is, the less likely it is that a collision will occur when the bit array is mapped to the bit array by the hash function, the bit array actually created should be larger than the minimum bit array length determined above, and the specific degree of larger should be determined according to the allowed false positive rate. The higher the allowed false positive rate is, the smaller the actual array length can be, and vice versa.
[0146] In summary, this embodiment provides a scheme for creating a bit array and a scheme for selecting the number of hash functions, that is, a parameter setting scheme for file migration comparison verification provided by the present invention. Based on the expected number of files and the allowable false positive rate, a more appropriate number of hash functions and bit array length can be determined based on the scheme of this embodiment to ensure that the false positive rate meets the requirements and the bit array length is as small as possible, occupying less memory resources.
[0147] In the above embodiment, a file migration comparison and verification method is described in detail, and the present invention also provides a corresponding embodiment of a file migration comparison and verification device. It should be noted that the present invention describes the embodiment of the device part from two perspectives, one is based on the perspective of functional modules, and the other is based on the perspective of hardware.
[0148] Based on the functional module perspective, such as Figure 5 As shown, this embodiment provides a file migration comparison and verification device, including:
[0149] The information acquisition module 11 is used to acquire unique file information of the file to be migrated; wherein the unique file information of different files to be migrated is different;
[0150] An index determination module 12, configured to determine corresponding index information through a hash function according to the unique file information;
[0151] The migration comparison module 13 is used to query the setting state of the corresponding bit on the pre-created bit array in the memory according to the index information to determine whether the file to be migrated has been migrated; wherein the setting state of each bit on the bit array includes a migrated state and a non-migrated state, and the initial state is the non-migrated state;
[0152] A migration skipping module 14 is used to skip the current migration if the file to be migrated has been migrated;
[0153] The file migration module 15 is used to put the current file to be migrated into the migration queue if the file to be migrated has not been migrated, and set the corresponding bit on the bit array to the migrated state after the migration is completed.
[0154] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0155] Figure 6 A structural diagram of a file migration comparison and verification device provided by another embodiment of the present invention, such as Figure 6 As shown, a file migration comparison and verification device includes: a memory 20, for storing a computer program;
[0156] The processor 21 is used to implement the steps of a file migration comparison and verification method in the above embodiment when executing a computer program.
[0157] The file migration comparison and verification device provided in this embodiment may include but is not limited to a mobile terminal, a personal computer, a workstation, etc.
[0158] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0159] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201, wherein, after the computer program is loaded and executed by the processor 21, it can implement the relevant steps of a file migration comparison and verification method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. Data 203 may include but is not limited to a file migration comparison and verification method, etc.
[0160] In some embodiments, a file migration comparison and verification device may further include a display screen 22 , an input and output interface 23 , a communication interface 24 , a power supply 25 , and a communication bus 26 .
[0161] Those skilled in the art will understand that Figure 6 The structure shown in the figure does not constitute a limitation on a file migration comparison and verification device, and may include more or fewer components than those shown in the figure.
[0162] A file migration comparison and verification device provided by an embodiment of the present invention includes a memory and a processor. When the processor executes a program stored in the memory, it can implement the following method: a file migration comparison and verification method.
[0163] In addition to the embodiments of the file migration comparison and verification method and device provided in the above embodiments, the present invention also provides an embodiment corresponding to a computer program product. A computer program product includes a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the file migration comparison and verification method described in any of the above embodiments can be implemented.
[0164] Since the embodiments of the computer program product part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the computer program product part, which will not be repeated here.
[0165] Finally, the present invention also provides an embodiment corresponding to a non-volatile storage medium. The non-volatile storage medium stores a computer program, and when the computer program is executed by a processor, the steps recorded in the above method embodiment are implemented.
[0166] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc. Various media that can store program codes.
[0167] The above is a detailed introduction to a file migration comparison and verification method, device and medium provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referenced to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the present invention.
[0168] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A file migration comparison and verification method, It is characterized in that include: Acquire unique file information of a file to be migrated; wherein the unique file information of different files to be migrated is different; Determine corresponding index information through a hash function according to the unique file information; According to the index information, query the setting state of the corresponding bit on the pre-created bit array in the memory to determine whether the file to be migrated has been migrated; wherein the setting state of each bit on the bit array includes a migrated state and a not-migrated state, and the initial state is the not-migrated state; If the file to be migrated has been migrated, skip this migration; If the file to be migrated has not been migrated, the current file to be migrated is put into a queue to be migrated, and after the migration is completed, the corresponding bit on the bit array is set to a migrated state.
2. The file migration comparison and verification method according to claim 1, It is characterized in that There are multiple hash functions; Then, according to the unique file information, the corresponding index information is determined by a hash function, including: According to the unique file information, determining corresponding multiple different index information by using multiple hash functions; Then, according to the index information, querying the setting state of the corresponding bit on the pre-created bit array in the memory to determine whether the file to be migrated has been migrated includes: According to the plurality of index information, querying the setting states of the corresponding plurality of bits on the bit array; If the setting states of the multiple bits are all in the migrated state, it is determined that the file to be migrated has been migrated; If the setting states of the multiple bits are all in the not-migrated state, it is determined that the to-be-migrated file has not been migrated; After the migration is completed, the corresponding bit on the bit array is set to a migrated state, including: After the migration is completed, all the corresponding multiple bits on the bit array are set to a migrated state.
3. The file migration comparison and verification method according to claim 2, It is characterized in that When the plurality of hash functions are created, different function numbers are assigned; Then, according to the unique file information, determining the corresponding multiple different index information through multiple hash functions includes: The plurality of hash functions respectively use the corresponding function numbers as function seed values to determine the index information.
4. The file migration comparison and verification method according to claim 2, It is characterized in that After querying the setting states of the corresponding multiple bits on the bit array according to the multiple index information, the method further includes: If the setting state of some bits is the migrated state and the setting state of other bits is the unmigrated state, it is determined that the to-be-migrated file has a hash collision; The method further comprises: If a hash collision occurs in the file to be migrated, obtaining the unique file information of the file to be migrated; According to the unique file information, query whether the metadata information of the file to be migrated exists in the destination file system; wherein the destination file system is the recipient of the file to be migrated during the migration process; If it exists, it is determined that the file to be migrated has been migrated; If it does not exist, it is determined that the file to be migrated has not been migrated.
5. The file migration comparison and verification method according to claim 4, It is characterized in that The unique file information is the destination file path of the file to be migrated; The destination file path is a file path where the file to be migrated is stored in the destination file system.
6. The file migration comparison and verification method according to claim 5, It is characterized in that Determining corresponding index information through a hash function according to the unique file information includes: Determine the hash value corresponding to the destination file path by using the hash function; Convert the hash value into integer form; A modulo operation is performed on the hash value in integer form, and the result of the modulo operation is used as the corresponding index information.
7. The file migration comparison and verification method according to any one of claims 2 to 6, It is characterized in that The process of pre-creating the bit array includes: Obtain the expected number of migrated files and the allowable false positive rate during this file migration process; Determining the number of the hash functions according to the allowable false positive rate; wherein the number of the hash functions is negatively correlated with the allowable false positive rate; Determining an expected array length according to the product of the expected number of migration files and the number of hash functions; Determine the actual array length according to the expected array length and the allowable false positive rate; wherein the actual array length is greater than the expected array length, and the difference between the actual array length and the expected array length is negatively correlated with the allowable false positive rate; Create the bit array in memory with a length equal to the actual array length.
8. A file migration comparison and verification device, It is characterized in that include: An information acquisition module, used for acquiring unique file information of a file to be migrated; wherein the unique file information of different files to be migrated is different; An index determination module, used to determine corresponding index information through a hash function according to the unique file information; A migration comparison module, used to query the setting state of the corresponding bit on the pre-created bit array in the memory according to the index information, so as to determine whether the file to be migrated has been migrated; wherein the setting state of each bit on the bit array includes a migrated state and a not-migrated state, and the initial state is the not-migrated state; A migration skip module, used to skip the current migration if the file to be migrated has been migrated; The file migration module is used for placing the current file to be migrated into a queue to be migrated if the file to be migrated has not been migrated, and setting the corresponding bit on the bit array to a migrated state after the migration is completed.
9. A file migration comparison and verification device, It is characterized in that include: Memory for storing computer programs; A processor, configured to implement the steps of the file migration comparison and verification method as described in any one of claims 1 to 7 when executing the computer program.
10. A non-volatile storage medium, It is characterized in that The non-volatile storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the file migration comparison and verification method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Data integration method and related equipment
CN119759653A
Data integration method and related apparatus
CN119759653B
