File storage method and device, computer device and storage medium thereof

CN116225324BActive Publication Date: 2026-09-15INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310130584.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-08
Publication Date
2026-09-15
Estimated Expiration
2043-02-08

AI Technical Summary

Technical Problem

[0004]但是,在利用大文件储存方法进行文件储存时,会导致储存所有文件的文件访问速度减慢,影响文件读取效率;在利用小文件储存方法进行文件储存时,会导致独立文件的数量较多,影响系统性能,同样影响文件读取效率

Benefits of technology

[0040] According to the technical solution of this application, by splitting the file to be stored into at least two file data blocks, it is ensured that the split file can be stored locally, thus ensuring the smooth progress of subsequent processes. By using the used capacity of the two local storage spaces and the capacity of the unit data block, the storable amount of local storage space is determined, ensuring that at least two file data blocks can be reasonably allocated according to the storable amount. This ensures that after storing the file data blocks according to the storable amount, the difference in the used capacity of each local storage space is small, achieving a uniform distribution of file data blocks. Furthermore, the above file storage method avoids the problem of slow file reading efficiency when using large file storage methods, improving the access efficiency of local storage space; it also avoids the problem of a large number of local storage spaces when using small file storage methods, improving system performance and the access efficiency of local storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116225324B_ABST
    Figure CN116225324B_ABST
Patent Text Reader

Abstract

The application relates to a file storage method and device, computer equipment and a storage medium thereof, and relates to the technical field of artificial intelligence. The method comprises the following steps: based on the capacity of a unit data block, splitting a to-be-stored file into at least two file data blocks; based on the used capacity of at least two local storage spaces and the capacity of a unit data block, respectively determining the storable amount of the file data blocks corresponding to each local storage space; and based on the storable amount of the file data blocks corresponding to each local storage space, storing each file data block. The method avoids the problem of slow file reading efficiency when a large file storage method is used for file storage, improves the access efficiency of the local storage space; meanwhile, the method also avoids the problem of a large number of local storage spaces caused by using a small file storage method for file storage, improves the system performance, and improves the access efficiency of the local storage space.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a file storage method, apparatus, computer device and storage medium thereof. Background Technology

[0002] With the rapid development of mobile internet, retrieving files from servers has become an important means of communication in people's daily work and life, such as retrieving email addresses from email servers. Storing files locally ensures that the required files can be quickly retrieved later when needed.

[0003] In the existing technology, there are two methods for storing files: large file storage method and small file storage method. The large file storage method refers to storing all files together in one file; the small file storage method refers to storing each file in a separate file.

[0004] However, using the large file storage method for file storage will slow down the access speed of all files and affect the file reading efficiency; using the small file storage method for file storage will result in a large number of independent files, which will affect system performance and file reading efficiency. Summary of the Invention

[0005] Therefore, it is necessary to provide a file storage method, apparatus, computer equipment, and storage medium that can improve file reading efficiency in response to the above-mentioned technical problems.

[0006] Firstly, this application provides a file storage method. The method includes:

[0007] Based on the capacity of a single data block, the file to be stored is split into at least two file data blocks;

[0008] Based on the used capacity of at least two local storage spaces and the capacity of a unit data block, determine the storable amount of file data blocks corresponding to each local storage space;

[0009] Based on the storable amount of file data blocks corresponding to each local storage space, each file data block is stored.

[0010] In one embodiment, based on the used capacity of at least two local storage spaces and the capacity of a unit data block, the storable amount of file data blocks corresponding to each local storage space is determined, including:

[0011] Based on the used capacity of at least two local storage spaces and the capacity of a unit data block, determine the data block content of each local storage space; wherein, the data block content represents the number of unit data blocks equivalent to the used capacity of each local storage space.

[0012] Based on the amount of data blocks contained in each local storage space, determine the storable amount of file data blocks corresponding to each local storage space;

[0013] The differences in target storage capacity between different local storage spaces are all within a preset range; the target storage capacity of each local storage space is the sum of the data block content and the storable capacity of each local storage space.

[0014] In one embodiment, the storable amount of file data blocks corresponding to each local storage space is determined based on the amount of data blocks contained in each local storage space, including:

[0015] Based on the amount of data blocks contained in each local storage space, sort the local storage spaces.

[0016] The difference in the content of data blocks is calculated for each pair of local storage spaces that are adjacent in sorting position, and the content difference between each pair of local storage spaces is obtained.

[0017] Based on the difference in content and the total number of file data blocks, the storable amount of file data blocks corresponding to each local storage space is determined.

[0018] In one embodiment, each local storage space includes a first storage space, a second storage space, and a third storage space; and the used capacity of the first storage space is greater than the used capacity of the second storage space; the used capacity of the second storage space is greater than the used capacity of the third storage space; the content difference includes a first content difference corresponding to the first storage space and the second storage space, and a second content difference corresponding to the second storage space and the third storage space.

[0019] Accordingly, based on the difference in content and the total number of file data blocks, the storable amount of file data blocks corresponding to each local storage space is determined, including:

[0020] Based on the total number of file data blocks, the first content difference, and the second content difference, determine the storable amount of file data blocks corresponding to the first storage space;

[0021] Based on the first content difference and the storable amount of file data blocks corresponding to the first storage space, determine the storable amount of file data blocks corresponding to the second storage space;

[0022] Based on the storable amount of file data blocks corresponding to the first storage space, the storable amount of file data blocks corresponding to the second storage space, and the total number of file data blocks, the storable amount of file data blocks corresponding to the third storage space is determined.

[0023] In one embodiment, each file data block is stored based on the storable amount of the file data block corresponding to each local storage space, including:

[0024] Retrieve the storage records corresponding to each local storage space;

[0025] Based on the storage records and the storable amount of file data blocks corresponding to each local storage space, determine the storage number corresponding to each local storage space;

[0026] Based on the storage number corresponding to each local storage space, each file data block is stored, and the storage record corresponding to each local storage space is updated.

[0027] In one embodiment, determining the storage number corresponding to each local storage space based on the storage records and the storable amount of file data blocks corresponding to each local storage space includes:

[0028] For each local storage space, based on the storage records, determine whether the local storage space has a historical storage number;

[0029] If so, select a reference storage number from the historical storage numbers whose number status is a reassigned number and / or the last number;

[0030] Based on the reference storage number and the storable amount of file data blocks corresponding to the local storage space, determine the storage number corresponding to the local storage space.

[0031] In one embodiment, the method further includes:

[0032] If not, then based on the storable amount of file data blocks corresponding to the local storage space, starting from the initial storage number of the local storage space, set the corresponding storage number for the local storage space.

[0033] Secondly, this application also provides a document storage device. The device includes:

[0034] The splitting module is used to split a file to be stored into at least two file data blocks based on the capacity of a unit data block;

[0035] The determination module is used to determine the storable amount of file data blocks corresponding to each local storage space based on the used capacity of at least two local storage spaces and the capacity of a unit data block.

[0036] The storage module is used to store each file data block based on the storable amount of file data blocks corresponding to each local storage space.

[0037] Thirdly, this application also provides a computer device. The computer device includes a storage device and a processor. The storage device stores a computer program, and the processor executes the computer program to implement the file storage method as described in any of the embodiments of the first aspect above.

[0038] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the file storage method as described in any of the embodiments of the first aspect above.

[0039] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the file storage method as described in any of the embodiments of the first aspect above.

[0040] According to the technical solution of this application, by splitting the file to be stored into at least two file data blocks, it is ensured that the split file can be stored locally, thus ensuring the smooth progress of subsequent processes. By using the used capacity of the two local storage spaces and the capacity of the unit data block, the storable amount of local storage space is determined, ensuring that at least two file data blocks can be reasonably allocated according to the storable amount. This ensures that after storing the file data blocks according to the storable amount, the difference in the used capacity of each local storage space is small, achieving a uniform distribution of file data blocks. Furthermore, the above file storage method avoids the problem of slow file reading efficiency when using large file storage methods, improving the access efficiency of local storage space; it also avoids the problem of a large number of local storage spaces when using small file storage methods, improving system performance and the access efficiency of local storage space. Attached Figure Description

[0041] Figure 1 An application environment diagram of a file storage method provided in this application embodiment;

[0042] Figure 2 A flowchart illustrating a file storage method provided in this application embodiment;

[0043] Figure 3 A flowchart illustrating the steps for determining the storable amount of local storage space, as provided in this application embodiment;

[0044] Figure 4 A flowchart illustrating the steps for storing data blocks of various files is provided in this embodiment of the application.

[0045] Figure 5 A flowchart illustrating another file storage method provided in this application embodiment;

[0046] Figure 6 A structural block diagram of a first type of file storage device provided in the embodiments of this application;

[0047] Figure 7 A structural block diagram of a second type of file storage device provided in the embodiments of this application;

[0048] Figure 8 A structural block diagram of a third type of file storage device provided in the embodiments of this application;

[0049] Figure 9 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0050] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0051] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application. In the description of this application, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in a suitable manner in any one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0052] With the rapid development of mobile internet, retrieving files from servers has become an important means of communication in people's daily work and life, such as retrieving email addresses from email servers. Storing files locally ensures that the required files can be quickly retrieved later. Currently, there are two main methods for file storage: large file storage and small file storage. Large file storage refers to storing all files together in one file; small file storage refers to storing each file in a separate file.

[0053] However, the disadvantages of using large file storage methods are as follows: large files are slow to access in later stages, and require a large amount of memory space to operate; furthermore, when the format of a large file is corrupted, all files will become inaccessible, requiring all files to be downloaded from the file server again, and files that have been deleted from the file server cannot be recovered, resulting in the loss of a large number of files, which may have a significant impact on work; furthermore, over time, many space fragments will be formed, requiring time-consuming space compression to release the fragments and reduce the file size.

[0054] The disadvantages of using the small file storage method are: the large size difference between a large number of files, the lack of standardization, and even the existence of a large number of small files. As the number of files increases, the number of files in the file system becomes too large, the file directory structure becomes too long, which affects system performance and causes local file access client software to slow down in the later stages.

[0055] The file storage method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, in one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows. Figure 1 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and data blocks. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The data blocks are used to store data for file storage retrieval. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a file storage method.

[0056] This application discloses a file storage method, apparatus, computer equipment, and storage medium. The computer equipment of the staff splits the file to be stored into at least two file data blocks, and determines the storable amount of each local storage space based on the used capacity of at least two local storage spaces and the capacity of the unit data block; and stores each file data block according to the storable amount of each local storage space.

[0057] Figure 2 A flowchart of a file storage method provided in an embodiment of this application is shown below. Figure 2 As shown, the method of storing this file may include the following steps:

[0058] Step 201: Based on the capacity of the unit data block, split the file to be stored into at least two file data blocks.

[0059] The capacity of a unit data block is used to represent the maximum volume corresponding to each file data block. For example, the capacity of a unit data block can be 1MB (or 512KB), which means that when the file to be stored is split into at least two file data blocks, the maximum capacity of the file data blocks in the at least two file data blocks is 1MB (or 512KB).

[0060] Furthermore, the capacity of a unit data block can be determined based on the size of the file to be stored, to ensure that when the file to be stored is split according to the capacity of the unit data block, the resulting data blocks of at least two files will have the same capacity. Specifically, to ensure that the resulting data blocks of at least two files have the same capacity, the capacity of the unit data block should be the smallest unit capacity of the file to be stored. For example, if the file to be stored is 1024MB, then the smallest unit capacity of the file to be stored is 1MB, therefore, the capacity of the unit data block is 1MB; if the file to be stored is 512KB, then the smallest unit capacity of the file to be stored is 1KB, therefore, the capacity of the unit data block is 1KB.

[0061] It should be noted that when a file to be stored needs to be split, in order to ensure that the at least two file data blocks obtained from the split do not exceed the capacity of the unit data block, the capacity of the file to be stored is planned in advance according to the capacity of the unit data block, the different file data blocks to which each part of the file to be stored belongs are determined, and the file to be stored is split according to the planning results, thereby splitting the file to be stored into at least two file data blocks.

[0062] For example, if the capacity of a unit data block is 1MB, when a file to be stored needs to be split, the capacity of the file to be stored is planned according to the capacity of the unit data block. The content of the file to be stored is divided into the same file data block for every 1MB of the content. The same content in the file to be stored cannot appear in two file data blocks at the same time. This determines the different file data blocks to which each part of the file to be stored belongs. Based on the planning results, the file to be stored is split, thereby splitting the file to be stored into at least two file data blocks.

[0063] Step 202: Based on the used capacity of at least two local storage spaces and the capacity of a unit data block, determine the storable amount of file data blocks corresponding to each local storage space.

[0064] The storable amount of file data blocks corresponding to the local storage space is used to represent the number of file data blocks that the local storage space can store for the file to be stored.

[0065] It should be noted that by determining the storable capacity of file data blocks corresponding to each local storage space, it can be ensured that the used capacity of each local storage space is basically the same after the file data blocks are stored, thus achieving the storage of the file to be stored. Therefore, when determining the storable capacity of file data blocks corresponding to each local storage space, the used capacity of the local storage space and the capacity of the unit data block should be considered to ensure that the used capacity of each local storage space is basically the same after the file data blocks are stored.

[0066] In one embodiment of this application, when it is necessary to determine the storable amount of file data blocks corresponding to each local storage space, the number of unit data blocks equivalent to the used capacity of the local storage space can be determined according to the capacity of the unit data block; and the storable amount of file data blocks corresponding to each local storage space can be determined according to the number of unit data blocks equivalent to the used capacity of the local storage space.

[0067] To further explain, when determining the storable amount of file data blocks corresponding to each local storage space based on the number of data blocks equivalent to the used capacity of the local storage space, the following can be included: A higher number of data blocks equivalent to the used capacity of the local storage space indicates a lower storable amount of file data blocks for that local storage space; conversely, a lower number of data blocks equivalent to the used capacity of the local storage space indicates a higher storable amount of file data blocks for that local storage space. Therefore, when determining the storable amount of file data blocks corresponding to each local storage space, at least two file data blocks are reasonably allocated based on the number of data blocks equivalent to the used capacity of the local storage space to ensure that the used capacity of each local storage space is approximately the same after storing the file data blocks.

[0068] Step 203: Store each file data block based on the storable amount of the file data block corresponding to each local storage space.

[0069] It should be noted that when storing file data blocks, it is necessary to determine the storage record corresponding to the local storage space, and then determine whether the file data blocks of historical files exist in the local storage space based on the storage number corresponding to the file data blocks of other files. If they exist, the storage number of the file to be stored is determined based on the storage number corresponding to the file data blocks of other files, and each file data block is stored according to the storage number. If they do not exist, the initial storage number of the local storage space is determined, and each file data block is stored according to the initial storage number.

[0070] As one implementation method, when storing file data blocks, if the storage record corresponding to the local storage space is determined, the file data blocks of historical files in the local storage space are determined according to the storage record, the numbers of the historical file data blocks with the number status at the end of the number are determined, the storage number of the file to be stored is determined according to the number of the file to be stored, and each file data block is stored according to the storage number.

[0071] Furthermore, when there are files in the historical file whose data blocks have a reassignment status, the storage number of the file to be stored can be determined based on the reassignment status and the end status, and each file data block can be stored according to the storage number.

[0072] As another implementation method, when storing file data blocks, if the storage record corresponding to the local storage space cannot be determined, the initial storage number of the local storage space is determined (usually number 1 is used as the initial storage number). The corresponding storage number is set for the local storage space according to the initial storage number, and then each file data block is stored according to the storage number.

[0073] In one embodiment of this application, the file to be stored can be an email downloaded from the email server. When the file to be stored is an email, the summary information of the email can be obtained according to the content of the email, and the summary information of the email can be displayed in the "Inbox" list of the local email client software.

[0074] The summary information of the email to be stored may include, but is not limited to: email subject, sender, recipient, CC recipient, email time, etc.

[0075] To further explain, when a user wants to query emails stored locally, they can determine the local storage space corresponding to each file data block of the email and the number of each file data block in the local storage space based on the summary information of the email to be queried; then, based on the local storage space corresponding to each file data block of the email and the number of each file data block in the local storage space, the file data blocks of the email are merged to obtain the complete email content, and the email content is displayed in the local email client software.

[0076] According to the file storage method of this application, by splitting the file to be stored into at least two file data blocks, it is ensured that the split file can be stored locally, thus ensuring the smooth progress of subsequent processes. By using the used capacity of the two local storage spaces and the capacity of the unit data block, the storable amount of local storage space is determined, ensuring that at least two file data blocks can be reasonably allocated according to the storable amount. This ensures that after storing the file data blocks according to the storable amount, the difference in the used capacity of each local storage space is small, achieving a uniform distribution of file data blocks. Furthermore, the above file storage method avoids the problem of slow file reading efficiency when using large file storage methods, improving the access efficiency of local storage space; it also avoids the problem of a large number of local storage spaces when using small file storage methods, improving system performance and improving the access efficiency of local storage space.

[0077] It should be noted that the storable file data blocks in each local storage space can be determined based on the amount of data blocks contained in each local storage space. Optionally, such as... Figure 3 As shown, Figure 3 A flowchart illustrating the steps for determining the storable amount of local storage space provided in this application embodiment includes the following steps:

[0078] Step 301: Determine the amount of data blocks contained in each local storage space based on the used capacity of at least two local storage spaces and the capacity of a unit data block.

[0079] The data block content represents the number of data blocks equivalent to the used capacity of each local storage space.

[0080] It should be noted that when it is necessary to determine the amount of data blocks contained in each local storage space, the used capacity of each local storage space and the capacity of a unit data block can be divided. The result is the amount of data blocks contained in each local storage space.

[0081] For example, if the used capacity of the local storage space is 1024MB and the capacity of a single data block is 1MB, then when it is necessary to determine the number of data blocks in the local storage space, the used capacity of the local storage space of 1024MB can be divided by the capacity of a single data block of 1MB. The result is 1024, so the local storage space contains 1024 data blocks.

[0082] To further explain, if the unit of measurement for the used capacity of local storage space is different from the unit of measurement for the capacity of a unit data block, then when determining the amount of data blocks contained in local storage space, the unit of measurement for the used capacity of local storage space should first be converted to ensure that the unit of measurement for the used capacity of local storage space is the same as the unit of measurement for the capacity of a unit data block. Then, a division operation should be performed on the used capacity of local storage space and the capacity of a unit data block to determine the amount of data blocks contained in each local storage space.

[0083] For example, if the used capacity of local storage space is 1MB and the capacity of a single data block is 1KB, since the units of measurement for the used capacity of local storage space and the unit of measurement for the capacity of a single data block are different, it is necessary to convert the units of measurement for the used capacity of local storage space. It is known that 1MB equals 1024KB, therefore, the used capacity of local storage space is 1024KB. Dividing the used capacity of local storage space 1024KB by the capacity of a single data block 1KB, the result is 1024. Therefore, the local storage space contains 1024 data blocks.

[0084] Step 302: Based on the amount of data blocks contained in each local storage space, determine the storable amount of file data blocks corresponding to each local storage space.

[0085] The differences in target storage capacity between different local storage spaces are all within a preset range; the target storage capacity of each local storage space is the sum of the data block content and the storable capacity of each local storage space.

[0086] Furthermore, the size of the preset range can be determined based on the actual situation and the staff's historical experience; no limit is placed on the size of the preset range here.

[0087] It should be noted that when it is necessary to determine the storable amount of file data blocks corresponding to each local storage space, the following can be included: sorting each local storage space based on the amount of data blocks contained in each local storage space; performing a difference calculation on the amount of data blocks contained in each pair of local storage spaces that are adjacent in the sorting position to obtain the difference in the amount of data blocks contained in each pair of local storage spaces; and determining the storable amount of file data blocks corresponding to each local storage space based on the difference in the amount of data blocks contained and the total number of file data blocks.

[0088] To further explain, the smaller the difference in the amount of content between two local storage spaces, the closer the used capacity of the two local storage spaces is, and the closer the storable amount of file data blocks in the two local storage spaces is; conversely, the larger the difference in the amount of content between two local storage spaces, the greater the difference in the used capacity of the two local storage spaces is, and the greater the difference in the storable amount of file data blocks in the two local storage spaces is.

[0089] In one embodiment of this application, when the number of local storage spaces is three, the three local storage spaces respectively include a first storage space, a second storage space and a third storage space, and the used capacity of the first storage space is greater than the used capacity of the second storage space; the used capacity of the second storage space is greater than the used capacity of the third storage space; the content difference includes a first content difference corresponding to the first storage space and the second storage space, and a second content difference corresponding to the second storage space and the third storage space.

[0090] Accordingly, determining the storable size of file data blocks corresponding to each local storage space may include the following:

[0091] When determining the storable amount of file data blocks corresponding to the first storage space, the storable amount of file data blocks corresponding to the first storage space can be determined based on the total number of file data blocks, the first content difference, and the second content difference.

[0092] Specifically, a difference operation is performed between the total number of file data blocks and the first content difference to obtain a first operation result. The first operation result is then compared with twice the second content difference to obtain a second operation result. Based on the second operation result, the storable amount of file data blocks corresponding to the first storage space is determined.

[0093] In summary, based on the description of the storable amount of the file data block corresponding to the first storage space, the calculation formula (1) for the storable amount of the file data block corresponding to the first storage space can be determined as follows:

[0094] T1=pin((Tm-2n) / 3)……(1)

[0095] Where T1 refers to the storable amount of file data blocks corresponding to the first storage space, T refers to the total number of file data blocks, m refers to the second content difference, n refers to the first content difference, and 3 refers to the amount of local storage space.

[0096] When determining the storable amount of file data blocks corresponding to the second storage space, the storable amount of file data blocks corresponding to the second storage space can be determined based on the first content difference and the storable amount of file data blocks corresponding to the first storage space.

[0097] Specifically, the first content difference is added to the storable amount of the file data block corresponding to the first storage space, and the result is the storable amount of the file data block corresponding to the second storage space.

[0098] In summary, based on the description of the storable amount of the file data block corresponding to the second storage space, the calculation formula (1) for the storable amount of the file data block corresponding to the second storage space can be determined as follows:

[0099] T2=n+T1……(2)

[0100] Where T1 refers to the storable amount of file data blocks corresponding to the first storage space, T2 refers to the storable amount of file data blocks corresponding to the second storage space, and n refers to the difference in the first amount of data.

[0101] Furthermore, substituting calculation formula (1) into calculation formula (2) yields calculation formula (3);

[0102] T2=n+pin((Tm-2n) / 3)……(3)

[0103] Where T2 refers to the storable amount of file data blocks corresponding to the second storage space, T refers to the total number of file data blocks, m refers to the second content difference, n refers to the first content difference, and 3 refers to the amount of local storage space.

[0104] When determining the storable amount of file data blocks corresponding to the third storage space, the storable amount of file data blocks corresponding to the first storage space, the storable amount of file data blocks corresponding to the second storage space, and the total number of file data blocks can be used to determine the storable amount of file data blocks corresponding to the third storage space.

[0105] Specifically, the total number of file data blocks is subtracted from the storable amount of file data blocks corresponding to the first storage space, and then the storable amount of file data blocks corresponding to the second storage space is subtracted from the result to determine the storable amount of file data blocks corresponding to the third storage space.

[0106] In summary, based on the description of the storable amount of the file data block corresponding to the third storage space, the calculation formula (4) for determining the storable amount of the file data block corresponding to the third storage space is as follows:

[0107] T3 = T - T1 - T2 ... (4)

[0108] Where T1 refers to the storable amount of file data blocks corresponding to the first storage space, T2 refers to the storable amount of file data blocks corresponding to the second storage space, T3 refers to the storable amount of file data blocks corresponding to the third storage space, and T refers to the total number of file data blocks.

[0109] Furthermore, by substituting calculation formulas (1) and (3) into calculation formula (4), we can obtain calculation formula (5);

[0110] T3=T-2pin((Tm-2n) / 3)-n…..(5)

[0111] Where T3 refers to the storable amount of file data blocks corresponding to the third storage space, T refers to the total number of file data blocks, m refers to the second content difference, n refers to the first content difference, and 3 refers to the amount of local storage space.

[0112] According to the file storage method of this application, by determining the data block content of each local storage space, it is ensured that the storable amount of file data blocks corresponding to each local storage space can be determined based on the data block content of each local storage space, thus providing a data basis for the subsequent storage of each file data block. Furthermore, by determining the content difference between any two local storage spaces, the accuracy of determining the storable amount of file data blocks corresponding to each local storage space is further improved, ensuring that the difference in the target storage amount of different local storage spaces is within a preset range. This enables the subsequent access efficiency of local storage spaces to be improved, avoiding the problems caused by using large file storage methods and small file storage methods.

[0113] It should be noted that each file data block can be stored according to the storage records corresponding to each local storage space. Optionally, such as... Figure 4 As shown, Figure 4 A flowchart illustrating the steps for storing file data blocks provided in this application embodiment includes the following steps:

[0114] Step 401: Obtain the storage records corresponding to each local storage space.

[0115] It should be noted that the storage record may record whether there are file data blocks of other files in the local storage space, and when there are file data blocks of other files in the local storage space, the storage record may record the historical storage number of the file data blocks of other files.

[0116] To further explain, the storage records can be stored in the corresponding local storage space. After the file data block is stored in the local storage space, the storage record in the local storage space can be updated according to the storage number of the file data block; or, after the file data block in the local storage space is deleted, the storage record in the local storage space can be updated according to the deletion.

[0117] Step 402: Based on the storage records and the storable amount of file data blocks corresponding to each local storage space, determine the storage number corresponding to each local storage space.

[0118] It should be noted that the existence of historical storage numbers in a local storage space can be determined based on storage records. The methods for determining the pending storage number differ depending on whether historical storage numbers exist. Specifically, determining the pending storage number for each local storage space may include the following: For each local storage space, based on storage records, determine whether a historical storage number exists for that local storage space; if so, select a reference storage number from the historical storage numbers whose status is a reallocated number and / or the last number; based on the reference storage number and the storable amount of the file data blocks corresponding to that local storage space, determine the pending storage number for that local storage space. If not, based on the storable amount of the file data blocks corresponding to that local storage space, starting from the initial storage number of that local storage space, set the corresponding pending storage number for that local storage space.

[0119] For example, if the local storage space has historical storage numbers, namely 001, 002, and 003, where the status of number 001 is "stored data block", the status of number 002 is "reassigned number", and the status of number 003 is "end number", then when it is necessary to determine the number to be stored corresponding to this local storage space, since the status of number 002 is "reassigned number", number 002 can be used again. Furthermore, since the status of number 003 is "end number", numbers 004 and beyond can be used. To further explain, if the storable amount of file data blocks corresponding to this local storage space is 3, then the numbers to be stored corresponding to this local storage space are 002, 004, and 005.

[0120] For example, if there is no historical storage number in the local storage space, and the initial storage number of the local storage space is determined to be 001, then the number 001 and subsequent numbers can be used; further, if the storable amount of the file data block corresponding to the local storage space is 3, then the storage numbers corresponding to the local storage space are 001, 002 and 003.

[0121] Step 403: Based on the storage number corresponding to each local storage space, store each file data block and update the storage record corresponding to each local storage space.

[0122] In one embodiment of this application, if the numbers to be stored corresponding to the local storage space are 002, 004 and 005, and the number status of number 02 is "reassigned number", then after storing each file data block according to the number to be stored, the number status of numbers 002, 004 and 005 is changed to "stored data block".

[0123] In one embodiment of this application, if the local storage space corresponds to the storage numbers 001, 002, and 003, and no file data blocks have been stored before for numbers 001, 002, and 003, then the number status of numbers 001, 002, and 003 is "empty". After storing each file data block according to the storage number, the number status of numbers 001, 002, and 003 is changed to "stored data block".

[0124] According to the file storage method of this application, by determining the storage record, it is possible to determine whether there is a historical storage number in the local storage space, thereby ensuring the accuracy of the determination of the storage number. This ensures that when it is necessary to query the file data block later, the file data block to be queried can be accurately obtained according to the storage number. The storage number ensures that the file data block can be stored smoothly.

[0125] In one embodiment of this application, such as Figure 5 As shown, Figure 5 A flowchart illustrating another file storage method provided in this application embodiment. Specifically, when resource borrowing approval is required for a target user, the method may include the following steps:

[0126] Step 501: Based on the capacity of the unit data block, split the file to be stored into at least two file data blocks.

[0127] Step 502: Determine the amount of data blocks contained in each local storage space based on the used capacity of at least two local storage spaces and the capacity of a unit data block.

[0128] The data block content represents the number of data blocks equivalent to the used capacity of each local storage space.

[0129] Step 503: Sort each local storage space based on the amount of data blocks contained in each local storage space.

[0130] Step 504: Perform a difference calculation on the content of data blocks in each pair of local storage spaces that are adjacent in the sorting position to obtain the content difference between each pair of local storage spaces.

[0131] Step 505: Based on the total number of file data blocks, the first content difference, and the second content difference, determine the storable amount of file data blocks corresponding to the first storage space.

[0132] Step 506: Based on the first content difference and the storable amount of the file data block corresponding to the first storage space, determine the storable amount of the file data block corresponding to the second storage space.

[0133] Step 507: Based on the storable amount of file data blocks corresponding to the first storage space, the storable amount of file data blocks corresponding to the second storage space, and the total number of file data blocks, determine the storable amount of file data blocks corresponding to the third storage space.

[0134] The differences in target storage capacity between different local storage spaces are all within a preset range; the target storage capacity of each local storage space is the sum of the data block content and the storable capacity of each local storage space.

[0135] Step 508: Obtain the storage records corresponding to each local storage space.

[0136] Step 509: For each local storage space, determine whether there is a historical storage number based on the storage record; if yes, proceed to step 510; otherwise, proceed to step 511.

[0137] Step 510: Select a reference storage number from the historical storage numbers whose status is a reassigned number and / or the last number; determine the number to be stored corresponding to the local storage space based on the reference storage number and the storable amount of the file data block corresponding to the local storage space.

[0138] Step 511: Based on the storable amount of file data blocks corresponding to the local storage space, starting from the initial storage number of the local storage space, set the corresponding storage number for the local storage space.

[0139] Step 512: Based on the storage number corresponding to each local storage space, store each file data block and update the storage record corresponding to each local storage space.

[0140] According to the file storage method of this application, by splitting the file to be stored into at least two file data blocks, it is ensured that the split file can be stored locally, thus ensuring the smooth progress of subsequent processes. By using the used capacity of the two local storage spaces and the capacity of the unit data block, the storable amount of local storage space is determined, ensuring that at least two file data blocks can be reasonably allocated according to the storable amount. This ensures that after storing the file data blocks according to the storable amount, the difference in the used capacity of each local storage space is small, achieving a uniform distribution of file data blocks. Furthermore, the above file storage method avoids the problem of slow file reading efficiency when using large file storage methods, improving the access efficiency of local storage space; it also avoids the problem of a large number of local storage spaces when using small file storage methods, improving system performance and improving the access efficiency of local storage space.

[0141] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0142] Based on the same inventive concept, this application also provides a file storage device for implementing the file storage method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more file storage device embodiments provided below can be found in the limitations of the file storage method described above, and will not be repeated here.

[0143] In one embodiment, such as Figure 6 As shown, Figure 6 This is a structural block diagram of a first type of file storage device provided in an embodiment of this application. The file storage device includes: a splitting module 10, a determining module 20, and a storage module 30, wherein:

[0144] Splitting module 10 is used to split the file to be stored into at least two file data blocks based on the capacity of a unit data block.

[0145] The determination module 20 is used to determine the storable amount of file data blocks corresponding to each local storage space based on the used capacity of at least two local storage spaces and the capacity of a unit data block.

[0146] Storage module 30 is used to store each file data block based on the storable amount of file data blocks corresponding to each local storage space.

[0147] According to the file storage device of this application, by splitting the file to be stored into at least two file data blocks, it ensures that the split file can be stored locally, thus ensuring the smooth progress of subsequent processes. By using the used capacity of the two local storage spaces and the capacity of the unit data block, the storable amount of local storage space is determined, ensuring that at least two file data blocks can be reasonably allocated according to the storable amount. This ensures that after storing the file data blocks according to the storable amount, the difference in the used capacity of each local storage space is small, achieving a uniform distribution of file data blocks. Furthermore, the above file storage method avoids the problem of slow file reading efficiency when using large file storage methods, improving the access efficiency of local storage space; it also avoids the problem of a large number of local storage spaces when using small file storage methods, improving system performance and the access efficiency of local storage space.

[0148] In one embodiment, such as Figure 7 As shown, Figure 7 This is a structural block diagram of a second type of file storage device provided in an embodiment of this application. A file storage device is provided, in which a determining module 20 includes: a first determining unit 21 and a second determining unit 22, wherein:

[0149] The first determining unit 21 is used to determine the data block content of each local storage space based on the used capacity of at least two local storage spaces and the capacity of a unit data block; wherein the data block content represents the number of unit data blocks equivalent to the used capacity of each local storage space.

[0150] The second determining unit 22 is used to determine the storable amount of file data blocks corresponding to each local storage space based on the amount of data blocks contained in each local storage space.

[0151] The differences in target storage capacity between different local storage spaces are all within a preset range; the target storage capacity of each local storage space is the sum of the data block content and the storable capacity of each local storage space.

[0152] It should be noted that, based on the amount of data blocks contained in each local storage space, the local storage spaces are sorted; the difference in the amount of data blocks contained in each pair of adjacent local storage spaces is calculated to obtain the difference in the amount of data blocks contained in each pair of local storage spaces; based on the difference in the amount of data blocks contained and the total number of file data blocks, the storable amount of file data blocks corresponding to each local storage space is determined.

[0153] To further explain, the storable amount of file data blocks corresponding to the first storage space is determined based on the total number of file data blocks, the first content difference, and the second content difference; the storable amount of file data blocks corresponding to the second storage space is determined based on the first content difference and the storable amount of file data blocks corresponding to the first storage space; and the storable amount of file data blocks corresponding to the third storage space is determined based on the storable amount of file data blocks corresponding to the first storage space, the storable amount of file data blocks corresponding to the second storage space, and the total number of file data blocks.

[0154] In one embodiment, such as Figure 8 As shown, Figure 8 This is a structural block diagram of a third type of file storage device provided in an embodiment of this application. The file storage device includes a storage module 30 comprising: an acquisition unit 31, a third determination unit 32, and a storage unit 33, wherein:

[0155] The acquisition unit 31 is used to acquire the storage records corresponding to each local storage space.

[0156] The third determining unit 32 is used to determine the storage number corresponding to each local storage space based on the storage record and the storable amount of file data blocks corresponding to each local storage space.

[0157] It should be noted that, for each local storage space, based on the storage record, it is determined whether the local storage space has a historical storage number; if so, a reference storage number with a number status of reallocation and / or end number is selected from the historical storage numbers; based on the reference storage number and the storable amount of the file data block corresponding to the local storage space, the storage number corresponding to the local storage space is determined.

[0158] If not, then based on the storable amount of file data blocks corresponding to the local storage space, starting from the initial storage number of the local storage space, set the corresponding storage number for the local storage space.

[0159] Storage unit 33 is used to store each file data block based on the storage number corresponding to each local storage space, and update the storage record corresponding to each local storage space.

[0160] Each module in the aforementioned file storage device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can invoke and execute the operations corresponding to each module.

[0161] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 9 As shown, the computer device includes a processor, storage, a communication interface, a display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The storage includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a file storage method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad located on the computer device's casing, or an external keyboard, touchpad, or mouse.

[0162] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0163] In one embodiment, a computer device is provided, including a storage device and a processor, wherein the storage device stores a computer program, and the processor executes the computer program to perform the following steps:

[0164] Based on the capacity of a single data block, the file to be stored is split into at least two file data blocks;

[0165] Based on the used capacity of at least two local storage spaces and the capacity of a unit data block, determine the storable amount of file data blocks corresponding to each local storage space;

[0166] Based on the storable amount of file data blocks corresponding to each local storage space, each file data block is stored.

[0167] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0168] Based on the used capacity of at least two local storage spaces and the capacity of a unit data block, determine the data block content of each local storage space; wherein, the data block content represents the number of unit data blocks equivalent to the used capacity of each local storage space.

[0169] Based on the amount of data blocks contained in each local storage space, determine the storable amount of file data blocks corresponding to each local storage space;

[0170] The differences in target storage capacity between different local storage spaces are all within a preset range; the target storage capacity of each local storage space is the sum of the data block content and the storable capacity of each local storage space.

[0171] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0172] Based on the amount of data blocks contained in each local storage space, sort the local storage spaces.

[0173] The difference in the content of data blocks is calculated for each pair of local storage spaces that are adjacent in sorting position, and the content difference between each pair of local storage spaces is obtained.

[0174] Based on the difference in content and the total number of file data blocks, the storable amount of file data blocks corresponding to each local storage space is determined.

[0175] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0176] Based on the total number of file data blocks, the first content difference, and the second content difference, determine the storable amount of file data blocks corresponding to the first storage space;

[0177] Based on the first content difference and the storable amount of file data blocks corresponding to the first storage space, determine the storable amount of file data blocks corresponding to the second storage space;

[0178] Based on the storable amount of file data blocks corresponding to the first storage space, the storable amount of file data blocks corresponding to the second storage space, and the total number of file data blocks, the storable amount of file data blocks corresponding to the third storage space is determined.

[0179] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0180] Retrieve the storage records corresponding to each local storage space;

[0181] Based on the storage records and the storable amount of file data blocks corresponding to each local storage space, determine the storage number corresponding to each local storage space;

[0182] Based on the storage number corresponding to each local storage space, each file data block is stored, and the storage record corresponding to each local storage space is updated.

[0183] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0184] For each local storage space, based on the storage records, determine whether the local storage space has a historical storage number;

[0185] If so, select a reference storage number from the historical storage numbers whose number status is a reassigned number and / or the last number;

[0186] Based on the reference storage number and the storable amount of file data blocks corresponding to the local storage space, determine the storage number corresponding to the local storage space.

[0187] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0188] If not, then based on the storable amount of file data blocks corresponding to the local storage space, starting from the initial storage number of the local storage space, set the corresponding storage number for the local storage space.

[0189] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0190] Based on the capacity of a single data block, the file to be stored is split into at least two file data blocks;

[0191] Based on the used capacity of at least two local storage spaces and the capacity of a unit data block, determine the storable amount of file data blocks corresponding to each local storage space;

[0192] Based on the storable amount of file data blocks corresponding to each local storage space, each file data block is stored.

[0193] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0194] Based on the used capacity of at least two local storage spaces and the capacity of a unit data block, determine the data block content of each local storage space; wherein, the data block content represents the number of unit data blocks equivalent to the used capacity of each local storage space.

[0195] Based on the amount of data blocks contained in each local storage space, determine the storable amount of file data blocks corresponding to each local storage space;

[0196] The differences in target storage capacity between different local storage spaces are all within a preset range; the target storage capacity of each local storage space is the sum of the data block content and the storable capacity of each local storage space.

[0197] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0198] Based on the amount of data blocks contained in each local storage space, sort the local storage spaces.

[0199] The difference in the content of data blocks is calculated for each pair of local storage spaces that are adjacent in sorting position, and the content difference between each pair of local storage spaces is obtained.

[0200] Based on the difference in content and the total number of file data blocks, the storable amount of file data blocks corresponding to each local storage space is determined.

[0201] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0202] Based on the total number of file data blocks, the first content difference, and the second content difference, determine the storable amount of file data blocks corresponding to the first storage space;

[0203] Based on the first content difference and the storable amount of file data blocks corresponding to the first storage space, determine the storable amount of file data blocks corresponding to the second storage space;

[0204] Based on the storable amount of file data blocks corresponding to the first storage space, the storable amount of file data blocks corresponding to the second storage space, and the total number of file data blocks, the storable amount of file data blocks corresponding to the third storage space is determined.

[0205] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0206] Retrieve the storage records corresponding to each local storage space;

[0207] Based on the storage records and the storable amount of file data blocks corresponding to each local storage space, determine the storage number corresponding to each local storage space;

[0208] Based on the storage number corresponding to each local storage space, each file data block is stored, and the storage record corresponding to each local storage space is updated.

[0209] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0210] For each local storage space, based on the storage records, determine whether the local storage space has a historical storage number;

[0211] If so, select a reference storage number from the historical storage numbers whose number status is a reassigned number and / or the last number;

[0212] Based on the reference storage number and the storable amount of file data blocks corresponding to the local storage space, determine the storage number corresponding to the local storage space.

[0213] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0214] If not, then based on the storable amount of file data blocks corresponding to the local storage space, starting from the initial storage number of the local storage space, set the corresponding storage number for the local storage space.

[0215] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0216] Based on the capacity of a single data block, the file to be stored is split into at least two file data blocks;

[0217] Based on the used capacity of at least two local storage spaces and the capacity of a unit data block, determine the storable amount of file data blocks corresponding to each local storage space;

[0218] Based on the storable amount of file data blocks corresponding to each local storage space, each file data block is stored.

[0219] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0220] Based on the used capacity of at least two local storage spaces and the capacity of a unit data block, determine the data block content of each local storage space; wherein, the data block content represents the number of unit data blocks equivalent to the used capacity of each local storage space.

[0221] Based on the amount of data blocks contained in each local storage space, determine the storable amount of file data blocks corresponding to each local storage space;

[0222] The differences in target storage capacity between different local storage spaces are all within a preset range; the target storage capacity of each local storage space is the sum of the data block content and the storable capacity of each local storage space.

[0223] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0224] Based on the amount of data blocks contained in each local storage space, sort the local storage spaces.

[0225] The difference in the content of data blocks is calculated for each pair of local storage spaces that are adjacent in sorting position, and the content difference between each pair of local storage spaces is obtained.

[0226] Based on the difference in content and the total number of file data blocks, the storable amount of file data blocks corresponding to each local storage space is determined.

[0227] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0228] Based on the total number of file data blocks, the first content difference, and the second content difference, determine the storable amount of file data blocks corresponding to the first storage space;

[0229] Based on the first content difference and the storable amount of file data blocks corresponding to the first storage space, determine the storable amount of file data blocks corresponding to the second storage space;

[0230] Based on the storable amount of file data blocks corresponding to the first storage space, the storable amount of file data blocks corresponding to the second storage space, and the total number of file data blocks, the storable amount of file data blocks corresponding to the third storage space is determined.

[0231] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0232] Retrieve the storage records corresponding to each local storage space;

[0233] Based on the storage records and the storable amount of file data blocks corresponding to each local storage space, determine the storage number corresponding to each local storage space;

[0234] Based on the storage number corresponding to each local storage space, each file data block is stored, and the storage record corresponding to each local storage space is updated.

[0235] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0236] For each local storage space, based on the storage records, determine whether the local storage space has a historical storage number;

[0237] If so, select a reference storage number from the historical storage numbers whose number status is a reassigned number and / or the last number;

[0238] Based on the reference storage number and the storable amount of file data blocks corresponding to the local storage space, determine the storage number corresponding to the local storage space.

[0239] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0240] If not, then based on the storable amount of file data blocks corresponding to the local storage space, starting from the initial storage number of the local storage space, set the corresponding storage number for the local storage space.

[0241] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0242] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to storage devices, data blocks, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile storage devices. Non-volatile storage devices can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile storage, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene storage, etc. Volatile storage devices can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The data blocks involved in the embodiments provided in this application may include at least one of relational data blocks and non-relational data blocks. Non-relational data blocks may include, but are not limited to, blockchain-based distributed data blocks. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0243] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0244] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A file storage method, characterized in that, The method includes: Based on the capacity of a unit data block, the file to be stored is split into at least two file data blocks. To ensure that the capacity of the at least two file data blocks obtained from the split is the same, the capacity of the unit data block should be the minimum unit capacity of the file to be stored. Based on the used capacity of at least two local storage spaces and the capacity of the unit data block, the data block content of each local storage space is determined; wherein, the data block content represents the number of unit data blocks equivalent to the used capacity of each local storage space. Based on the amount of data blocks contained in each local storage space, the storable amount of file data blocks corresponding to each local storage space is determined respectively; The differences in the target storage capacity of different local storage spaces are all within a preset range; the target storage capacity of each local storage space is the sum of the data block content and the storable capacity of each local storage space. Based on the storable amount of the file data blocks corresponding to each local storage space, each file data block is stored.

2. The method according to claim 1, characterized in that, The determination of the storable amount of file data blocks corresponding to each local storage space based on the data block content of each local storage space includes: Based on the amount of data blocks contained in each local storage space, the local storage spaces are sorted. The difference in the amount of data blocks in each pair of local storage spaces with adjacent sorting positions is calculated to obtain the difference in the amount of data blocks in each pair of local storage spaces. Based on the difference in content and the total number of file data blocks, the storable amount of the file data blocks corresponding to each local storage space is determined.

3. The method according to claim 2, characterized in that, Each local storage space includes a first storage space, a second storage space, and a third storage space; and the used capacity of the first storage space is greater than the used capacity of the second storage space. The used capacity of the second storage space is greater than the used capacity of the third storage space; The content difference includes a first content difference between the first storage space and the second storage space, and a second content difference between the second storage space and the third storage space; Accordingly, determining the storable amount of the file data blocks corresponding to each local storage space based on the content difference and the total number of file data blocks includes: Based on the total number of file data blocks, the first content difference, and the second content difference, the storable amount of the file data blocks corresponding to the first storage space is determined. Based on the first content difference and the storable amount of the file data block corresponding to the first storage space, determine the storable amount of the file data block corresponding to the second storage space; Based on the storable amount of the file data blocks corresponding to the first storage space, the storable amount of the file data blocks corresponding to the second storage space, and the total number of file data blocks, the storable amount of the file data blocks corresponding to the third storage space is determined.

4. The method according to claim 1, characterized in that, The storage of each file data block based on the storable amount of the file data block corresponding to each local storage space includes: Obtain the storage records corresponding to each local storage space; Based on the storage record and the storable amount of the file data block corresponding to each local storage space, determine the storage number corresponding to each local storage space; Based on the storage number corresponding to each local storage space, each file data block is stored, and the storage record corresponding to each local storage space is updated.

5. The method according to claim 4, characterized in that, The step of determining the storage number corresponding to each local storage space based on the storage record and the storable amount of the file data block corresponding to each local storage space includes: For each local storage space, based on the storage record, determine whether the local storage space has a historical storage number; If so, then select the reference storage number whose number status is a reassigned number and / or the reference storage number at the end of the historical storage number; Based on the reference storage number and the storable amount of the file data block corresponding to the local storage space, the storage number corresponding to the local storage space is determined.

6. The method according to claim 5, characterized in that, The method further includes: If not, then based on the storable amount of the file data block corresponding to the local storage space, starting from the initial storage number of the local storage space, set the corresponding storage number for the local storage space.

7. A file storage device, characterized in that, The device includes: The splitting module is used to split the file to be stored into at least two file data blocks based on the capacity of a unit data block. To ensure that the capacity of the at least two file data blocks obtained by splitting is the same, the capacity of the unit data block should be the minimum unit capacity of the file to be stored. A determining module is configured to determine the data block content of each local storage space based on the used capacity of at least two local storage spaces and the capacity of the unit data block; wherein the data block content represents the number of unit data blocks equivalent to the used capacity of each local storage space; based on the data block content of each local storage space, the storable amount of file data blocks corresponding to each local storage space is determined respectively; wherein the difference in the target storage amount of different local storage spaces is within a preset range; the target storage amount of each local storage space is the sum of the data block content and the storable amount of each local storage space; The storage module is used to store each file data block based on the storable amount of the file data block corresponding to each local storage space.

8. A computer device comprising a storage unit and a processor, wherein the storage unit stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method for storing document in plurality of storage units and storage allocation method

    CN102622185A

  • File storage method and device based on HDFS (Hadoop Distributed File System) and distributed file system

    CN103473365A