CN109597588B - Data storage method, data restoration method and device - Google Patents

Data storage method, data restoration method and device Download PDF

Info

Publication number
CN109597588B
CN109597588B CN201811509080.8A CN201811509080A CN109597588B CN 109597588 B CN109597588 B CN 109597588B CN 201811509080 A CN201811509080 A CN 201811509080A CN 109597588 B CN109597588 B CN 109597588B
Authority
CN
China
Prior art keywords
timestamp
sequence
time stamp
ith
original
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811509080.8A
Other languages
Chinese (zh)
Other versions
CN109597588A (en
Inventor
苏宏业
卜梓琴
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Zhongzhida Technology Co ltd
Original Assignee
Zhejiang Zhongzhida Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Zhongzhida Technology Co ltd filed Critical Zhejiang Zhongzhida Technology Co ltd
Priority to CN201811509080.8A priority Critical patent/CN109597588B/en
Publication of CN109597588A publication Critical patent/CN109597588A/en
Application granted granted Critical
Publication of CN109597588B publication Critical patent/CN109597588B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0608Saving storage space on storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a data storage method, a data recovery method and a device, if the relation between the ith time stamp and the (i-1) th time stamp is a continuous relation and the ith time stamp is not the nth time stamp, adding 1 to i and returning to execute the acquisition of the ith time stamp in the original time stamp sequence, if the relation between the ith time stamp and the (i-1) th time stamp is a continuous relation and the ith time stamp is the nth time stamp, storing the respective offset values and the number of the stored offset values of the 1 st time stamp, the 2 nd to the nth time stamps in the original time stamp sequence, and recovering the unique time stamp corresponding to each offset value, thereby realizing the reduction of the occupation of a storage space by storing the offset value, so that the offset value does not need to be discarded when storing the offset value, and each time stamp in the original time stamp sequence can be recovered accurately by storing the offset value, thereby improving the integrity and authenticity of the timestamp.

Description

Data storage method, data restoration method and device
Technical Field
The invention belongs to the technical field of data processing, and particularly relates to a data storage method, a data recovery method and a data recovery device.
Background
Currently, in the field of industrial control, large-scale real-time data needs to be stored as an important basis for processes such as production control, production analysis, production optimization and the like, where the real-time data is used to describe state change information of an object in a historical time dimension, for example, 2017, 1, 9 minutes and 9 minutes: 123456 seconds, the temperature of the water of the rectifying device No. 1 in the factory is 20 ℃, and therefore the real-time data comprise: the state change information of the object and the timestamp corresponding to the state change information are generally a character and are used for uniquely representing a certain moment, and the timestamp is composed of year, month, day, hour, minute, second and millisecond, so that the timestamp occupies a larger memory when the timestamp is stored.
In order to reduce the memory occupied by the timestamp, the timestamp can be stored by adopting a mode of setting a deviation threshold value, for example, if the deviation value between the current timestamp and the previous timestamp is within the deviation threshold value, the current timestamp is discarded, if the deviation value exceeds the deviation threshold value, the current timestamp is kept and stored, the memory occupation is reduced by reducing the number of the stored timestamps, the purpose of storage optimization is achieved, but some timestamps are lost by the storage mode, and the integrity and the authenticity of the timestamp are reduced.
Disclosure of Invention
In view of the above, the present invention provides a data storage method, a data recovery method and a data recovery device, which are used to store data by storing an offset value in a timestamp and obtain data by recovering the offset value. The technical scheme is as follows:
the invention provides a data storage method, which comprises the following steps:
acquiring the ith timestamp in an original timestamp sequence, wherein i is any number from 2 to n, and n is the total number of timestamps in the original timestamp sequence;
if the relation between the ith timestamp and the (i-1) th timestamp is a continuous relation and the ith timestamp is not the nth timestamp, adding 1 to the i and returning to execute the step of acquiring the ith timestamp in the original timestamp sequence;
and if the relation between the ith timestamp and the (i-1) th timestamp is a continuous relation and the ith timestamp is the nth timestamp, storing the offset values and the number of the stored offset values of the 1 st timestamp, the 2 nd timestamp and the nth timestamp in the original timestamp sequence.
Preferably, the method further comprises:
if the relation between the ith timestamp and the (i-1) th timestamp is a discontinuous relation, and the ith timestamp is the nth timestamp, independently storing the ith timestamp;
if the relation between the ith timestamp and the (i-1) th timestamp is a discontinuous relation and the ith timestamp is not the nth timestamp, determining the ith timestamp as a new 1 st timestamp in the original timestamp sequence, adding 1 to i, and returning to execute the step of obtaining the ith timestamp in the original timestamp sequence;
storing the 1 st timestamp to the i-1 st timestamp in the original timestamp sequence based on a relationship between timestamps.
Preferably, the storing the 1 st timestamp to the i-1 st timestamp in the original timestamp sequence based on the relationship between timestamps includes:
if the value of i is equal to 2, independently storing the 1 st time stamp in the original time stamp sequence;
if the value of i is greater than 2, if a continuous time stamp sequence composed of time stamps which are in a continuous relationship and adjacent to each other exists in the original time stamp sequence, storing the 1 st time stamp in the continuous time stamp sequence, storing the deviation value and the number of the stored deviation value from the 2 nd time stamp to the m th time stamp, wherein m-1 is the number of the deviation values in the continuous time stamp sequence, and if the relationship between the jth time stamp and the jth-1 time stamp in the original time stamp sequence is a discontinuous relationship and the relationship between the jth time stamp and the (j + 1) th time stamp is a discontinuous relationship, separately storing the jth time stamp in the original time stamp sequence.
Preferably, the storing offset values and the number of stored offset values of the 1 st timestamp, the 2 nd timestamp to the nth timestamp in the original timestamp sequence includes:
storing the 1 st time stamp, the 2 nd time stamp to the nth time stamp and the deviation value number into the continuous time stamp sequence according to the sequence of the 1 st time stamp to the nth time stamp in the original time stamp sequence;
the deviation value of the xth timestamp from the 2 nd timestamp to the nth timestamp is as follows: an offset value between the xth timestamp and the (x-1) th timestamp, or an offset value between the xth timestamp and the (1) th timestamp, wherein x is any number from 2 to n.
Preferably, the 1 st bit in the continuous time stamp sequence is a value of an identifier, and the value of the identifier is used to indicate that the relationships between the time stamps stored in the continuous time stamp sequence are all continuous relationships.
Preferably, the method further comprises: storing the sampling intervals of the original sequence of time stamps in the sequence of consecutive time stamps.
The invention provides a data reduction method, which comprises the following steps:
acquiring an identifier in a time stamp sequence, wherein the time stamp sequence is a sequence obtained by processing an original time stamp sequence based on the method of any one of claims 1 to 6;
if the value of the identifier in the timestamp sequence indicates that the timestamp sequence is a continuous timestamp sequence, acquiring fields which represent the 1 st timestamp, represent the deviation values of the 2 nd timestamp to the e nd timestamp and represent the number of the deviation values in the continuous timestamp sequence, and acquiring the 1 st timestamp to the e th timestamp based on the fields which represent the 1 st timestamp, represent the deviation values of the 2 nd timestamp to the e nd timestamp and represent the number of the deviation values, wherein e-1 is the number of the deviation values recorded by the continuous timestamp sequence;
and if the value of the identifier in the time stamp sequence indicates that the time stamp sequence is the independent time stamp sequence, calculating to obtain the time stamp recorded in the independent time stamp sequence.
The present invention provides a data storage device, the device comprising:
the first acquisition module is used for acquiring the ith timestamp in the original timestamp sequence, wherein i is any number from 2 to n, and n is the total number of timestamps in the original timestamp sequence;
a first return execution module, configured to add 1 to i and trigger the first obtaining module if a relationship between the ith timestamp and the (i-1) th timestamp is a continuous relationship and the ith timestamp is not the nth timestamp;
and the first storage module is used for storing the 1 st timestamp, the deviation values from the 2 nd timestamp to the nth timestamp and the number of the stored deviation values in the original timestamp sequence if the relationship between the ith timestamp and the (i-1) th timestamp is a continuous relationship and the ith timestamp is the nth timestamp.
Preferably, the apparatus further comprises:
a second storage module, configured to store an ith timestamp separately if a relationship between the ith timestamp and an (i-1) th timestamp is a discontinuous relationship and the ith timestamp is an nth timestamp;
a second return execution module, configured to determine, if the relationship between the ith timestamp and the (i-1) th timestamp is a discontinuous relationship and the ith timestamp is not the nth timestamp, that the ith timestamp is a new 1 st timestamp in the original timestamp sequence, add 1 to i, and trigger the first obtaining module;
and the third storage module is used for storing the 1 st timestamp to the (i-1) th timestamp in the original timestamp sequence based on the relation between the timestamps.
The present invention provides a data reduction apparatus, the apparatus comprising:
a second obtaining module, configured to obtain an identifier in a time stamp sequence, where the time stamp sequence is a sequence obtained by processing an original time stamp sequence based on the apparatus of any one of claims 8 to 9;
a first restoring module, configured to, if a value of an identifier in the timestamp sequence indicates that the timestamp sequence is a continuous timestamp sequence, obtain fields indicating a 1 st timestamp, an offset value indicating each of a 2 nd timestamp to an e th timestamp, and a number of the offset values in the continuous timestamp sequence, and obtain the 1 st timestamp to the e th timestamp based on the fields indicating the 1 st timestamp, the offset value indicating each of the 2 nd timestamp to the e th timestamp, and the number of the offset values, where e-1 is the number of the offset values recorded by the continuous timestamp sequence;
and the second restoring module is used for calculating the time stamp recorded in the independent time stamp sequence if the value of the identifier in the time stamp sequence indicates that the time stamp sequence is the independent time stamp sequence.
Known from the technical scheme, by acquiring the ith timestamp in the original timestamp sequence, if the relationship between the ith timestamp and the (i-1) th timestamp is a continuous relationship and the ith timestamp is not the nth timestamp, adding 1 to i and returning to acquire the ith timestamp in the original timestamp sequence, if the relationship between the ith timestamp and the (i-1) th timestamp is a continuous relationship and the ith timestamp is the nth timestamp, storing the 1 st timestamp in the original timestamp sequence, storing the offset values and the stored offset values of the 2 nd timestamp to the nth timestamp respectively, and restoring the unique timestamp corresponding to each offset value through the offset values, thereby reducing the occupation of a storage space by storing the offset values, and thus, when the offset values are stored, discarding the offset values is not required, and each time stamp in the original time stamp sequence can be accurately restored by storing the deviation value, so that the integrity and the authenticity of the time stamp are improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flow chart of a data storage method according to an embodiment of the present invention;
FIG. 2 is a flow chart of another data storage method provided by an embodiment of the invention;
fig. 3 is a flowchart of a data restoring method according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a data storage device according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of another data storage device according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a data reduction apparatus according to an embodiment of the present invention.
Detailed Description
Because real-time data in a plurality of fields, such as the field of industrial control, are generated by sampling by a collector at regular time, timestamps corresponding to the real-time data often increase regularly, and as a result, the timestamps corresponding to the real-time data theoretically conform to the following characteristics:
t1, t2 ═ t1 +/Δ t, t3 ═ t2 +/Δ t, as.. tn ═ tn-1 +/Δ t, where Δ t is the sampling interval, thus summarizing the theoretical rule followed between two adjacent timestamps in a sequence of timestamps consisting of a plurality of timestamps as: tn-1 +. DELTA.t (n-2, 3.... 9.).
In practice, due to the acquisition accuracy of the acquirer and other various reasons, each timestamp may have a certain degree of deviation, and the values of the timestamps in the timestamp sequence are as follows: t1+ d1, t2 ═ t1 +/Δ t + d2, t3 ═ t2 +/Δ t + d3,.. 9., tn ═ tn-1 +/Δ t + dn (n > -2), so that the law that is followed on the basis of theoretical laws between two adjacent timestamps in a sequence of timestamps is:
tn-1 +. DELTA.t + dn (n > -2). Wherein d2, d 3.. and dn are deviation values, and if the collector continuously collects, the value of delta t + dn fluctuates above and below the sampling interval delta t.
Assuming that each timestamp is represented by int64 when storing the timestamp sequence, each timestamp occupies 8 bytes, which results in a large storage space occupied by the timestamp sequence, and the inventor has observed that the offset value is used to replace the timestamp by taking advantage of the above-mentioned rule of tn-1 +. Δ t + dn (n > -2), because: compared with the timestamp, the offset value is far smaller than the timestamp, so that a smaller storage space can be used for storing the offset value, for example, but not limited to, 2 bytes are used for storing, and the storage space occupied by the timestamp sequence is greatly reduced.
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, a flowchart of a data storage method provided by an embodiment of the present invention is shown, for reducing a storage space occupied by a time stamp sequence, where the method may include the following steps:
s101: and acquiring the ith timestamp in the original timestamp sequence, wherein i is any number from 2 to n, and n is the total number of timestamps in the original timestamp sequence. It can be understood that: the sequence of each timestamp in the original timestamp sequence is from 1 to n, but in the actual storage process, each timestamp can be sequentially acquired from the 2 nd timestamp of the original timestamp sequence until the last timestamp of the original timestamp sequence, and any timestamp between the 2 nd timestamp and the last timestamp can be acquired only once, and the subsequent steps are executed for each timestamp. The reason why the acquisition can be started from the 2 nd timestamp is that the acquisition is started from the 2 nd timestamp because the acquisition is based on the relationship between the ith timestamp and the (i-1) th timestamp in the subsequent storage, the 1 st timestamp is the first timestamp in the original timestamp sequence, the timestamps before the 1 st timestamp do not exist for the 1 st timestamp, and the storage mode of the 1 st timestamp can also be determined through the relationship between the 1 st timestamp and the 2 nd timestamp.
If the original timestamp sequence contains 10 timestamps, the timestamps are sequentially acquired from the 2 nd timestamp until the 10 th timestamp is acquired, the acquisition is finished, and the following steps are executed on the currently acquired timestamp every time one timestamp is acquired so as to judge the relationship between the currently acquired timestamp and the previous timestamp adjacent to the currently acquired timestamp and determine how to store the timestamp based on the relationship.
S102: and if the relation between the ith timestamp and the (i-1) th timestamp is a continuous relation and the ith timestamp is not the nth timestamp, adding 1 to the ith timestamp, and returning to execute the step of acquiring the ith timestamp in the original timestamp sequence.
In this embodiment, one possible way to determine the relationship between the ith timestamp and the (i-1) th timestamp is to: obtaining an ith time stamp and an ith-1 time stamp, obtaining an offset value (for convenience of description, marked as an ith offset value) between the ith time stamp and the ith-1 time stamp based on the ith time stamp and the ith-1 time stamp, if the ith offset value has continuity, determining that the relationship between the ith time stamp and the ith-1 time stamp is a continuous relationship, and if the ith offset value does not have continuity, determining that the relationship between the ith time stamp and the ith-1 time stamp is a discontinuous relationship.
One possible way to determine whether the ith deviation value has continuity is: and judging whether the ith deviation value is within a threshold range, if the ith deviation value is within the threshold range, the ith deviation value has continuity, if the ith deviation value is not within the threshold range, the ith deviation value does not have continuity, and the threshold range can be but is not limited to [ -32768, +32767], so that if the ith deviation value is within [ -32768, +32767], the ith deviation value is confirmed to have continuity, and otherwise, the ith deviation value does not have continuity.
One possible way to determine that the ith timestamp is not the nth timestamp is to: and obtaining the value of i, obtaining the total number n of the timestamps, and judging whether i is greater than or equal to n, wherein if i is greater than or equal to n, the ith timestamp is the nth timestamp, and if i is less than n, the ith timestamp is not the nth timestamp.
It should be noted that: adding 1 to i and returning to execute the step of acquiring the ith timestamp in the original timestamp sequence, namely: and if the relation between the ith timestamp and the (i-1) th timestamp is a continuous relation, returning to obtain the (i + 1) th timestamp in the original timestamp sequence, and if the relation between the (5) th timestamp and the (4) th timestamp is a continuous relation, continuously obtaining the (6) th timestamp in the original timestamp sequence.
S103: and if the relation between the ith timestamp and the (i-1) th timestamp is a continuous relation and the ith timestamp is the nth timestamp, storing the 1 st timestamp in the original timestamp sequence, storing the deviation values of the 2 nd timestamp to the nth timestamp and storing the number of the deviation values.
In this embodiment, one possible way to store the offset values and the number of stored offset values of the 1 st timestamp, the 2 nd timestamp to the nth timestamp in the original timestamp sequence is as follows: and storing the 1 st time stamp, the 2 nd time stamp to the nth time stamp and the deviation value number into the continuous time stamp sequence according to the sequence of the 1 st time stamp to the nth time stamp in the original time stamp sequence.
That is, with respect to the original time stamp sequence, each memory cell in the original time stamp sequence stores one time stamp, while the 1 st memory cell in the continuous time stamp sequence stores the 1 st time stamp, and the other memory cells store the offset value of the time stamp, and the content stored by each memory cell in the continuous time stamp sequence is still in the order of the 1 st to nth time stamps in the original time stamp sequence.
Wherein the deviation value of the xth timestamp from the 2 nd timestamp to the nth timestamp is: an offset value between the xth timestamp and the (x-1) th timestamp, or an offset value between the xth timestamp and the (1) th timestamp, wherein x is any number from 2 to n. That is, each timestamp from the 2 nd timestamp to the nth timestamp has 1 corresponding offset value, such as the offset values d2, d3, a...... and dn obtained from the above tn-1 +. DELTA.t + dn (n > -2) and stored in sequence in the sequence of consecutive timestamps based on the sequence of d2, d3, a.... and dn, and the offset values from the tn-1 +. DELTA.t + dn (n > -2) are known to be offset values between the x-th timestamp and the x-1 st timestamp, although other offset values from other timestamps with respect to the 1 st timestamp, such as the offset values between the x-th timestamp and the 1 st timestamp, may be calculated with the 1 st timestamp as a reference, or calculated with other timestamps as a reference, this embodiment is not illustrated.
It should be noted that: when the deviation values of the 1 st time stamp, the 2 nd time stamp and the nth time stamp in the original time stamp sequence are stored, the number of the deviation values also needs to be stored, so that the deviation values stored in the continuous time stamp sequence can be determined through the number of the deviation values when the data is restored, if the time stamps t2 to t5 in the original time stamp sequence are in a continuous relation, the deviation values of the t2 to t5 in one continuous time stamp sequence are stored, and meanwhile, the number of the deviation values in the continuous time stamp sequence is stored to the continuous time stamp sequence, and the value of the number of the deviation values in the current continuous time stamp sequence is 4.
To facilitate determining whether current data is data in a sequence of consecutive time stamps during data recovery, the consecutive time stamp sequence may be marked by means of an identifier, for example, the 1 st bit in the consecutive time stamp sequence is the value of the identifier, the value of the identifier is used to indicate that the relation between the timestamps stored in the sequence of consecutive timestamps is a consecutive relation, for example, when the value of the identifier is 1, indicating that it is a sequence of consecutive time stamps and the relationship between the time stamps stored in the sequence of consecutive time stamps is a consecutive relationship, the time stamps can be restored for the data stored in the 2 nd to nth memory cells during data restoration in a manner of tn-1 +. DELTA.t + dn (n > -2), where dn is an offset value corresponding to the nth time stamp stored in the nth memory cell and Δ t is a sampling interval. The bytes of the memory cells storing the offset value may be determined according to the offset value, and if the offset value needs to occupy 2 bytes or 4 bytes, 2 bytes or 4 bytes may be allocated to the memory cells to store the offset value, and the bytes allocated to the memory cells are not limited herein as long as they are smaller than the bytes occupied by the time stamps in the original time stamp sequence.
And as can be seen from tn-1 +. DELTA.t + dn (n > -2), DELTA.t is required for the reduction, for which purpose a sampling interval can be stored in the sequence of consecutive time stamps, which sampling interval can be stored in the last memory location of the sequence of consecutive time stamps, i.e. by adding one memory location to the original sequence of time stamps, as shown in Table 1.
TABLE 1 storage of a sequence of consecutive time stamps
Figure BDA0001900229140000081
Of course, other storage manners may also be adopted, such as storing the sampling interval between the offset value corresponding to the 1 st timestamp and the offset value corresponding to the 2 nd timestamp, which is not illustrated in this embodiment, or interacting the sampling interval in a pre-interaction manner, so as to perform data recovery. For the number of the offset values, the number of the offset values may be stored between the offset values corresponding to the 1 st timestamp and the 2 nd timestamp, or stored in other locations.
Known from the technical scheme, by acquiring the ith timestamp in the original timestamp sequence, if the relationship between the ith timestamp and the (i-1) th timestamp is a continuous relationship and the ith timestamp is not the nth timestamp, adding 1 to i and returning to acquire the ith timestamp in the original timestamp sequence, if the relationship between the ith timestamp and the (i-1) th timestamp is a continuous relationship and the ith timestamp is the nth timestamp, storing the 1 st timestamp in the original timestamp sequence, storing the offset values and the stored offset values of the 2 nd timestamp to the nth timestamp respectively, and restoring the unique timestamp corresponding to each offset value through the offset values, thereby reducing the occupation of a storage space by storing the offset values, and thus, when the offset values are stored, discarding the offset values is not required, and each time stamp in the original time stamp sequence can be accurately restored by storing the deviation value, so that the integrity and the authenticity of the time stamp are improved.
In contrast, if the relationship between the ith timestamp and the (i-1) th timestamp is a discontinuous relationship, the ith timestamp also needs to be stored, so this embodiment provides a flowchart of another data storage method, which explains a storage manner when the relationship between the ith timestamp and the (i-1) th timestamp is a discontinuous relationship, and the data storage method may include the following steps based on fig. 1:
s104: if the relation between the ith timestamp and the (i-1) th timestamp is a discontinuous relation, and the ith timestamp is the nth timestamp, the ith timestamp is separately stored.
The step S102 is performed in the same manner and in the same principle as the step S102, and is not described herein again. But differs from step S102 in that: if the relationship between two adjacent timestamps is a discontinuous relationship and the ith timestamp is the nth timestamp, the ith timestamp is stored separately, for example, the ith timestamp is stored in an independent timestamp sequence, and the independent timestamp sequence may store only one timestamp having a discontinuous relationship with the adjacent timestamps or store a plurality of timestamps having a discontinuous relationship with the adjacent timestamps.
Corresponding to the continuous time stamp sequence, for the independent time stamp sequence, a value of an identifier also needs to be configured, for example, a value of the identifier is recorded at the 1 st bit of the independent time stamp sequence, the value of the identifier is different from the value of the identifier in the continuous time stamp sequence, for example, the value of the identifier in the independent time stamp sequence is 0, so as to indicate that the relation between each stored time stamp in the independent time stamp sequence and other time stamps is a discontinuous relation.
Here, it should be noted that: if an original timestamp sequence is obtained as at least one continuous timestamp sequence and at least one independent timestamp sequence, and each independent timestamp sequence only stores one timestamp, when the continuous timestamp sequence and the independent timestamp sequence are stored, it needs to be stored according to the ordering of the timestamps in the original timestamp sequence in the continuous timestamp sequence and the independent timestamp sequence, for example, the original timestamp sequence is composed of 10 timestamps, where the 1 st timestamp to the 3 rd timestamp form one continuous timestamp sequence (described as continuous timestamp sequence 1), the 4 th timestamp is in one independent timestamp sequence (described as independent timestamp sequence 1), the 5 th timestamp sequence to the 10 th timestamp form one continuous timestamp sequence (described as continuous timestamp sequence 2, then the positional relationship of these three time stamp sequences at the time of storage is: the continuous time stamp sequence 1, the independent time stamp sequence 1 and the continuous time stamp sequence 2 can sequentially restore data in the three time stamp sequences during restoration, and the restored time stamps are ordered as follows: the 1 st, 2 nd, 10 th timestamps have the same ordering as the timestamps in the original sequence of timestamps.
If a plurality of timestamps are stored in one independent timestamp sequence, in order to make the sequence of the restored timestamps the same as the sequence of the timestamps in the original timestamp sequence, the sequences of the timestamps and the offset values in the original timestamp sequence need to be stored in the continuous timestamp sequence and the independent timestamp sequence, so that the restored timestamps can be arranged according to the sequences during restoration.
S105: and if the relation between the ith timestamp and the (i-1) th timestamp is a discontinuous relation and the ith timestamp is not the nth timestamp, determining the ith timestamp as a new 1 st timestamp in the original timestamp sequence, adding 1 to i, and returning to execute the step of acquiring the ith timestamp in the original timestamp sequence.
That is, if the relationship between a timestamp in the original timestamp sequence and the previous timestamp is a discontinuous relationship, the timestamp is used as the new 1 st timestamp in the original timestamp sequence, then the other timestamps that are located after the new 1 st timestamp in the original timestamp sequence are sequentially acquired from the new 1 st timestamp, and the relationship between the new 1 st timestamp and the other timestamps that are located after the new 1 st timestamp is determined and stored based on the relationship.
For example, the relationship between the 5 th timestamp and the 4 th timestamp in the original timestamp sequence is a discontinuous relationship, and the 5 th timestamp is not the nth timestamp (i.e., the last timestamp), then the 5 th timestamp is taken as the new 1 st timestamp, and the other timestamps after the new 1 st timestamp, i.e., the 6 th timestamp to the nth timestamp, are continuously and sequentially acquired.
S106: the 1 st time stamp through the (i-1) th time stamp in the original time stamp sequence are stored based on the relationship between the time stamps.
In this embodiment, the storage of the 1 st timestamp to the i-1 st timestamp in the original timestamp sequence based on the relationship between timestamps needs to be determined based on the value of i, specifically: if the value of i is equal to 2, the 1 st timestamp in the original timestamp sequence is stored separately.
If the value of i is greater than 2, if a continuous time stamp sequence formed by mutually adjacent time stamps with a continuous relation exists in the original time stamp sequence, storing the 1 st time stamp in the continuous time stamp sequence, storing the deviation value from the 2 nd time stamp to the m th time stamp and the number of the stored deviation values, wherein m-1 is the number of the deviation values in the continuous time stamp sequence.
That is, the value of i is greater than 2, and if the relationship between a plurality of timestamps that are consecutive to each other in the original timestamp sequence is a consecutive relationship, the plurality of timestamps are considered to form a consecutive timestamp sequence. For example, in the 1 st to i-1 th timestamps of the original timestamp sequence, the relationship between any two adjacent timestamps is a continuous relationship, and a continuous timestamp sequence is formed according to the j to j + a timestamps (where a is a natural number greater than or equal to 1), then for this continuous timestamp sequence, the j timestamp is used as the 1 st timestamp, the offset values and the stored offset value numbers of the other timestamps are stored in the continuous timestamp sequence, and for the obtaining manner of the offset values of the other timestamps, please refer to the description in the above method embodiment.
If the value of i is greater than 2, if the relationship between the jth timestamp and the jth-1 timestamp in the original timestamp sequence is a discontinuous relationship and the relationship between the jth timestamp and the (j + 1) th timestamp in the original timestamp sequence is a discontinuous relationship, the jth timestamp in the original timestamp sequence is separately stored. For example, the jth timestamp may be stored in an independent timestamp sequence, and for the description of the independent timestamp sequence, refer to the related description in the above method embodiment.
The following describes the method shown in fig. 1 and 2, taking an example that an original time stamp sequence includes 10 time stamps: the following relationship exists between the 10 timestamps:
the first relationship is: if the relation between any two adjacent timestamps in the 10 timestamps is a continuous relation, the 10 timestamps are stored in a continuous timestamp sequence in the following way: and storing the 1 st time stamp in the 10 time stamps, storing the offset values of other time stamps and storing the number of the offset values in the continuous time stamp sequence.
The second relationship is: the relation between the 10 th timestamp and/or the 1 st timestamp in the 10 timestamps and the adjacent timestamps is a discontinuous relation, and the relation between other timestamps is a continuous relation, then the 10 th timestamp and/or the 1 st timestamp is stored separately, and other timestamps can be stored in a continuous timestamp sequence, and the storage mode is as follows: if the stored timestamps of the 1 st sequence among the timestamps and the offset values of the other sequences, for example, the other timestamps are from the 2 nd timestamp to the 9 th timestamp, the offset values of the 2 nd timestamp, the 3 rd timestamp to the 9 th timestamp are stored in the continuous timestamp sequence, and the number of the offset values is stored.
The third relationship is: the relation between the other timestamps except the 10 th timestamp and the 1 st timestamp among the 10 timestamps and the adjacent timestamps is a discontinuous relation, for example, the relation between the 3 rd timestamp and the 8 th timestamp among the 10 timestamps and the adjacent timestamps is a discontinuous relation, and the relation between the other adjacent timestamps is a continuous relation, then the three part of the timestamps divided by the 3 rd timestamp and the 8 th timestamp are respectively regarded as a continuous timestamp sequence, i.e. the 1 st timestamp and the 2 nd timestamp constitute a continuous timestamp sequence, the 4 th timestamp to the 7 th timestamp constitute a continuous timestamp sequence, the 9 th timestamp and the 10 th timestamp constitute a continuous timestamp sequence, and for the three continuous timestamp sequences, any continuous timestamp sequence is stored according to the description in the second relation, and storing the 3 rd time stamp and the 8 th time stamp in independent time stamp sequences, for example, storing the 3 rd time stamp and the 8 th time stamp in an independent time stamp sequence respectively, and storing the number of deviation values corresponding to each continuous time stamp sequence.
As can be seen from the foregoing technical solution, if the relationship between the ith timestamp and the (i-1) th timestamp is a discontinuous relationship and the ith timestamp is the nth timestamp, the ith timestamp is separately stored, if the relationship between the ith timestamp and the (i-1) th timestamp is not a continuous relationship and the ith timestamp is not the nth timestamp, the (1) th timestamp to the (i-1) th timestamp in the original timestamp sequence can be stored based on the relationship between the timestamps, and there is a case where an offset value of some timestamps is stored when the offset value is stored based on the relationship between the timestamps, so that the storage space occupied by the timestamps can be reduced, the timestamps are not lost, and the integrity and the authenticity of the timestamps are improved.
Referring to fig. 3, a flowchart of a data restoring method according to an embodiment of the present invention is shown, configured to restore timestamps in a timestamp sequence, where in detail, the data restoring method shown in fig. 3 may include the following steps:
s201: the identifier in the time stamp sequence is acquired, wherein the time stamp sequence is a sequence obtained by processing the original time stamp sequence based on the data storage method, and the identifier in the time stamp sequence can be acquired based on the setting of the identifier position by the data storage method, and the identifier can be acquired from the 1 st bit by setting the 1 st bit in the sequence as the identifier by the data storage method.
S202: if the value of the identifier in the timestamp sequence indicates that the timestamp sequence is a continuous timestamp sequence, acquiring fields which represent the 1 st timestamp, represent the deviation values from the 2 nd timestamp to the e nd timestamp and represent the number of the deviation values in the continuous timestamp sequence, and acquiring the 1 st timestamp to the e th timestamp based on the fields which represent the 1 st timestamp, represent the deviation values from the 2 nd timestamp to the e nd timestamp and represent the number of the deviation values, wherein e-1 is the number of the deviation values recorded by the continuous timestamp sequence.
One possible way in which the value of the identifier in the timestamp sequence indicates that the timestamp sequence is a continuous timestamp sequence is: based on the identifier in the timestamp sequence, the value of the identifier is obtained, if the value of the identifier meets a first threshold, the timestamp sequence is a continuous timestamp sequence, if the first threshold may be 1, if the value of the identifier is 1, the timestamp sequence is a continuous timestamp sequence, the first threshold may be determined according to practical application, and the value of the first threshold is not limited in this embodiment.
If the time stamp sequence is a continuous time stamp sequence, acquiring fields which are stored in the continuous time stamp sequence and represent the 1 st time stamp, the 2 nd to e th time stamps and offset values respectively, and acquiring data from the fields to restore the data, wherein the 1 st time stamp is acquired by N-ary operation, the 1 st time stamp is restored by binary operation if the continuous time stamp sequence is stored in binary, and the 2 nd time stamp and the e th time stamp are restored based on the offset values and tn-1+ [ delta ] t + dn (N > < 2).
S203: and if the value of the identifier in the time stamp sequence indicates that the time stamp sequence is the independent time stamp sequence, calculating to obtain the time stamp recorded in the independent time stamp sequence.
One possible way in which the value of the identifier in the timestamp sequence indicates that the timestamp sequence is an independent timestamp sequence is: based on the identifier in the timestamp sequence, the value of the identifier is obtained, if the value of the identifier meets a second threshold, the timestamp sequence is an independent timestamp sequence, if the second threshold is 0, if the value of the identifier is 0, the timestamp sequence is an independent timestamp sequence, the second threshold may be determined according to practical application, and the value of the second threshold is not limited in this embodiment.
One possible way to calculate the timestamps in the independent timestamp sequences is to: and restoring the timestamp of the data stored in any storage unit in the independent timestamp sequence through N-system operation, and restoring the timestamp through binary operation if the independent timestamp sequence adopts binary storage.
According to the technical scheme, if the value of the identifier in the time stamp sequence indicates that the time stamp sequence is a continuous time stamp sequence, the time stamp sequence is obtained by processing the original time stamp sequence through the data storage method, the fields indicating the 1 st time stamp, the deviation values from the 2 nd time stamp to the e nd time stamp and the number of the deviation values in the continuous time stamp sequence are obtained, the 1 st time stamp to the e th time stamp are obtained based on the fields indicating the 1 st time stamp, the deviation values from the 2 nd time stamp to the e nd time stamp and the number of the deviation values, and the time stamps recorded in the independent time stamp sequence are obtained by calculation if the value of the identifier in the time stamp sequence indicates that the time stamp sequence is an independent time stamp sequence, so that the time stamps recorded in the time stamp sequence are restored.
While, for purposes of simplicity of explanation, the foregoing method embodiments have been described as a series of acts or combination of acts, it will be appreciated by those skilled in the art that the present invention is not limited by the illustrated ordering of acts, as some steps may occur in other orders or concurrently with other steps in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
Corresponding to the above method embodiments, an embodiment of the present invention provides a data storage device, whose schematic structural diagram is shown in fig. 4, and the data storage device may include: a first obtaining module 11, a first return execution module 12 and a first storage module 13.
The first obtaining module 11 is configured to obtain an ith timestamp in the original timestamp sequence, where i is any number from 2 to n, and n is a total number of timestamps in the original timestamp sequence. It can be understood that: the sequence of the timestamps in the original timestamp sequence is from 1 to n, but in the actual storage process, the timestamps may be sequentially obtained from the 2 nd timestamp of the original timestamp sequence to the last timestamp of the original timestamp sequence, and any timestamp between the 2 nd timestamp and the last timestamp is obtained only once, and each timestamp is processed, so the reason for obtaining from the 2 nd timestamp is described in the method embodiment.
The first return execution module 12 is configured to add 1 to i and trigger the first obtaining module 11 to continue to obtain other timestamps in the original timestamp sequence if the relationship between the ith timestamp and the (i-1) th timestamp is a continuous relationship and the ith timestamp is not the nth timestamp.
In this embodiment, one possible way for the first return execution module 12 to determine the relationship between the ith timestamp and the (i-1) th timestamp is as follows: obtaining an ith time stamp and an ith-1 time stamp, obtaining an offset value (for convenience of description, marked as an ith offset value) between the ith time stamp and the ith-1 time stamp based on the ith time stamp and the ith-1 time stamp, if the ith offset value has continuity, determining that the relationship between the ith time stamp and the ith-1 time stamp is a continuous relationship, and if the ith offset value does not have continuity, determining that the relationship between the ith time stamp and the ith-1 time stamp is a discontinuous relationship. For the determination of whether the ith deviation value has continuity and the determination of whether the ith timestamp is the nth timestamp, please refer to the method embodiment, which will not be described further.
A first storing module 13, configured to store the 1 st timestamp, the offset value from the 2 nd timestamp to the nth timestamp, and the number of stored offset values in the original timestamp sequence if the relationship between the ith timestamp and the (i-1) th timestamp is a continuous relationship and the ith timestamp is the nth timestamp.
In this embodiment, one possible way to store the offset values and the number of stored offset values of the 1 st timestamp, the 2 nd timestamp to the nth timestamp in the original timestamp sequence is as follows: and storing the 1 st time stamp, the 2 nd time stamp to the nth time stamp and the deviation value number into the continuous time stamp sequence according to the sequence of the 1 st time stamp to the nth time stamp in the original time stamp sequence.
That is, with respect to the original time stamp sequence, each memory cell in the original time stamp sequence stores one time stamp, while the 1 st memory cell in the continuous time stamp sequence stores the 1 st time stamp, and the other memory cells store the offset value of the time stamp, and the content stored by each memory cell in the continuous time stamp sequence is still in the order of the 1 st to nth time stamps in the original time stamp sequence, and the number of offset values is stored in one memory cell in the continuous time stamp sequence.
Wherein the deviation value of the xth timestamp from the 2 nd timestamp to the nth timestamp is: an offset value between the xth timestamp and the xth-1 timestamp, or an offset value between the xth timestamp and the 1 st timestamp, where x is any number from 2 to n, is described with reference to the method embodiment, which is not described again.
In addition, in order to facilitate determining whether current data is data in a continuous time stamp sequence or not during data restoration, the continuous time stamp sequence may be marked by an identifier, for example, the 1 st bit in the continuous time stamp sequence is a value of the identifier, the value of the identifier is used to indicate that all relationships between time stamps stored in the continuous time stamp sequence are continuous relationships, for example, when the value of the identifier is 1, it indicates that the continuous time stamp sequence and all relationships between time stamps stored in the continuous time stamp sequence are continuous relationships, a time stamp may be restored for data stored in the 2 nd to nth storage units in a manner of tn-1 +/Δ t + dn (n >) 2, dn is an offset value corresponding to the nth time stamp stored in the nth storage unit, Δ t is a sampling interval, the sampling interval may also be stored in a sequence of consecutive time stamps, see the description of the method embodiment for storing the offset value and the sampling interval.
Known from the technical scheme, by acquiring the ith timestamp in the original timestamp sequence, if the relationship between the ith timestamp and the (i-1) th timestamp is a continuous relationship and the ith timestamp is not the nth timestamp, adding 1 to i and returning to acquire the ith timestamp in the original timestamp sequence, if the relationship between the ith timestamp and the (i-1) th timestamp is a continuous relationship and the ith timestamp is the nth timestamp, storing the 1 st timestamp in the original timestamp sequence, storing the offset values and the stored offset values of the 2 nd timestamp to the nth timestamp respectively, and restoring the unique timestamp corresponding to each offset value through the offset values, thereby reducing the occupation of a storage space by storing the offset values, and thus, when the offset values are stored, discarding the offset values is not required, and each time stamp in the original time stamp sequence can be accurately restored by storing the deviation value, so that the integrity and the authenticity of the time stamp are improved.
In contrast, if the relationship between the ith timestamp and the (i-1) th timestamp is a discontinuous relationship, the ith timestamp also needs to be stored, so this embodiment provides another structural schematic diagram of a data storage device, which explains a storage manner when the relationship between the ith timestamp and the (i-1) th timestamp is a discontinuous relationship, and the data storage device may include, on the basis of fig. 4: a second storage module 14, a second return execution module 15 and a third storage module 16, as shown in fig. 5.
A second storing module 14, configured to store the ith timestamp separately if the relationship between the ith timestamp and the (i-1) th timestamp is a discontinuous relationship, and the ith timestamp is an nth timestamp, for example, store the ith timestamp in an independent timestamp sequence.
Please refer to the description in the above method embodiment, which will not be further described herein, wherein the relationship between the ith timestamp and the (i-1) th timestamp is determined, and it is determined that the ith timestamp is not the nth timestamp.
Corresponding to the continuous time stamp sequence, for the independent time stamp sequence, a value of an identifier also needs to be configured, for example, a value of the identifier is recorded at the 1 st bit of the independent time stamp sequence, the value of the identifier is different from the value of the identifier in the continuous time stamp sequence, for example, the value of the identifier in the independent time stamp sequence is 0, so as to indicate that the relation between each stored time stamp in the independent time stamp sequence and other time stamps is a discontinuous relation.
Here, it should be noted that: if an original timestamp sequence is obtained as at least one continuous timestamp sequence and at least one independent timestamp sequence, and each independent timestamp sequence only stores one timestamp, when the continuous timestamp sequence and the independent timestamp sequence are stored, it needs to be stored according to the ordering of the timestamps in the original timestamp sequence in the continuous timestamp sequence and the independent timestamp sequence, for example, the original timestamp sequence is composed of 10 timestamps, where the 1 st timestamp to the 3 rd timestamp form one continuous timestamp sequence (described as continuous timestamp sequence 1), the 4 th timestamp is in one independent timestamp sequence (described as independent timestamp sequence 1), the 5 th timestamp sequence to the 10 th timestamp form one continuous timestamp sequence (described as continuous timestamp sequence 2, then the positional relationship of these three time stamp sequences at the time of storage is: the continuous time stamp sequence 1, the independent time stamp sequence 1 and the continuous time stamp sequence 2 can sequentially restore data in the three time stamp sequences during restoration, and the restored time stamps are ordered as follows: the 1 st, 2 nd, 10 th timestamps have the same ordering as the timestamps in the original sequence of timestamps.
If a plurality of timestamps are stored in one independent timestamp sequence, in order to make the sequence of the restored timestamps the same as the sequence of the timestamps in the original timestamp sequence, the sequences of the timestamps and the offset values in the original timestamp sequence need to be stored in the continuous timestamp sequence and the independent timestamp sequence, so that the restored timestamps can be arranged according to the sequences during restoration.
A second return execution module 15, configured to determine, if the relationship between the ith timestamp and the (i-1) th timestamp is a discontinuous relationship and the ith timestamp is not the nth timestamp, that the ith timestamp is the new 1 st timestamp in the original timestamp sequence, add 1 to i, and trigger the first obtaining module 11 to continue to obtain other timestamps in the original timestamp sequence.
That is, if the relationship between a timestamp in the original timestamp sequence and the previous timestamp is a discontinuous relationship, the timestamp is used as the new 1 st timestamp in the original timestamp sequence, then the other timestamps that are located after the new 1 st timestamp in the original timestamp sequence are sequentially acquired from the new 1 st timestamp, and the relationship between the new 1 st timestamp and the other timestamps that are located after the new 1 st timestamp is determined and stored based on the relationship.
For example, the relationship between the 5 th timestamp and the 4 th timestamp in the original timestamp sequence is a discontinuous relationship, and the 5 th timestamp is not the nth timestamp (i.e., the last timestamp), then the 5 th timestamp is taken as the new 1 st timestamp, and the other timestamps after the new 1 st timestamp, i.e., the 6 th timestamp to the nth timestamp, are continuously and sequentially acquired.
A third storage module 16, configured to store the 1 st timestamp to the i-1 st timestamp in the original timestamp sequence based on a relationship between timestamps.
In this embodiment, the storage of the 1 st timestamp to the i-1 st timestamp in the original timestamp sequence based on the relationship between timestamps needs to be determined based on the value of i, specifically: if the value of i is equal to 2, the 1 st timestamp in the original timestamp sequence is stored separately.
If the value of i is greater than 2, if a continuous time stamp sequence formed by mutually adjacent time stamps with a continuous relation exists in the original time stamp sequence, storing the 1 st time stamp in the continuous time stamp sequence, storing the deviation value from the 2 nd time stamp to the m th time stamp and the number of the stored deviation values, wherein m-1 is the number of the deviation values in the continuous time stamp sequence.
That is, the value of i is greater than 2, and if the relationship between a plurality of timestamps that are consecutive to each other in the original timestamp sequence is a consecutive relationship, the plurality of timestamps are considered to form a consecutive timestamp sequence. For example, in the 1 st to i-1 th timestamps of the original timestamp sequence, the relationship between any two adjacent timestamps is a continuous relationship, and a continuous timestamp sequence is formed according to the j to j + a timestamps (where a is a natural number greater than or equal to 1), then for this continuous timestamp sequence, the j timestamp is used as the 1 st timestamp, the offset values and the stored offset value numbers of the other timestamps are stored in the continuous timestamp sequence, and for the obtaining manner of the offset values of the other timestamps, please refer to the description in the above method embodiment.
If the value of i is greater than 2, if the relationship between the jth timestamp and the jth-1 timestamp in the original timestamp sequence is a discontinuous relationship and the relationship between the jth timestamp and the (j + 1) th timestamp in the original timestamp sequence is a discontinuous relationship, the jth timestamp in the original timestamp sequence is separately stored. For example, the jth timestamp may be stored in an independent timestamp sequence, and for the description of the independent timestamp sequence, refer to the related description in the above method embodiment. Specifically, please refer to the above method embodiments, which are not described herein again.
An embodiment of the present invention further provides a data recovery apparatus, a structure of which is shown in fig. 6, and the data recovery apparatus may include: a second obtaining module 21, a first restoring module 22 and a second restoring module 23.
The second obtaining module 21 is configured to obtain an identifier in a time stamp sequence, where the time stamp sequence is a sequence obtained by processing an original time stamp sequence based on the data storage device, and the identifier in the time stamp sequence can be obtained based on a setting of the data storage device to a location of the identifier, and the identifier can be obtained from the 1 st bit if the data storage device sets the 1 st bit in the sequence as the identifier.
A first restoring module 22, configured to, if a value of an identifier in the timestamp sequence indicates that the timestamp sequence is a continuous timestamp sequence, obtain fields indicating a 1 st timestamp, offset values indicating respective 2 nd to nth timestamps, and a number of the offset values in the continuous timestamp sequence, and obtain the 1 st to e-th timestamps based on the fields indicating the 1 st timestamp, the offset values indicating respective 2 nd to e-th timestamps, and the number of the offset values, where e-1 is the number of the offset values recorded by the continuous timestamp sequence.
One possible way in which the value of the identifier in the timestamp sequence indicates that the timestamp sequence is a continuous timestamp sequence is: based on the identifier in the timestamp sequence, the value of the identifier is obtained, if the value of the identifier meets a first threshold, the timestamp sequence is a continuous timestamp sequence, if the first threshold may be 1, if the value of the identifier is 1, the timestamp sequence is a continuous timestamp sequence, the first threshold may be determined according to practical application, and the value of the first threshold is not limited in this embodiment.
If the time stamp sequence is a continuous time stamp sequence, acquiring fields for storing the 1 st time stamp, the 2 nd to e th time stamps and the number of stored offset values, and acquiring data from the fields for restoring, wherein the fields are acquired by N-ary operation for the 1 st time stamp, the 1 st time stamp can be restored by binary operation if the continuous time stamp sequence is stored in binary, and the 2 nd and e-th time stamps can be restored based on the offset values and tn-1+ [ delta ] t + dn (N > [ 2 ]).
The second restoring module 23 is configured to calculate to obtain a timestamp recorded in the independent timestamp sequence if the value of the identifier in the timestamp sequence indicates that the timestamp sequence is the independent timestamp sequence. One possible way in which the value of the identifier in the timestamp sequence indicates that the timestamp sequence is an independent timestamp sequence is: based on the identifier in the timestamp sequence, the value of the identifier is obtained, if the value of the identifier meets a second threshold, the timestamp sequence is an independent timestamp sequence, if the second threshold is 0, if the value of the identifier is 0, the timestamp sequence is an independent timestamp sequence, the second threshold may be determined according to practical application, and the value of the second threshold is not limited in this embodiment.
One possible way to calculate the timestamps in the independent timestamp sequences is to: and restoring the timestamp of the data stored in any storage unit in the independent timestamp sequence through N-system operation, and restoring the timestamp through binary operation if the independent timestamp sequence adopts binary storage.
According to the technical scheme, if the value of the identifier in the time stamp sequence indicates that the time stamp sequence is a continuous time stamp sequence, the time stamp sequence is obtained by processing the original time stamp sequence through the data storage method, the fields indicating the 1 st time stamp, the deviation values from the 2 nd time stamp to the e nd time stamp and the number of the deviation values in the continuous time stamp sequence are obtained, the 1 st time stamp to the e th time stamp are obtained based on the fields indicating the 1 st time stamp, the deviation values from the 2 nd time stamp to the e nd time stamp and the number of the deviation values, and the time stamps recorded in the independent time stamp sequence are obtained by calculation if the value of the identifier in the time stamp sequence indicates that the time stamp sequence is an independent time stamp sequence, so that the time stamps recorded in the time stamp sequence are restored.
It should be noted that, in the present specification, the embodiments are all described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. For the device-like embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (8)

1. A method of data storage, the method comprising:
acquiring an ith timestamp in an original timestamp sequence, wherein i is any number from 2 to n, and n is the total number of timestamps in the original timestamp sequence, wherein n is a positive integer greater than or equal to 2;
if the relation between the ith timestamp and the (i-1) th timestamp is a continuous relation and the ith timestamp is not the nth timestamp, adding 1 to the i and returning to execute the step of acquiring the ith timestamp in the original timestamp sequence;
if the relation between the ith timestamp and the (i-1) th timestamp is a continuous relation, and the ith timestamp is the nth timestamp, storing the 1 st timestamp in the original timestamp sequence, storing the deviation values of the 2 nd timestamp to the nth timestamp, storing the number of the deviation values and sampling intervals, wherein the two adjacent sampling intervals are the same;
or,
if the relation between the ith timestamp and the (i-1) th timestamp is a discontinuous relation, and the ith timestamp is the nth timestamp, independently storing the ith timestamp;
if the relation between the ith timestamp and the (i-1) th timestamp is a discontinuous relation and the ith timestamp is not the nth timestamp, determining the ith timestamp as a new 1 st timestamp in the original timestamp sequence, adding 1 to i, and returning to execute the step of obtaining the ith timestamp in the original timestamp sequence;
storing the 1 st timestamp to the i-1 st timestamp in the original timestamp sequence based on a relationship between timestamps.
2. The method of claim 1, wherein the storing of the 1 st through i-1 st timestamps in the original sequence of timestamps based on a relationship between timestamps comprises:
if the value of i is equal to 2, independently storing the 1 st time stamp in the original time stamp sequence;
if the value of i is greater than 2, if a continuous time stamp sequence composed of time stamps which are in a continuous relationship and adjacent to each other exists in the original time stamp sequence, storing the 1 st time stamp in the continuous time stamp sequence, storing the deviation value and the number of the stored deviation value from the 2 nd time stamp to the m th time stamp, and m-1 is the number of the deviation value in the continuous time stamp sequence, if the relationship between the jth time stamp and the jth-1 time stamp in the original time stamp sequence is a discontinuous relationship and the relationship between the jth time stamp and the +1 th time stamp is a discontinuous relationship, separately storing the jth time stamp in the original time stamp sequence, wherein m and j are positive integers greater than or equal to 2.
3. The method of claim 1, wherein storing the offset values and the number of stored offset values for each of the 1 st timestamp, the 2 nd timestamp through the nth timestamp in the original sequence of timestamps comprises:
storing the 1 st time stamp, the 2 nd time stamp to the nth time stamp and the deviation value number into the continuous time stamp sequence according to the sequence of the 1 st time stamp to the nth time stamp in the original time stamp sequence;
the deviation value of the xth timestamp from the 2 nd timestamp to the nth timestamp is as follows: an offset value between the xth timestamp and the (x-1) th timestamp, or an offset value between the xth timestamp and the (1) th timestamp, wherein x is any number from 2 to n.
4. The method according to claim 3, wherein the 1 st bit in the consecutive timestamp sequence is a value of an identifier, and the value of the identifier is used to indicate that the relationships between the timestamps stored in the consecutive timestamp sequence are all consecutive relationships.
5. The method of claim 3, further comprising: storing the sampling intervals of the original sequence of time stamps in the sequence of consecutive time stamps.
6. A method for data reduction, the method comprising:
acquiring an identifier in a time stamp sequence, wherein the time stamp sequence is a sequence obtained by processing an original time stamp sequence based on the method of any one of claims 1 to 5;
if the value of the identifier in the timestamp sequence indicates that the timestamp sequence is a continuous timestamp sequence, acquiring fields representing 1 st timestamp, offset values representing the 2 nd timestamp to the e nd timestamp, the number of the offset values and a sampling interval in the continuous timestamp sequence, and acquiring the 1 st timestamp to the e th timestamp based on the fields representing the 1 st timestamp, the offset values representing the 2 nd timestamp to the e nd timestamp, the number of the offset values and the sampling interval, wherein e-1 is the number of the offset values recorded by the continuous timestamp sequence, and e is a positive integer greater than or equal to 2;
and if the value of the identifier in the time stamp sequence indicates that the time stamp sequence is the independent time stamp sequence, calculating to obtain the time stamp recorded in the independent time stamp sequence.
7. A data storage device, characterized in that the device comprises:
the device comprises a first obtaining module, a second obtaining module and a third obtaining module, wherein the first obtaining module is used for obtaining the ith time stamp in an original time stamp sequence, i is any number from 2 to n, and n is the total number of the time stamps in the original time stamp sequence, wherein n is a positive integer greater than or equal to 2;
a first return execution module, configured to add 1 to i and trigger the first obtaining module if a relationship between the ith timestamp and the (i-1) th timestamp is a continuous relationship and the ith timestamp is not the nth timestamp;
a first storage module, configured to store, if a relationship between the ith timestamp and the (i-1) th timestamp is a continuous relationship, and the ith timestamp is an nth timestamp, the 1 st timestamp in the original timestamp sequence, the offset value from the 2 nd timestamp to the nth timestamp, the number of stored offset values, and a sampling interval, where two adjacent sampling intervals are the same;
a second storage module, configured to store an ith timestamp separately if a relationship between the ith timestamp and an (i-1) th timestamp is a discontinuous relationship and the ith timestamp is an nth timestamp;
a second return execution module, configured to determine, if the relationship between the ith timestamp and the (i-1) th timestamp is a discontinuous relationship and the ith timestamp is not the nth timestamp, that the ith timestamp is a new 1 st timestamp in the original timestamp sequence, add 1 to i, and trigger the first obtaining module;
and the third storage module is used for storing the 1 st timestamp to the (i-1) th timestamp in the original timestamp sequence based on the relation between the timestamps.
8. An apparatus for data recovery, the apparatus comprising:
a second obtaining module, configured to obtain an identifier in a time stamp sequence, where the time stamp sequence is a sequence obtained by processing an original time stamp sequence based on the apparatus of claim 7;
a first restoring module, configured to, if a value of an identifier in the timestamp sequence indicates that the timestamp sequence is a continuous timestamp sequence, obtain a field indicating a 1 st timestamp, an offset value indicating each of a 2 nd timestamp to an e th timestamp, a number of the offset values, and a sampling interval in the continuous timestamp sequence, and obtain the 1 st timestamp to the e th timestamp based on the field indicating the number of the offset values and the sampling interval, where e-1 is the number of the offset values recorded by the continuous timestamp sequence, and e is a positive integer greater than or equal to 2;
and the second restoring module is used for calculating the time stamp recorded in the independent time stamp sequence if the value of the identifier in the time stamp sequence indicates that the time stamp sequence is the independent time stamp sequence.
CN201811509080.8A 2018-12-11 2018-12-11 Data storage method, data restoration method and device Active CN109597588B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811509080.8A CN109597588B (en) 2018-12-11 2018-12-11 Data storage method, data restoration method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811509080.8A CN109597588B (en) 2018-12-11 2018-12-11 Data storage method, data restoration method and device

Publications (2)

Publication Number Publication Date
CN109597588A CN109597588A (en) 2019-04-09
CN109597588B true CN109597588B (en) 2020-09-04

Family

ID=65961616

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811509080.8A Active CN109597588B (en) 2018-12-11 2018-12-11 Data storage method, data restoration method and device

Country Status (1)

Country Link
CN (1) CN109597588B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110688362A (en) * 2019-08-27 2020-01-14 浙江浙大中控信息技术有限公司 Data sectional type storage method based on time stamp
WO2021226922A1 (en) * 2020-05-14 2021-11-18 深圳市欢太科技有限公司 Data compression method, apparatus and device, and readable storage medium
CN112419698B (en) * 2020-10-26 2022-05-17 浙江正泰仪器仪表有限责任公司 Electric energy meter data transmission method, system and device based on distribution line message specification

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104035956A (en) * 2014-04-11 2014-09-10 江苏瑞中数据股份有限公司 Time-series data storage method based on distributive column storage
CN106055430A (en) * 2016-05-27 2016-10-26 北京奇虎科技有限公司 System backup updating method and device for PTZ camera

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100259631A1 (en) * 2007-10-26 2010-10-14 Fujifilm Corporation Data compression apparatus, data compression program and image-taking apparatus
CN102103630B (en) * 2010-12-08 2013-06-05 中国联合网络通信集团有限公司 Data compression method and device as well as data decompression method and device
CN103914449B (en) * 2012-12-29 2017-06-16 上海可鲁系统软件有限公司 A kind of multi-source time series data compression and storage method
CN104281616B (en) * 2013-07-10 2017-10-13 北京旋极信息技术股份有限公司 Data processing method
CN106549673B (en) * 2016-10-27 2020-02-21 深圳市金证科技股份有限公司 Data compression method and device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104035956A (en) * 2014-04-11 2014-09-10 江苏瑞中数据股份有限公司 Time-series data storage method based on distributive column storage
CN106055430A (en) * 2016-05-27 2016-10-26 北京奇虎科技有限公司 System backup updating method and device for PTZ camera

Also Published As

Publication number Publication date
CN109597588A (en) 2019-04-09

Similar Documents

Publication Publication Date Title
CN109597588B (en) Data storage method, data restoration method and device
CN107591800B (en) Method for predicting running state of power distribution network with distributed power supply based on scene analysis
CN106936778B (en) Method and device for detecting abnormal website traffic
CN109215338B (en) Gridding-based Beidou gps vehicle track management system and method thereof
CN106202280B (en) Information processing method and server
CN112559592B (en) Real-time data processing method, device and equipment
CN108664603B (en) Method and device for repairing abnormal aggregation value of time sequence data
CN107704373B (en) Data processing method and device
CN110543472A (en) data reconciliation method and related device
CN111158999B (en) Formatting time calculation method and device
CN114817645A (en) Time sequence data storage and reading method, device, equipment and storage medium
CN106250499B (en) Video pair mining method and device
CN109344164B (en) Data storage method and device
CN108491432B (en) Electric power system accumulated quantity storage and extraction method based on message abstract, electronic equipment and storage medium
CN110766232A (en) Dynamic prediction method and system thereof
CN105022753A (en) Data storage method and system
CN112445835B (en) Business data processing method and device, network management server and storage medium
CN117666926A (en) Data storage method and device and electronic equipment
CN108460495B (en) Data processing method and device
CN107995014A (en) Method and device based on warning information discovery feature topology
JP6244681B2 (en) Compensation method for accumulated time series data loss
CN113568898A (en) Electric power data leakage point completion method, device, equipment and readable storage medium
CN110245844B (en) Abnormal index detection method and device
CN113190554A (en) Method for generating primary key and distributed system
CN109255579B (en) Data index determination method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
PE01 Entry into force of the registration of the contract for pledge of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: The invention relates to a data storage method, a data restoration method and a device

Effective date of registration: 20210615

Granted publication date: 20200904

Pledgee: The Bank of Hangzhou branch of Limited by Share Ltd. sea park

Pledgor: ZHEJIANG ZHONGZHIDA TECHNOLOGY Co.,Ltd.

Registration number: Y2021980004734

PC01 Cancellation of the registration of the contract for pledge of patent right
PC01 Cancellation of the registration of the contract for pledge of patent right

Date of cancellation: 20220713

Granted publication date: 20200904

Pledgee: The Bank of Hangzhou branch of Limited by Share Ltd. sea park

Pledgor: ZHEJIANG ZHONGZHIDA TECHNOLOGY Co.,Ltd.

Registration number: Y2021980004734

PE01 Entry into force of the registration of the contract for pledge of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: A data storage method, data restore method and device

Effective date of registration: 20220720

Granted publication date: 20200904

Pledgee: The Bank of Hangzhou branch of Limited by Share Ltd. sea park

Pledgor: ZHEJIANG ZHONGZHIDA TECHNOLOGY Co.,Ltd.

Registration number: Y2022980010803