Data processing method and device for storage device
By detecting insufficient storage space in the storage device, determining the activity value of the file based on its reading time and selecting the file to be cleared for deletion, it solves the problem in the existing technology that may cause valuable files to be accidentally deleted, and achieves a more accurate file value judgment and higher storage space utilization.
Patent Information
- Application Number
- CN202011523975.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-21
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2040-12-21
AI Technical Summary
When the storage space of the storage device is insufficient, the improper way of deleting files in the prior art may lead to the incorrect deletion of valuable files.
Through sufficient storage space for the storage device, determine its active value according to the read time of each file, and select the file to be removed from the storage device to delete it from the active value.
This method comprehensively considers the frequency and time of file use, and can more accurately judge the value of files, thereby avoiding deletion of valuable files and improving storage space utilization.
Smart Images

Figure CN114647619B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a data processing method and device for a storage device, a computer storage medium, and an intelligent interactive tablet. Background Art
[0002] With the development of network technology, users have more and more demands for browsing files on the Internet. In the file preview service, the files uploaded by users need to be converted first, and the relevant converted files are stored locally. In the case of public network, the converted files can be stored in the cloud server, but in the privatization scenario, disks or external hard disks are often used to store files. However, the space available for programs on disks or external hard disks is often limited. File cleaning is needed to improve the utilization of disk space, so that more meaningful files with the highest probability of use can be stored in the limited space.
[0003] The current methods for file cleaning include: 1) Deleting the "oldest" files, that is, the files with the earliest creation time. This is the most commonly used method. When the cleaning threshold is reached, the oldest files are directly deleted. However, old files do not mean useless. This method does not take into account the actual value of the files and is likely to cause valuable files to be deleted. 2) Deleting the files that have not been used for the longest time, but there may be Figure 1 The situation shown, Figure 1 The order of files in the above table is from the oldest to the newest, i.e., file A is stored the longest and file B is stored the most recently. Since file A is the oldest and its usage time is before file B, file A is the longest unused file and is cleaned. This method does not take into account the high number of times file A is used. Files that are used many times are often more valuable than files that are used less often. Therefore, method 2) will also lead to the accidental deletion of valuable files.
[0004] With respect to the problem in the prior art that an improper way of deleting files when the storage space of the storage device is insufficient may result in the deletion of valuable files, no effective solution has been proposed yet. Summary of the invention
[0005] Embodiments of the present invention provide a data processing method and apparatus for a storage device, a computer storage medium, and an intelligent interactive tablet, so as to at least solve the technical problem that when the storage space of a storage device is insufficient, an improper method of deleting files may result in the deletion of valuable files.
[0006] According to one aspect of an embodiment of the present invention, a data processing method for a storage device is provided, comprising: detecting whether the storage space of the storage device is sufficient; when it is determined that the storage space of the storage device is insufficient, determining the activity value of each file according to the file read time of each file in the storage device; selecting at least one file to be cleared from the files stored in the storage device according to the activity value of each file; and clearing the files to be cleared.
[0007] According to another aspect of an embodiment of the present invention, a data processing device of a storage device is also provided, including: a detection module, used to detect whether the storage space of the storage device is sufficient; an activity value acquisition module, used to determine the activity value of each file in the storage device according to the file read time of each file in the storage device when it is determined that the storage space of the storage device is insufficient; a selection module, used to select at least one file to be cleared from the files stored in the storage device according to the activity value of each file; and a clearing module, used to clear the files to be cleared.
[0008] According to another aspect of an embodiment of the present invention, a computer storage medium is provided. The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the above method steps.
[0009] According to another aspect of an embodiment of the present invention, there is also provided an intelligent interactive tablet, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above method steps.
[0010] In an embodiment of the present invention, it is detected whether the storage space of the storage device is sufficient; when it is determined that the storage space of the storage device is insufficient, the activity value of each file is determined according to the file read time of each file in the storage device; at least one file to be deleted is selected from the files stored in the storage device according to the activity value of each file; and the files to be deleted are deleted. The above scheme uses the file read time to determine the activity value of the file, and sorts the files to be deleted by the activity value. It comprehensively considers factors such as the frequency of file use and the time of use, and can more accurately judge the value of the file, which solves the problem in the prior art that the improper way of deleting files when the storage space of the storage device is insufficient may cause valuable files to be deleted. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0012] Figure 1 is a schematic diagram of a file cleaning method according to the prior art;
[0013] Figure 2is a flow chart of a data processing method of a storage device according to an embodiment of the present invention;
[0014] Figure 3 is a schematic diagram of optionally establishing a corresponding file record table when creating a file according to an embodiment of the present invention;
[0015] Figure 4 A schematic diagram of creating a file record table when an optional file is used according to an embodiment of the present invention;
[0016] Figure 5 A schematic diagram of an optional method for storing data of a device according to an embodiment of the present invention;
[0017] Figure 6 is a flow chart of an optional data processing method of a storage device according to an embodiment of the present invention;
[0018] Figure 7 is a flow chart of an optional data processing method of a storage device according to an embodiment of the present invention;
[0019] Figure 8 A flow chart of a data processing apparatus of a storage device according to an embodiment of the present invention;
[0020] Fig. 9 It is a structural schematic diagram of a smart interactive tablet provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings 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 should fall within the scope of protection of the present invention.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] Example 1
[0024] According to an embodiment of the present invention, an embodiment of a data processing method for a storage device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0025] Figure 2 is a data processing method of a storage device according to an embodiment of the present invention, such as Figure 2 As shown, the method comprises the following steps:
[0026] Step S201, detecting whether the storage space of the storage device is sufficient.
[0027] Specifically, the above-mentioned storage device can be a disk or hard disk of a computer or smart device. Detecting whether the storage space of the storage device is sufficient can be used as a condition to trigger file cleaning. Whether the storage space of the storage device is sufficient can be determined by setting a storage space threshold based on the maximum allowable usable space of the storage space. When the size of the current stored file exceeds the storage space threshold, it is determined that the storage space of the storage device is insufficient. The storage space threshold can be determined by leaving 15%-20% of the maximum allowable usable space of the storage space as a buffer, that is, the storage space threshold can be selected as 80%-85% of the maximum allowable usable space of the storage space. For example, the storage space of the storage device can be 100MB, and the storage space threshold is set to 85MB. When the file size in the storage device reaches 85MB, it is determined that the storage space is insufficient, and the file cleaning program can be triggered.
[0028] It should be noted that the conditions for triggering the detection of whether the storage space is sufficient include setting the detection time interval through a timer after setting the storage space threshold, so that the storage device automatically detects whether the storage space reaches the storage space threshold at regular intervals, or triggers the detection of whether the storage space of the storage device reaches the storage space threshold when a new file is written to the storage space.
[0029] Step S202: When it is determined that the storage space of the storage device is insufficient, the activity value of each file in the storage device is determined according to the file read time of each file.
[0030] When the storage space of the storage device reaches the set storage space threshold, the activity value of each file is determined according to the file reading time of each file. The activity value of the file is used to indicate the activity level of the file in the storage space, and the activity level is related to the time and number of times the file is read. In an optional embodiment, the more times the file is read and the closer the time when the file is read is to the current time, the higher the activity value corresponding to the file.
[0031] Specifically, the file read time can be stored in the corresponding file record table. When the storage space of the storage device is insufficient, the activity value of each file can be determined by reading the file read time in the file record table. The file read time represents the time point of each file read, so when the same file is read multiple times, the file read time may include multiple time points.
[0032] The file record table is used to record file information when the file is created and when it is used, for example Figure 3 The figure shows a schematic diagram of establishing a corresponding file record table when creating a file. When file A is created (i.e., the user saves the file on a storage device), file parameters such as file size, file name, file creation time, and file identifier are recorded, and the above file parameters are stored in the file record table. Figure 4 A schematic diagram of creating a file record table when a file is used, such as Figure 4 Each time a file is used, the time of each use (i.e., the file read time) and the number of uses (if the file has been used before, add 1 to the original number of uses) are recorded, and the above file parameters are stored in the file record table. Optionally, all file information when the file is created and when it is used is stored in the same file record table, so that all file information can be read when determining the activity value of each file.
[0033] Step S203: selecting at least one file to be deleted from the files stored in the storage device according to the activity value of each file.
[0034] Since the activity value of each file is determined by the file reading time, the activity value of each file is at least affected by the reading time and the number of times the file is read. The combination of these two parameters comprehensively considers whether the file has been used recently and the frequency of use, which can more accurately judge the value of the file.
[0035] Optionally, the files can be sorted according to the activity value, and the files with the lowest order can be selected as the files to be cleared. For example, files with low activity values can be understood as files that have not been used recently or are used less frequently, so the files are of low value and can be deleted. You can also set an activity value range as a basis for selecting files to be cleared. For example, the activity values of 5 files on a storage device are 10, 11, 12, 13, and 14, respectively. Files with activity values ranging from 0 to 11 can be determined as files to be cleared.
[0036] In addition, the number of files to be cleared is determined by the file size and the storage space that needs to be obtained. The file size is the size of the storage space occupied by the file on the storage device. According to the storage space that needs to be obtained, after obtaining the activity value ranking of the files, the number of corresponding files with lower activity value ranking is determined according to the storage space that needs to be obtained. For example, there are 5 files in the storage device, and after sorting by activity value, they are (the corresponding file sizes are in brackets): file A (3MB), file B (3MB), file C (2MB), file D (3MB), file E (3MB) If 6MB of storage space needs to be obtained through cleaning, file D and file E are determined as files to be cleared. If 8MB of space needs to be obtained through cleaning, file C, file D and file E are determined as files to be cleared.
[0037] It should be noted that the storage space required to be obtained is set according to the maximum allowable usage space of the storage space and the needs of the user, and is not limited here. The specific strategy for determining the number of files to be cleared according to the file size can be flexibly set according to the needs of the user. For example, there are 5 files in the storage device, which are sorted by activity value in order: file A (3MB), file B (3MB), file C (2MB), file D (3MB), file E (3MB). If 5MB of storage space needs to be obtained through cleaning, and the sum of the sizes of file D and file E is 6MB, it can be preset that the sum of the sizes of the minimum files to be cleared that meet the storage space required can be greater than the storage space required, so that file D and file E are both files to be cleared. It can also be preset that the size of the files to be cleared does not exceed the size of the storage space required. In this case, only file E is a file to be cleared.
[0038] Step S204, clear the files to be cleared.
[0039] According to the above steps, the activity value of the file is determined by using the file reading time, and the files to be cleared are determined by sorting based on the activity value. The frequency of file use, the time of use and other factors are comprehensively considered, so the value of the file can be judged more accurately, and the problem in the prior art that the improper way of deleting files when the storage space of the storage device is insufficient may cause valuable files to be deleted.
[0040] As an optional embodiment, detecting whether the storage space of the storage device is sufficient includes: receiving a write instruction to the storage device; obtaining the file size of the file to be written; if the sum of the storage space occupied by the storage device and the file size of the file to be written is greater than or equal to a preset value, determining that the storage space of the storage device is insufficient.
[0041] The above-mentioned write instruction to the storage device can be understood as triggering the detection of whether the storage space of the storage device reaches the storage space threshold when a new file is written to the storage space. The above-mentioned preset value can be the storage space threshold, that is, the condition for judging whether the storage space of the storage device is sufficient. The following preset values can all be applicable to this interpretation. For example, the maximum allowable usable space of the storage space is 100MB, and the preset value is 85MB. If the storage space occupied by the storage device is 80MB, and the size of the new file written to the storage space is 6MB at this time, then the sum of the storage space occupied by the storage device and the file size of the file to be written is 86MB, which is greater than the above-mentioned preset value. It is determined that the storage space of the storage device is insufficient, and the files to be cleared can be cleared according to the above-mentioned steps S202-S204.
[0042] As an optional embodiment, when it is determined that the storage space of the storage device is insufficient, the activity value of each file in the storage device is determined according to the file reading time of each file in the storage device, including: determining the time difference for reading the file according to the current time and the file reading time, wherein the corresponding file reading time is recorded each time the file is read; determining the ratio of the time difference to a preset period as a time difference score; determining the difference between a preset basic score and the time difference score as the activity value corresponding to this file reading; and obtaining the sum of the activity values corresponding to each file reading to obtain the activity value of the file.
[0043] As an optional embodiment, the calculation formula of the file activity value is:
[0044] V=∑M max -R time ;
[0045] Among them, V is the active value of the file, M max It is the preset basic score, which can be flexibly set by the user. max Optional: 12; R time is the time difference of reading the file, R time =(T now -T record ) / S,T now is the current time, T record is the file reading time, S is the preset period, the preset period can be set freely by the user, S can be selected as 30 (unit: day), and can be set directly in the software configuration file.
[0046] It should be noted that the smaller the time difference is, the closer the file reading time is to the current time, that is, the file has been used recently.
[0047] For example, a file in a storage device has three usage records, which are 12 days ago, 36 days ago, and 90 days ago. The current time and file reading time can be obtained to determine that the time differences of reading the file are 12, 36, and 90 days respectively. The preset period S can be selected as 30, and the preset basic division M max The optional value is 12, then the active value calculation method of the file is:
[0048] Active value V = (12-12 / 30) + (12-36 / 30) + (12-90 / 30) = 11.6 + 10.8 + 9 = 31.4
[0049] According to the above method, the activity value of the file can be obtained as 31.4.
[0050] As an optional embodiment, selecting at least one file to be deleted from the files stored in the storage device according to the activity value of each file includes: determining a file with the lowest activity value as the file to be deleted.
[0051] As an optional embodiment, after calculating the activity values of all files in the storage device, a file with the lowest activity value is determined as the file to be cleared. Figure 5 The figure shows an optional data processing method embodiment of a storage device. The storage device includes file A and file B. When file cleaning is triggered, the activity values of file A and file B are calculated according to the above steps. Specifically, the number of times file A is used is obtained as 10 times through the file record table. According to the time interval between the current time and the file reading time of each of the 10 times, the time difference R of the 10 file readings is obtained. time They are: 365, 340, 200, 159, 158, 155, 140, 138, 136, 134 respectively; the corresponding number of times file B is used is 5 times, and the time difference R time They are: 4, 3, 2, 1, 1 respectively.
[0052] The activity value V of file A A is calculated as:
[0053] V A =(12-365 / 30)+(12-340 / 30)+(12-200 / 30)+(12-159 / 30)+(12-158 / 30)+(12-155 / 30)+(12-140 / 30)+(12-138 / 30)+(12-136 / 30)+(12-134 / 30)≈55.9
[0054] The activity value V of file B B for:
[0055] V B=(12-4 / 30)+(12-3 / 30)+(12-2 / 30)+(12-1 / 30)+(12-1 / 30)≈59.67
[0056] The calculated V A and V B By comparing the values, we can get V B Greater than V A , then determine V A Files to be cleaned up.
[0057] According to the above activity value algorithm, we can get that file A has been used more times in the past, and file B is used less frequently than file A, but it is a recently used file, so the activity value of file B may be higher than that of file A. However, the high total number of times file A is used does not mean that it is always active, so its activity value is relatively low. If two files are used the same number of times, the recently used file has a higher activity value than the file used a long time ago, and the probability of being used in the future is also greater.
[0058] Through the above-mentioned active value algorithm, the value of each file in the storage device can be obtained more reasonably, and the probability of deleting valuable files can be reduced.
[0059] As an optional embodiment, after clearing the files to be cleared, the method further includes: determining whether the sum of the storage space occupied by the storage device after clearing the files to be cleared and the file size of the files to be written is greater than or equal to a preset value; if the judgment result is yes, returning to the step of selecting at least one file to be cleared from the files stored in the storage device according to the activity value of each of the files, and selecting at least one file to be cleared again; if the judgment result is no, ending the file clearing.
[0060] The above preset value is the threshold of the storage space. When the sum of the occupied storage space and the file size to be written is greater than or equal to the storage space threshold, it is determined that the storage space of the storage device is insufficient and the file cleaning program is triggered. The preset value can be flexibly set by the user.
[0061] The storage device includes multiple files. When cleaning files, it is often necessary to clean multiple files. After clearing the file with the lowest activity value according to the above steps, it is necessary to check again whether the sum of the storage space occupied by the storage device and the file size of the file to be written is greater than or equal to the preset value, and determine whether the occupied storage space of the storage device is still insufficient after cleaning by the above steps. If so, return to step S203 to clean the files, and loop in sequence until the judgment result is no.
[0062] It should be noted that whenever a new file is written to the storage device, the above steps will be triggered to determine whether the sum of the occupied storage space and the file size of the file to be written is greater than or equal to the preset value, so that the storage device can clear files in time and improve the utilization rate of the storage device. In the case where no new files are written and the storage device automatically detects whether the storage space reaches the storage space threshold at regular intervals, the file size of the file to be written can be zero.
[0063] For example, the preset storage space threshold of the storage device is 85MB, and the storage space occupied by the storage device is 80MB. When a new file of 10MB is written to the storage device, the cleanup process is triggered. After sorting the activity values of multiple files in the storage device according to the above steps, the file with the lowest activity value (file size is 3MB) is cleared. At this time, the sum of the storage space occupied by the storage device and the file size of the file to be written is 87MB. The sum of the storage space occupied by the storage device and the file size of the file to be written is compared with the storage space threshold again. Since this value is greater than the storage space threshold of 85MB, it is necessary to return to the above step S203 to delete another file (for example, the file size is 5MB) according to the activity value. After deleting the above two files, the occupied storage space of the storage device is 82MB, which is less than the storage space threshold, and the file clearing is ended.
[0064] As an optional embodiment, at least one file to be cleared is selected from the files stored in the storage device according to the activity value of each file, including: sorting the files in order of activity value from low to high; judging whether the sum of the storage space occupied by the storage device minus the file size of the first-ranked file and the file size of the file to be written is greater than or equal to a preset value; if the judgment result is no, determining that the first-ranked file is the file to be cleared; if the judgment result is yes, continuing to judge whether the sum of the storage space occupied by the storage device minus the file size of the first-ranked file and the file size of the file to be written is greater than or equal to the preset value; if the judgment result is no, determining that the first-ranked file and the second-ranked file are the files to be cleared.
[0065] As an optional embodiment, when a storage device includes multiple files and multiple files to be cleared need to be cleared, the method for selecting the multiple files to be cleared is understood as follows: sort the files in order of activity value from low to high. If deleting a file with the lowest activity value can make the sum of the occupied storage space and the file size of the file to be written less than a preset value, then the file with the lowest activity value is the file to be cleared; if deleting the file with the lowest activity value, the sum of the occupied storage space and the file size of the file to be written still exceeds the threshold of the storage space, then select a file with the second lowest activity value as the file to be cleared in order of activity value from low to high.
[0066] For example, the preset storage space threshold of the storage device is 85MB, the storage space occupied by the storage device is 80MB, and the cleaning process is triggered when a new file of 10MB is written to the storage device. After sorting the activity values of multiple files in the storage device according to the above steps, the file sizes after sorting the files from low to high according to the activity values are 3MB, 5MB, 6MB, etc. Calculation shows that even after clearing the 3MB file with the lowest activity value, the sum of the storage space occupied by the storage device and the file size of the file to be written is 87MB, which is still greater than the storage space threshold of 85MB. Then, the 5MB file with the second lowest activity value is selected. After deleting the above two files, the storage space occupied by the storage device is 82MB, which is less than the storage space threshold of 85MB, and the file clearing ends.
[0067] It should be noted that after selecting the file with the second lowest activity value as the file to be cleared, if the sum of the storage space occupied by the storage device and the file size of the file to be written is still greater than or equal to the preset value, then the third lowest activity value file is selected as the file to be cleared according to the above steps until the sum of the storage space occupied by the storage device and the file size of the file to be written is less than the preset value.
[0068] Through the above steps, by taking the activity value of the file as the basis for selecting the file to be cleared, factors such as the frequency of file use and the time of use are comprehensively considered, and the value of the file can be judged more accurately, thereby solving the problem in the prior art that when the storage space of the storage device is insufficient, the improper way of deleting files may cause valuable files to be deleted.
[0069] Figure 6 An optional data processing method for a storage device according to an embodiment of the present invention is provided. The maximum allowable usable space of the storage device is set to 100 MB, and the storage space threshold is set to 85 MB. After a new file A is written and a file cleaning program is triggered, the data processing method includes the following steps:
[0070] Step S601, obtaining the file size SizeA of the newly written file A.
[0071] Step S602, obtaining the size Cur_Size of the storage space of the current storage device.
[0072] Step S603, determine whether the sum of the storage space size Cur_Size of the current storage device and the size SizeA of the newly written file A is greater than or equal to the storage space threshold 85MB; if the judgment result is yes, proceed to step S604 to execute the file cleaning task, if the judgment result is no, proceed to step S605 to end the cleaning.
[0073] Figure 7 An optional data processing method for a storage device according to an embodiment of the present invention is provided. The maximum allowable usable space of the storage device is set to 100 MB, and the storage space threshold is set to 85 MB. After a new file A is written and a file cleaning program is triggered, the processing method includes the following steps:
[0074] Step S701, start the cleaning task.
[0075] Step S702, obtaining the size Cur_Size of the storage space of the current storage device.
[0076] Step S703, obtaining a file record table, which includes file parameters such as the reading time of each file.
[0077] Step S704: Calculate the active value list List of each file according to the file record table.
[0078] Step S705, determine whether the storage space size Cur_Size of the current storage device is less than the storage space threshold 85MB; if the determination result is yes, proceed to step S706 to end the cleanup; if the determination result is no, proceed to step S707.
[0079] Step S707: Obtain the file S with the lowest activity value from the activity value list List.
[0080] Step S708, obtaining the file size information Size_S of the file S.
[0081] Step S709, clearing file S;
[0082] Step S710, subtract the size Size_S of file S from the size Cur_Size of the storage space in step S702 and reassign it to Cur_Size to obtain the size Cur_Size of the current storage space after cleaning file S, return to step S705 to again determine whether the size Cur_Size of the storage space of the current storage device is less than the storage space threshold 85MB and repeat the above steps.
[0083] Example 2
[0084] According to an embodiment of the present invention, a data processing device embodiment of a storage device is provided, such as Figure 8As shown, the data processing device of the storage device includes: a detection module 81, which is used to detect whether the storage space of the storage device is sufficient; an activity value acquisition module 82, which is used to determine the activity value of each file in the storage device according to the file parameters of each file in the storage device when it is determined that the storage space of the storage device is insufficient, wherein the above-mentioned file parameters include: file size and file reading time; a selection module 83, which is used to select at least one file to be cleared from the files stored in the storage device according to the activity value of each file; and a clearing module 84, which is used to clear the files to be cleared.
[0085] Optionally, the detection module 81 includes: a receiving submodule for receiving a write instruction to the storage device; an acquiring submodule for acquiring the file size of the file to be written; and a comparing submodule for determining that the storage space of the storage device is insufficient if the sum of the storage space occupied by the storage device and the file size of the file to be written is greater than or equal to a preset value.
[0086] Optionally, the activity value acquisition module 82 includes: a time difference acquisition submodule, used to determine the time difference for reading a file based on the current time and the file reading time, wherein the corresponding file reading time is recorded each time the file is read; a score determination submodule, used to determine the ratio of the time difference to a preset period as a time difference score; a single activity value calculation submodule, used to determine the difference between a preset basic score and the time difference score as the activity value corresponding to this file reading; and a total activity value calculation submodule, used to obtain the sum of the activity values corresponding to each file reading to obtain the activity value of the file.
[0087] Optionally, the selection module 83 includes: a determination submodule, configured to determine a file with the lowest activity value as the file to be cleared.
[0088] Optionally, the above-mentioned device also includes: a storage space comparison module, which is used to determine whether the sum of the storage space occupied by the storage device after clearing the files to be cleared and the file size of the files to be written is greater than or equal to a preset value; and if the judgment result is yes, then after selecting at least one file to be cleared from the files stored in the storage device according to the activity value of each of the files, at least one file to be cleared is selected again; if the judgment result is no, the file clearing is ended.
[0089] Optionally, the selection module 83 includes: a sorting submodule, used to sort the files in order of activity value from low to high; a judgment submodule, used to judge whether the sum of the storage space occupied by the storage device minus the file size of the first-ranked file and the file size of the file to be written is greater than or equal to a preset value; and if the judgment result is no, the first-ranked file is determined to be the file to be cleared; if the judgment result is yes, continue to store the storage device to determine whether the sum of the storage space occupied by the storage device minus the file size of the first-ranked file and the file size of the file to be written is greater than or equal to a preset value, if the judgment result is no, determine that the first-ranked file and the second-ranked file are the files to be cleared.
[0090] Example 3
[0091] According to an embodiment of the present application, a computer storage medium is provided, which stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps of any one of the methods in Embodiment 1.
[0092] In the embodiment of the present application, the storage medium stores multiple instructions so that the processor can load and execute any one of the methods in Embodiment 1 to detect whether the storage space of the storage device is sufficient; when it is determined that the storage space of the storage device is insufficient, the activity value of each file is determined according to the file read time of each file in the storage device; at least one file to be cleared is selected from the files stored in the storage device according to the activity value of each file; and the files to be cleared are cleared. The above scheme uses the file read time to determine the activity value of the file, and sorts the files to be cleared by the activity value. It comprehensively considers factors such as the frequency of file use and the time of use, and can more accurately judge the value of the file, solving the problem in the prior art that the improper way of deleting files when the storage space of the storage device is insufficient may cause valuable files to be deleted.
[0093] Example 4
[0094] According to an embodiment of the present application, a smart interactive tablet is provided, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing any one of the method steps in Example 1.
[0095] Fig. 9 is a schematic diagram of the structure of a smart interactive tablet provided in an embodiment of the present application, the smart interactive tablet comprises the above-mentioned interactive device body and touch frame, combined with Fig. 9 As shown, the smart interactive tablet 1000 may include: at least one processor 1001 , at least one network interface 1004 , a user interface 1003 , a memory 1005 , and at least one communication bus 1002 .
[0096] The communication bus 1002 is used to realize the connection and communication between these components.
[0097] The user interface 1003 may include a display screen (Display) and a camera (Camera), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
[0098] The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0099] Among them, the processor 1001 may include one or more processing cores. The processor 1001 uses various interfaces and lines to connect the various parts of the entire intelligent interactive tablet 1000, and executes various functions and processes data of the intelligent interactive tablet 1000 by running or executing instructions, programs, code sets or instruction sets stored in the memory 1005, and calling data stored in the memory 1005. Optionally, the processor 1001 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 1001 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 1001, and it can be implemented separately through a chip.
[0100] Among them, the memory 1005 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 1005 includes a non-transitory computer-readable storage medium. The memory 1005 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 1005 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 1005 may optionally be at least one storage device located away from the aforementioned processor 1001. As Fig. 9 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an operating application of the smart interactive tablet.
[0101] exist Fig. 9 In the smart interactive tablet 1000 shown, the user interface 1003 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 1001 can be used to call the operating application of the smart interactive tablet stored in the memory 1005, and specifically perform any one of the operations in Example 1.
[0102] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0103] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0104] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0105] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0106] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0107] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, 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, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0108] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A data processing method for a storage device, characterized in that: include: Detecting whether the storage space of the storage device is sufficient; When it is determined that the storage space of the storage device is insufficient, determining the activity value of each file in the storage device according to the file read time of each file; Selecting at least one file to be cleared from the files stored in the storage device according to the activity value of each of the files; Clearing the files to be cleared; Among them, when it is determined that the storage space of the storage device is insufficient, the activity value of each file in the storage device is determined according to the file reading time of each file, including: determining the time difference for reading the file according to the current time and the file reading time, wherein the corresponding file reading time is recorded each time the file is read; determining the ratio of the time difference to a preset period as a time difference score; determining the difference between a preset basic score and the time difference score as the activity value corresponding to this file reading; obtaining the sum of the activity values corresponding to each file reading to obtain the activity value of the file.
2. The method according to claim 1, characterized in that: Detecting whether the storage space of the storage device is sufficient includes: receiving a write instruction to the storage device; Get the file size of the file to be written; If the sum of the storage space occupied by the storage device and the file size of the file to be written is greater than or equal to a preset value, it is determined that the storage space of the storage device is insufficient.
3. The method according to claim 1, characterized in that Selecting at least one to-be-cleared file from the files stored in the storage device according to the activity value of each of the files includes: determining a file with the lowest activity value as the to-be-cleared file.
4. The method according to claim 3, characterized in that: After clearing the files to be cleared, the method further includes: Determine whether the sum of the storage space occupied by the storage device after clearing the file to be cleared and the file size of the file to be written is greater than or equal to a preset value; If the judgment result is yes, return to the step of selecting at least one file to be deleted from the files stored in the storage device according to the activity value of each of the files, and select at least one file to be deleted again; If the judgment result is no, the file clearing process ends.
5. The method according to claim 1, characterized in that: Selecting at least one file to be cleared from the files stored in the storage device according to the activity value of each of the files comprises: Sort the files in order of activity value from low to high; Determine whether the sum of the storage space occupied by the storage device minus the file size of the first-ranked file and the file size of the file to be written is greater than or equal to a preset value; If the judgment result is no, the file ranked first is determined to be the file to be cleared; If the judgment result is yes, continue to check whether the sum of the storage space occupied by the storage device minus the file sizes of the first-ranked file and the second-ranked file and the file size of the file to be written is greater than or equal to the preset value; if the judgment result is no, determine that the first-ranked file and the second-ranked file are files to be cleared.
6. A data processing device for a storage device, characterized in that: include: A detection module, used to detect whether the storage space of the storage device is sufficient; An activity value acquisition module, configured to determine the activity value of each file in the storage device according to the file reading time of each file in the storage device when it is determined that the storage space of the storage device is insufficient; A selection module, configured to select at least one file to be cleared from the files stored in the storage device according to the activity value of each file; A clearing module, used for clearing the files to be cleared; Among them, the activity value acquisition module includes: a time difference acquisition submodule, used to determine the time difference for reading a file based on the current time and the file reading time, wherein the corresponding file reading time is recorded each time the file is read; a score determination submodule, used to determine the ratio of the time difference to a preset period as a time difference score; a single activity value calculation submodule, used to determine the difference between a preset basic score and the time difference score as the activity value corresponding to this file reading; a total activity value calculation submodule, used to obtain the sum of the activity values corresponding to each file reading to obtain the activity value of the file.
7. The device according to claim 6, characterized in that The detection module comprises: A receiving submodule, used for receiving a write instruction to the storage device; Get submodule, used to get the file size of the file to be written; The comparison submodule determines that the storage space of the storage device is insufficient if the sum of the storage space occupied by the storage device and the file size of the file to be written is greater than or equal to a preset value.
8. A computer storage medium, characterized in that The computer storage medium stores a plurality of instructions, which are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 5.
9. A smart interactive tablet, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for cleaning disk space, storage medium and terminal
CN109542344A
File cleaning method and related equipment thereof
CN111737209A