[0021] The application will be further described in detail below through specific implementations in conjunction with the drawings.
[0022] In order to solve the problem that when the storage space is full, the prior art will automatically delete the oldest historical observation data to make storage space for the new data, which will seriously distort the overall trend of the data. When the space is not enough, one of the two adjacent data with the smallest difference is deleted, thereby freeing up storage space for storing new data, while retaining the changing trend of the data in the storage space to the greatest extent. The following further illustrates through several embodiments.
[0023] Please refer to figure 1 This embodiment provides a method for storing historical trend data in a limited storage space, including a judgment step S103, a subtraction step S105, a comparison step S107, and a deletion step S109. In one embodiment, it may also include the collection step S101 and/ Or write step S111, which will be described in detail below.
[0024] Collection step S101: collect new data.
[0025] Judgment step S103: judge the remaining space of the storage space. In one embodiment, the remaining space judgment of the storage space in the judgment step S103 is to judge whether the storage space has remaining space; the advantage of this is that it only needs to simply judge whether the storage space has remaining space, but it may cause problems Yes, the remaining space is not enough to store new data. In another embodiment, the remaining space judgment of the storage space in the judgment step S103 is to judge whether the storage space has enough free space to store new data; the advantage of this is that it can ensure that when the judgment result is yes, the remaining space must be available Write new data, but the disadvantage is that you need to compare the storage space occupied by the new data with the remaining space. In another embodiment, the remaining space judgment of the storage space in the judging step S103 is to judge whether the storage space has a remaining space greater than a preset threshold. This is convenient for the situation that some new data always occupy a fixed storage space. For example, when the monitor collects new data one by one and saves it, the storage space required for each new data collected is usually the same. In one embodiment, the judging step S103 is performed before storing the new data, for example, after the new data is collected in the collecting step S101, before the collected data is ready to be stored.
[0026] When the judgment result of the judgment step S103 is yes, then the writing step S111 is performed; when the judgment result is no no, then the subtraction step S105 is performed. In one embodiment, the judgment step S103 is performed before storing new data.
[0027] Subtraction step S105: subtract all the data in the storage space from the respective adjacent data to obtain a difference, where the adjacent data is the data adjacent at the storage time. In an embodiment, the difference value refers to the absolute value of the difference between two data. For example, in one embodiment, for example, if there are 1 to 5 adjacent data, the first data can be subtracted from the second data, the second data can be subtracted from the third data, and the fourth data can be subtracted from the third data. Subtract the third data from the data, and subtract the fourth data from the fifth data.
[0028] Comparison step S107: compare the differences to obtain the smallest difference.
[0029] Deleting step S109: Deleting one of the two adjacent data corresponding to the smallest difference, so that the storage space has remaining space for storing new data. In one embodiment, the smaller one of the two adjacent data corresponding to the smallest difference is deleted. When the smallest difference is 0, that is, when the corresponding two adjacent data are equal, just delete one of them at this time. In one embodiment, when there are multiple minimum differences, one of the minimum differences is arbitrarily selected, and one of the two adjacent data corresponding to it is deleted.
[0030] Writing step S111: store the new data in the storage space.
[0031] In one embodiment, after step S109 is deleted, the judgment step S103 is performed again. For example, when the remaining space of the storage space is judged in the judgment step S103, it is judged whether there is enough remaining space in the storage space to store new data, so after the deletion step S109, there may be remaining space or insufficient storage of new data. Therefore, it is necessary to perform the judgment step S103 again to judge whether the storage space has enough free space to store new data.
[0032] Please refer to figure 2 This embodiment also provides a device for storing historical trend data in a limited storage space, which includes a judgment module 103, a subtraction module 105, a comparison module 107, and a deletion module 109. In an embodiment, it may also include a collection module 101. And/or write module 111, which will be described in detail below.
[0033] The collection module 101 is used to collect new data.
[0034] The judgment module 103 is used to judge the remaining space of the storage space. In one embodiment, the judging module 103 is a module for judging whether the storage space has free space; in another embodiment, the judging module 103 can also be a module for judging whether the storage space has enough free space to store new data; In another embodiment, the judging module may also be a module for judging whether the storage space has a remaining space greater than a preset threshold.
[0035] The subtraction module 105 is used for subtracting all the data in the storage space from the adjacent data to obtain the difference when the judgment result of the judgment module 103 is no, where the adjacent data is the data adjacent at the storage time.
[0036] The comparison module 107 is used to compare the difference obtained by the subtraction module 105 to obtain the smallest difference.
[0037] The deleting module 109 is configured to delete one of the two adjacent data corresponding to the smallest difference obtained by the comparison module 107, so that there is free space in the storage space to store new data. In an embodiment, the deleting module 109 deletes the smaller one of the two adjacent data corresponding to the smallest difference; when the smallest difference is 0, that is, when the corresponding two adjacent data are equal , Just delete one of them at this time. In an embodiment, when there are multiple minimum differences, one of the minimum differences is arbitrarily selected, and one of the two adjacent data corresponding to it is deleted. In one embodiment, after the deleting module 109 deletes a piece of data, it notifies the judgment module 103 to perform judgment again.
[0038] The writing module 109 is configured to write the new data collected in the collection module 101 into the storage space when the judgment result of the judgment module 103 is yes.
[0039] The method and device for storing historical trend data in a limited storage space in this application, because when it is judged that the storage space is insufficient, one of the two adjacent data with the smallest difference is deleted, thereby freeing up storage space for While storing new data, the changing trend of the data in the storage space is retained to the greatest extent.
[0040] The above content is a further detailed description of the application in conjunction with specific implementations, and it cannot be considered that the specific implementation of the application is limited to these descriptions. For those of ordinary skill in the technical field to which this application belongs, several simple deductions or substitutions can be made without departing from the inventive concept of this application.