Summary of the invention
In view of this, being used for the purpose of the present invention is to provide a kind of date storage method, data restoration method and device
By storage time stab in deviation come storing data, and by restore deviation obtain data.Technical solution is as follows:
The present invention provides a kind of date storage method, which comprises
I-th of timestamp in original time stamp sequence is obtained, i is from 2 any one number into n, and n is described original
Timestamp sum in timestamp sequence;
If relationship between i-th of timestamp and (i-1)-th timestamp is serial relation, and i-th of the time
Stamp is not n-th of timestamp, then adds 1 return to execute the step of obtaining i-th of timestamp in original time stamp sequence i;
If relationship between i-th of timestamp and (i-1)-th timestamp is serial relation, and i-th of the time
Stamp is n-th of timestamp, then stores the 1st timestamp, the 2nd timestamp of storage to n-th in the original time stamp sequence
A respective deviation of timestamp and storage deviation number.
Preferably, the method also includes:
If relationship between i-th of timestamp and (i-1)-th timestamp is discontinuous relationship, and i-th of timestamp
It is n-th of timestamp, then individually stores i-th of timestamp;
If relationship between i-th of timestamp and (i-1)-th timestamp is discontinuous relationship, and i-th of timestamp
It is not n-th of timestamp, then the 1st new time being determined as i-th of timestamp in the original time stamp sequence
Stamp, and add 1 return to execute the step of obtaining i-th of timestamp in original time stamp sequence i;
To the 1st timestamp in the original time stamp sequence to (i-1)-th timestamp based on the pass between timestamp
System's storage.
Preferably, the 1st timestamp in the original time stamp sequence to (i-1)-th timestamp is based on the time
Relationship storage between stamp includes:
If the value of i is equal to 2, the 1st timestamp in the original time stamp sequence is individually stored;
If the value of i is greater than 2, if there are relationship being serial relation in the original time stamp sequence and adjacent to each other
The continuous time of timestamp composition stabs sequence, then stores the 1st timestamp in the continuous time stamp sequence, stores the 2nd
For timestamp to the respective deviation of m-th of timestamp and storage deviation number, m-1 is the continuous time to stab sequence large deviations
It is worth number, if the relationship between -1 timestamp of j-th of timestamp in the original time stamp sequence and jth is discontinuous
Relationship and relationship between+1 timestamp of jth is discontinuous relationship, then individually store in the original time stamp sequence
J-th of timestamp.
Preferably, the 1st timestamp in the storage original time stamp sequence, the 2nd timestamp of storage to n-th
A respective deviation of timestamp and storage deviation number include:
Sequence according to the 1st timestamp to n-th of timestamp in the original time stamp sequence, storage the 1st
A timestamp, the 2nd timestamp of storage to the respective deviation of n-th of timestamp and storage deviation number to continuous time stab
In sequence;
The deviation of 2nd timestamp x-th of timestamp into n-th of timestamp are as follows: x-th of timestamp and xth-
The deviation between deviation or x-th of timestamp and the 1st timestamp between 1 timestamp, x be from 2 into n
Any one number.
Preferably, the 1st in the continuous time stamp sequence is the value of identifier, and the value of the identifier is used for
Show that the relationship between the timestamp of the continuous time stamp sequence storage is serial relation.
Preferably, the method also includes: the sampling interval of the original time stamp sequence is stored in the consecutive hours
Between stab sequence in.
The present invention provides a kind of data restoration method, which comprises
Acquisition time stabs the identifier in sequence, wherein the timestamp sequence is based on claim 1 to 6 any one
The sequence that the method handles original time stamp sequence;
If the value of the identifier in the timestamp sequence shows that the timestamp sequence is continuous time to stab sequence,
It obtains and indicates the 1st timestamp in the continuous time stamp sequence, indicate that the 2nd timestamp is respective partially to e-th of timestamp
Difference and the field for indicating deviation number, and when based on the 2nd the 1st timestamp of expressions, expression timestamp to e-th
Between stab respective deviation and indicate the field of deviation number, obtain the 1st timestamp to e-th of timestamp, e-1 is the company
The deviation number of continuous timestamp sequential recording;
If the value of the identifier in the timestamp sequence shows that the timestamp sequence is that independent time stabs sequence,
The timestamp recorded in the independent time stamp sequence is calculated.
The present invention provides a kind of data storage device, and described device includes:
First obtains module, and for obtaining i-th of timestamp in original time stamp sequence, i is any into n from 2
One number, n are timestamp sum in the original time stamp sequence;
First returns to execution module, if the relationship between i-th of timestamp and (i-1)-th timestamp is continuous
Relationship, and i-th of timestamp is not n-th of timestamp, then adds 1 to i and trigger the first acquisition module;
First memory module, if being continuous close for the relationship between i-th of timestamp and (i-1)-th timestamp
System, and i-th of timestamp is n-th of timestamp, then stores the in the original time stamp sequence the 1st timestamp, deposits
The 2nd timestamp is stored up to the respective deviation of n-th of timestamp and storage deviation number.
Preferably, described device further include:
Second memory module, if being discontinuous close for the relationship between i-th of timestamp and (i-1)-th timestamp
System, and i-th of timestamp is n-th of timestamp, then individually stores i-th of timestamp;
Second returns to execution module, if being not connect for the relationship between i-th of timestamp and (i-1)-th timestamp
Continuous relationship, and i-th of timestamp is not n-th of timestamp, then i-th of timestamp is determined as the original time stamp sequence
The 1st new timestamp in column, and is added by 1 and triggers described first by i and obtains module;
Third memory module, for the 1st timestamp in the original time stamp sequence to (i-1)-th timestamp base
Relationship storage between timestamp.
The present invention provides a kind of data recovery device, and described device includes:
Second obtains module, for the identifier in acquisition time stamp sequence, wherein the timestamp sequence is based on power
The sequence that benefit requires 8 to 9 any one described devices to handle original time stamp sequence;
First recovery module is if the value for the identifier in the timestamp sequence shows the timestamp sequence
Continuous time stabs sequence, then obtaining indicates the 1st timestamp, indicates the 2nd timestamp to e in the continuous time stamp sequence
A respective deviation of timestamp and the field for indicating deviation number, and based on the 1st timestamp of the expression, expression the 2nd
A timestamp obtains the 1st timestamp to e to the field of the respective deviation of e-th of timestamp and expression deviation number
A timestamp, e-1 are the deviation number for the continuous time stabbing sequential recording;
Second recovery module is if the value for the identifier in the timestamp sequence shows the timestamp sequence
Independent time stabs sequence, then the timestamp recorded in the independent time stamp sequence is calculated.
From above-mentioned technical proposal it is found that by obtaining i-th of timestamp in original time stamp sequence, if i-th of time
Relationship between stamp and (i-1)-th timestamp is serial relation and i-th of timestamp is not that n-th of timestamp then adds 1 return to i
I-th of the timestamp obtained in original time stamp sequence is executed, if the relationship between i-th of timestamp and (i-1)-th timestamp
For serial relation and i-th of timestamp is that n-th of timestamp then stores the 1st timestamp in original time stamp sequence, storage
2nd timestamp can be restored each to the respective deviation of n-th of timestamp and storage deviation number by deviation
The corresponding unique time stamps of deviation, being achieved in by way of storing deviation reduces the occupancy of memory space, in this way
It does not need to abandon deviation when storing deviation, and makes original time stamp sequence by way of storing deviation
Each timestamp in column can accurate reproduction, to improve the integrality and authenticity of timestamp.
Specific embodiment
Because of various fields, as the real time data of industrial control field be generated by collector timing sampling, so
Between the corresponding timestamp of real time data often it is regular be incremented by, as theoretically meet between the corresponding timestamp of real time data as
Lower feature:
T1, t2=t1+ △ t, t3=t2+ △ t ... ..tn=tn-1+ △ t, wherein △ t is the sampling interval, thus can be total
Bear the theory rule followed between two neighboring timestamp in the timestamp sequence being made of multiple timestamps are as follows: tn=tn-1
+ △ t (n=2,3 ...).
But actually due to the acquisition precision of collector and other a variety of causes, each timestamp will appear to a certain degree
Deviation, the value of the timestamp in timestamp sequence are as follows: t1+d1, t2=t1+ △ t+d2, t3=t2+ △ t+d3 ...,
Tn=tn-1+ △ t+dn (n >=2), therefore followed on theoretical regular basis between two neighboring timestamp in timestamp sequence
Rule are as follows:
Tn=tn-1+ △ t+dn (n >=2).Wherein d2, d3 ..., dn is deviation, if collector is uninterruptedly adopted
Collection, then the value of △ t+dn can fluctuate above or below sampling interval △ t.
Assuming that each timestamp is indicated using int64 when storage time stabs sequence, then each timestamp occupies 8
Byte, this memory space for resulting in timestamp sequence to occupy can be very big, and inventor can use for reference above-mentioned tn=tn- by observation
The rule of 1+ △ t+dn (n >=2) replaces timestamp using deviation, why using deviation replace timestamp be because are as follows:
For deviation for timestamp, the value of deviation will be much smaller than the value of timestamp, in this way can when storing deviation
It to use lesser memory space, such as uses but is not limited to store using 2 bytes, so that the storage that timestamp sequence occupies
Space is greatly reduced, and is based on this thinking, and the present invention provides a kind of date storage method, data restoration method and device.
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is
A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art
Every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
Referring to Fig. 1, it illustrates a kind of flow chart of date storage method provided in an embodiment of the present invention, for reducing
The memory space that timestamp sequence occupies, may comprise steps of:
S101: obtaining i-th of timestamp in original time stamp sequence, and i is from 2 any one number into n, and n is original
Timestamp sum in beginning timestamp sequence.It is to be understood that in original time stamp sequence each timestamp be ordered as from 1 to
N, but during actual storage each timestamp can be successively obtained since the 2nd timestamp of original time stamp sequence
Until arrive original time stamp sequence the last one timestamp, while the 2nd timestamp between the last one timestamp appoint
One timestamp only obtains once, is performed both by subsequent step to each timestamp.Why can be obtained since the 2nd timestamp
Take is because being and the 1st timestamp based on the relationship between i-th of timestamp and (i-1)-th timestamp in follow-up storage
It is first in original time stamp sequence, the timestamp before the 1st timestamp is not present for the 1st timestamp,
And it also can determine the storage mode of the 1st timestamp by the relationship of the 1st timestamp and the 2nd timestamp.
It if included 10 timestamps in original time stamp sequence, is then successively obtained since the 2nd timestamp, until obtaining
When to the 10th timestamp, acquisition terminates, one timestamp of every acquisition, executes following steps to the timestamp currently got,
To judge the timestamp currently got and the relationship between its adjacent previous timestamp, and determined such as based on the relationship
What storage time stamp.
S102: if the relationship between i-th of timestamp and (i-1)-th timestamp is serial relation, and i-th of timestamp is not
It is n-th of timestamp, then adds 1 return to execute the step of obtaining i-th of timestamp in original time stamp sequence i.
In the present embodiment, judge a kind of feasible pattern of the relationship between i-th of timestamp and (i-1)-th timestamp
It is: obtains i-th of timestamp and (i-1)-th timestamp, i-th of timestamp and (i-1)-th timestamp is based on, when obtaining i-th
Between stab and (i-1)-th timestamp between deviation (being denoted as i-th of deviation in order to facilitate description), if i-th of deviation
With continuity, it is determined that the relationship between i-th of timestamp and (i-1)-th timestamp is serial relation, if i-th of deviation
Value does not have continuity, then the relationship between i-th of timestamp and (i-1)-th timestamp is discontinuous relationship.
Wherein judge whether i-th of deviation there is a kind of successional feasible pattern to be: whether judging i-th of deviation
In threshold range, if i-th of deviation, in threshold range, i-th of deviation has continuity, if i-th inclined
Difference is not in threshold range, then i-th deviation does not have a continuity, threshold range can be but not limited to [- 32768 ,+
32767], if therefore i-th of deviation be located in [- 32768 ,+32767], then confirm that i-th of deviation has continuity, it is no
Do not have continuity then.
A kind of feasible pattern for determining i-th of timestamp not and be n-th of timestamp is: obtaining the value of i, acquisition time stamp
Total n, judges whether i is greater than or equal to n, if i is greater than or equal to n, i-th of timestamp is n-th of timestamp, if i
Less than n, then i-th of timestamp is not n-th of timestamp.
It should be understood that adding 1 return to execute the step of obtaining i-th of timestamp in original time stamp sequence i is
Refer to: the relationship between i-th of timestamp and (i-1)-th timestamp is serial relation, then returns and obtain original time stamp sequence
In i+1 timestamp, relationship such as between the 5th timestamp and the 4th timestamp is serial relation, then continues to obtain
The 6th timestamp in original time stamp sequence.
S103: if the relationship between i-th of timestamp and (i-1)-th timestamp is serial relation, and i-th of timestamp is
N-th of timestamp then stores the 1st timestamp, the 2nd timestamp of storage to n-th of timestamp in original time stamp sequence
Respective deviation and storage deviation number.
In the present embodiment, it stores the 1st timestamp in original time stamp sequence, store the 2nd timestamp to n-th
A kind of feasible pattern of the respective deviation of timestamp and storage deviation number is: according to the 1st timestamp to n-th of time
The sequence in original time stamp sequence is stabbed, the 2nd the 1st timestamp of storage, storage timestamp are respective to n-th of timestamp
Deviation and storage deviation number are into continuous time stamp sequence.
That is, also saying relative to original time stamp sequence, each storage unit is stored in original time stamp sequence
One timestamp, and the 1st storage unit storage in continuous time stamp sequence is the 1st timestamp, other storage units
Storage be timestamp deviation, and in continuous time stamp sequence the content of each storage unit storage be still according to it is original when
Between stab sequence in the 1st timestamp to n-th of timestamp sequence.
The wherein deviation of the 2nd timestamp x-th of timestamp into n-th of timestamp are as follows: x-th of timestamp and xth-
The deviation between deviation or x-th of timestamp and the 1st timestamp between 1 timestamp, x be from 2 into n
Any one number.That is, each timestamp of the 2nd timestamp into n-th of timestamp has 1 corresponding deviation
Value such as obtains the 2nd timestamp and the respective deviation of n-th of timestamp by above-mentioned tn=tn-1+ △ t+dn (n >=2)
D2, d3 ..., dn, and it is based on d2, d3 ..., the sequence of dn is sequentially stored in continuous time stamp sequence, by tn=
Tn-1+ △ t+dn (n >=2) know that deviation is the deviation between -1 timestamp of x-th of timestamp and xth, may be used also certainly
To use other modes, such as deviation between x-th of timestamp and the 1st timestamp, i.e., on the basis of the 1st timestamp,
Deviation of the other times stamp relative to the 1st timestamp is calculated, or using being calculated on the basis of other times stamp, originally
Embodiment is not illustrating.
It should be understood that when storing the 1st timestamp in original time stamp sequence, the 2nd timestamp to n-th
Between while stab respective deviation, it is also desirable to store deviation number, deviation number can be passed through in data convert in this way
Determine the deviation stored in continuous time stamp sequence, if the timestamp t2 to t5 in original time stamp sequence is serial relation,
Then in continuous time stamp sequence while storage t2 respective to t5 deviation, also storage deviation number to consecutive hours
Between stab sequence in, this continuous time stab sequence in deviation number value be 4.
In order to whether be the data stabbed continuous time in sequence convenient for the current data of determination during data convert,
Continuous time stamp sequence can be marked by way of identifier, if the 1st in continuous time stamp sequence is mark
The value of symbol, the value of the identifier are used to show that the relationship between the timestamp of continuous time stamp sequence storage to be continuous
Relationship, for example, when identifier value be 1, be shown to be continuous time stamp sequence and continuous time stamp sequence storage timestamp it
Between relationship be serial relation, then the number stored for the 2nd storage unit into n-th of storage unit in data convert
Timestamp is restored according to the mode that tn=tn-1+ △ t+dn (n >=2) can be used, dn is then the n-th of n-th of storage unit storage
The corresponding deviation of a timestamp, △ t are the sampling interval.The byte for wherein storing the storage unit of deviation can be according to deviation
Depending on, if deviation needs to occupy 2 bytes or 4 bytes, then 2 bytes can be distributed for storage unit or 4 bytes are come
Deviation is stored, the byte of storage unit distribution is not defined herein, as long as being less than timestamp in original time stamp sequence
The byte of occupancy.
And it can be stabbed thus in continuous time from tn=tn-1+ △ t+dn (n >=2) it is found that needing △ t in reduction
The sampling interval is stored in sequence, which can store the last one storage unit in continuous time stamp sequence, i.e. phase
For original time stamp sequence, increase a storage unit to store the sampling interval, as shown in table 1.
A kind of storage mode of 1 continuous time of table stamp sequence
Certainly other storage modes, the deviation corresponding with the 2nd timestamp such as after the 1st timestamp can also be used
The sampling interval is stored between value, this present embodiment is not being illustrated, or the sampling interval is interacted using preparatory interactive mode,
In order to carry out data convert.For deviation number, it can store after the 1st timestamp and the 2nd time
It stabs between corresponding deviation, or is stored in other positions, the present embodiment is to the position of deviation number without limiting.
From above-mentioned technical proposal it is found that by obtaining i-th of timestamp in original time stamp sequence, if i-th of time
Relationship between stamp and (i-1)-th timestamp is serial relation and i-th of timestamp is not that n-th of timestamp then adds 1 return to i
I-th of the timestamp obtained in original time stamp sequence is executed, if the relationship between i-th of timestamp and (i-1)-th timestamp
For serial relation and i-th of timestamp is that n-th of timestamp then stores the 1st timestamp in original time stamp sequence, storage
2nd timestamp can be restored each to the respective deviation of n-th of timestamp and storage deviation number by deviation
The corresponding unique time stamps of deviation, being achieved in by way of storing deviation reduces the occupancy of memory space, in this way
It does not need to abandon deviation when storing deviation, and makes original time stamp sequence by way of storing deviation
Each timestamp in column can accurate reproduction, to improve the integrality and authenticity of timestamp.
Opposite, if the case where relationship between i-th of timestamp and (i-1)-th timestamp is discontinuous relationship, i-th
Timestamp is also required to be stored, and present embodiments provides the flow chart of another date storage method thus, when illustrating i-th
Between stab and (i-1)-th timestamp between relationship be discontinuous relationship when storage mode, base of the date storage method in Fig. 1
It may comprise steps of on plinth:
S104: if relationship between i-th of timestamp and (i-1)-th timestamp is discontinuous relationship, and i-th of timestamp
It is n-th of timestamp, then individually stores i-th of timestamp.
Wherein judge the relationship between i-th of timestamp and (i-1)-th timestamp and determines that i-th of timestamp is not n-th
A timestamp is identical as above-mentioned steps S102 implementation procedure and principle, is not repeating herein.But with step S102 difference
It is: if the relationship between two adjacent timestamps is discontinuous relationship and i-th of timestamp is n-th of timestamp, can incites somebody to action
I-th of timestamp individually stores, and such as i-th of timestamp is stored in an independent time stamp sequence, which stabs sequence
Column can only store one and the relationship of adjacent timestamp is the timestamp of discontinuous relationship, or store multiple and adjacent
The relationship of timestamp is the timestamp of discontinuous relationship.
It is corresponding with continuous time stamp sequence, independent time stamp sequence is also required to configure taking for an identifier for it
Value, such as value in the 1st record identifier of independent time stamp sequence, the value of the identifier and continuous time are stabbed in sequence
The value of identifier is different, if the value of identifier in independent time stamp sequence is 0, to show in independent time stamp sequence
It is discontinuous relationship that each timestamp of storage, which is with the relationship of other times stamp,.
Herein it should be understood that if an original time stamp sequence, obtain at least one continuous time stamp sequence and
At least one independent time stabs sequence, and each independent time stamp sequence only stores a timestamp, then in storage consecutive hours
Between stab sequence and independent time stamp sequence when, need according to continuous time stab sequence and independent time stamp sequence in timestamp in original
Sequence in beginning timestamp sequence stores, if original time stamp sequence is by 10 timestamps, wherein the 1st timestamp is to the 3rd
A timestamp forms a continuous time stamp sequence (being denoted as continuous time stamp sequence 1 for ease of description), and the 4th timestamp exists
(it is denoted as independent time stamp sequence 1 for ease of description) in one independent time stamp sequence, the 5th timestamp sequence is to the 10th
Timestamp form continuous time stamp sequence (be denoted as continuous time stamp sequence 2 for ease of description, then in storage this three
The positional relationship of a timestamp sequence are as follows: continuous time stabs sequence 1, independent time stamp sequence 1 and continuous time and stabs sequence 2, this
Sample can successively restore the data in these three timestamp sequences in reduction, the sequence of the timestamp after reduction are as follows:
1st timestamp, the 2nd timestamp ..., the 10th timestamp, sequence and the timestamp in original time stamp sequence
It sorts identical.
If multiple timestamps are stored in an independent time stamp sequence, in order to make the sequence of the timestamp restored
It is identical as the sequence of timestamp in original time stamp sequence, then it needs to stab in sequence and independent time stamp sequence in continuous time and deposit
The sequence of timestamp and deviation in original time stamp sequence is stored up, it in this way can be according to the sequence to reduction in reduction
Timestamp is arranged.
S105: if relationship between i-th of timestamp and (i-1)-th timestamp is discontinuous relationship, and i-th of timestamp
It is not n-th of timestamp, then i-th of timestamp is determined as the 1st new timestamp in original time stamp sequence, and to i
1 return is added to execute the step of obtaining i-th of timestamp in original time stamp sequence.
That is, the relationship between some timestamp in original time stamp sequence and its previous timestamp is not connect
Continuous relationship, then can using timestamp as the 1st new timestamp in original time stamp sequence, then from newly the 1st when
Between stamp start successively to obtain the other times stamp after being located at the 1st new timestamp in original time stamp sequence, and to new
The 1st timestamp and the other times stamp after the 1st new timestamp carry out the judgement of relationship and based on relationship
Storage.
For example, the relationship between the 5th timestamp and the 4th timestamp in original time stamp sequence is discontinuous closes
System, and the 5th timestamp is not n-th of timestamp (i.e. the last one timestamp), then using the 5th timestamp as the new the 1st
A timestamp, and continue successively to obtain the other times stamp after the 1st new timestamp, i.e., the 6th timestamp is to n-th
Timestamp.
S106: to the 1st timestamp in original time stamp sequence to (i-1)-th timestamp based on the pass between timestamp
System's storage.
In the present embodiment, timestamp is based on to the 1st timestamp in original time stamp sequence to (i-1)-th timestamp
Between relationship storage need the value based on i depending on, it is specific: if the value of i is equal to 2, individually to store original time stamp
The 1st timestamp in sequence.
If the value of i is greater than 2, if being serial relation and the time adjacent to each other there are relationship in original time stamp sequence
The continuous time of stamp composition stabs sequence, then stores the 1st timestamp in continuous time stamp sequence, stores the 2nd timestamp extremely
The respective deviation of m-th of timestamp and storage deviation number, m-1 are continuous time to stab sequence large deviations value number.
That is it is greater than 2 in the value of i, if between multiple timestamps continuous each other in original time stamp sequence
Relationship be serial relation, then be considered as this multiple timestamp and form continuous times stamp sequence.Such as original time stamp sequence
Into (i-1)-th timestamp, to+a timestamps of jth, (a is the nature more than or equal to 1 to j-th of timestamp to 1st timestamp of column
Number) in, the relationship between two timestamps of arbitrary neighborhood is serial relation, then regards j-th of timestamp to+a timestamps of jth
A continuous time stamp sequence is formed, then for this continuous time stamp sequence, using j-th of timestamp as the 1st
Timestamp stores the 1st timestamp in continuous time stamp sequence, storage other times stab respective deviation and storage deviation
It is worth number, the acquisition modes that other times stab respective deviation is please referred to the explanation in above method embodiment.
If the value of i is greater than 2, if j-th timestamp and -1 timestamp of jth in original time stamp sequence nucleotide sequence it
Between relationship be discontinuous relationship and the relationship between+1 timestamp of jth is discontinuous relationship, then when individually storing original
Between stab sequence in j-th of timestamp.Such as j-th of timestamp can be stored in one independent time stamp sequence, for
The explanation of independent time stamp sequence please refers to the related description in above method embodiment.
Below by taking an original time stamp sequence includes 10 timestamps as an example, method shown in above-mentioned Fig. 1 and Fig. 2 is carried out
Illustrate: there are following relationships between this 10 timestamps:
The first relationship is: the relationship in 10 timestamps between two timestamps of arbitrary neighborhood is serial relation, then
This 10 timestamps are stored in a continuous time stamp sequence, storage mode are as follows: store this in continuous time stamp sequence
The 1st timestamp, storage other times in 10 timestamps stab respective deviation and storage deviation number.
Second of relationship is: in 10 timestamps the 10th timestamp and/or the 1st timestamp respectively with the adjacent time
Relationship between stamp is discontinuous relationship, and the relationship between other times stamp is serial relation, then individually stores the 10th time
Stamp and/or the 1st timestamp can store in a continuous time stamp sequence other times stamp, storage mode are as follows: this
The storage time stamp of sequence the 1st in a little timestamps, the respective deviation of storage of other sequences, such as other times stamp are the 2nd
A timestamp then stores the 2nd timestamp, the 3rd timestamp of storage to the to the 9th timestamp in continuous time stamp sequence
9 respective deviations of timestamp store deviation number.
The third relationship is: the stamp of the other times in addition to the 10th timestamp and the 1st timestamp in 10 timestamps
Relationship between adjacent timestamp is discontinuous relationship, such as the 3rd timestamp and the 8th timestamp in 10 timestamps
Respectively the relationship between adjacent timestamp is discontinuous relationship, and the relationship between other timestamps adjacent to each other is continuous
Relationship then is respectively seen as being a continuous time by the three parts timestamp that the 3rd timestamp and the 8th timestamp are divided into
Stab sequence, i.e. the 1st timestamp and the 2nd timestamp form a continuous time and stab sequence, when the 4th timestamp is to the 7th
Between stamp form continuous time and stab sequence, the 9th timestamp and the 10th timestamp form a continuous time and stab sequence, right
Any continuous time stamp sequence is stored according to the explanation in second of relationship in these three continuous times stamp sequence, for the 3rd
A timestamp and the 8th timestamp can be then stored in independent time stamp sequence, such as by the 3rd timestamp and the 8th timestamp
It is respectively stored in an independent time stamp sequence, and store corresponding deviation in stamp sequence of each continuous time
Number.
From above-mentioned technical proposal it is found that if the relationship between i-th of timestamp and (i-1)-th timestamp is discontinuous closes
System, and i-th of timestamp is n-th of timestamp, then i-th of timestamp is individually stored, if when i-th of timestamp and (i-1)-th
Between relationship between stamp be not serial relation, and i-th of timestamp is not n-th of timestamp, then can be to original time stamp sequence
The 1st timestamp in column is stored to (i-1)-th timestamp based on the relationship between timestamp, and based between timestamp
The case where when relationship stores in the presence of the deviation for storing some timestamps, the storage that thus can also reduce timestamp occupancy are empty
Between, it is equally also stabbed without drop-out time, improves the integrality and authenticity of timestamp.
It please join Fig. 3, a kind of flow chart of data restoration method provided in an embodiment of the present invention be illustrated, for restoring
Timestamp in timestamp sequence, specifically, data restoration method shown in Fig. 3 may comprise steps of:
S201: acquisition time stabs the identifier in sequence, and wherein timestamp sequence is based on above-mentioned date storage method pair
The sequence that original time stamp sequence is handled, and the identifier in timestamp sequence can be based on above-mentioned date storage method
The setting of identifier-location is obtained, such as the 1st in sequence is set identifier by above-mentioned date storage method, then can be from
Identifier is obtained in 1st.
S202: it if the value of the identifier in timestamp sequence shows that timestamp sequence is continuous time to stab sequence, obtains
Take indicated in continuous time stamp sequence the 1st timestamp, indicate the 2nd timestamp to the respective deviation of e-th of timestamp and
Indicate the field of deviation number, and respective to e-th of timestamp based on the 2nd the 1st timestamp of expression, expression timestamp
Deviation and the field for indicating deviation number obtain the 1st timestamp to e-th of timestamp, and e-1 is the continuous time to stab sequence
Arrange the deviation number of record.
Wherein the value of the identifier in timestamp sequence shows that timestamp sequence is that continuous time one kind of stamp sequence can
Line mode is: based on the identifier in timestamp sequence, the value of identifier is obtained, if the value of identifier meets the first threshold
Value, then the timestamp sequence is continuous time to stab sequence,, should if the value of identifier is 1 if first threshold can be 1
Timestamp sequence is continuous time to stab sequence, and first threshold can be depending on practical application, and the present embodiment does not limit its value.
If timestamp sequence is continuous time to stab sequence, expression the 1st stored in continuous time stamp sequence is obtained
Timestamp, the field for indicating the 2nd timestamp to the respective deviation of e-th of timestamp and expression deviation number, from these
Data are obtained in field to be restored, are such as obtained for the 1st timestamp by N system operation, as continuous time stabs sequence
Using can then restore the 1st timestamp when binary storage by binary arithmetic operation, for the 2nd timestamp and e
For a timestamp, then it can be obtained based on respective deviation and tn=tn-1+ △ t+dn (n >=2) reduction.
S203: it if the value of the identifier in timestamp sequence shows that timestamp sequence is that independent time stabs sequence, counts
Calculate the timestamp for obtaining recording in independent time stamp sequence.
Wherein the value of the identifier in timestamp sequence shows that one kind that timestamp sequence is independent time stamp sequence can
Line mode is: based on the identifier in timestamp sequence, the value of identifier is obtained, if the value of identifier meets the second threshold
Value, then the timestamp sequence is that independent time stabs sequence,, should if the value of identifier is 0 if second threshold can be 0
Timestamp sequence is that independent time stabs sequence, and second threshold can be depending on practical application, and the present embodiment does not limit its value.
A kind of feasible pattern of timestamp being calculated in independent time stamp sequence is: independent time is stabbed appointing in sequence
The data are restored timestamp by N system operation by the data of one storage unit storage, as independent time stamp sequence uses two
System then can restore timestamp by binary arithmetic operation when storing.
From above-mentioned technical proposal it is found that being obtained after above-mentioned date storage method is handled in original time stamp sequence
Timestamp sequence, if the value of the identifier in timestamp sequence show timestamp sequence be continuous time stab sequence, obtain
Take indicated in continuous time stamp sequence the 1st timestamp, indicate the 2nd timestamp to the respective deviation of e-th of timestamp and
Indicate the field of deviation number, and respective to e-th of timestamp based on the 2nd the 1st timestamp of expression, expression timestamp
Deviation and the field for indicating deviation number, obtain the 1st timestamp to e-th of timestamp, if the mark in timestamp sequence
The value for knowing symbol shows that timestamp sequence is that independent time stabs sequence, then the time recorded in independent time stamp sequence is calculated
Stamp realizes the reduction to the timestamp recorded in timestamp sequence.
For the various method embodiments described above, for simple description, therefore, it is stated as a series of action combinations, but
Be those skilled in the art should understand that, the present invention is not limited by the sequence of acts described because according to the present invention, certain
A little steps can be performed in other orders or simultaneously.Secondly, those skilled in the art should also know that, it is retouched in specification
The embodiment stated belongs to preferred embodiment, and related actions and modules are not necessarily necessary for the present invention.
Corresponding with above method embodiment, the embodiment of the present invention provides a kind of data storage device, structural schematic diagram
As shown in figure 4, may include: that the first acquisition module 11, first returns to execution module 12 and the first memory module 13.
First obtains module 11, and for obtaining i-th of timestamp in original time stamp sequence, i is appointing into n from 2
It anticipates a number, n is timestamp sum in original time stamp sequence.It is to be understood that each time in original time stamp sequence
Stamp be ordered as from 1 to n, but during actual storage can since the 2nd timestamp of original time stamp sequence according to
It is secondary to obtain each timestamp until arriving the last one timestamp of original time stamp sequence, at the same the 2nd timestamp to last
Any one timestamp between a timestamp only obtains once, handles each timestamp, why from the 2nd timestamp
Start to please refer to the explanation in embodiment of the method the reason of acquisition.
First returns to execution module 12, if being to connect for the relationship between i-th of timestamp and (i-1)-th timestamp
Continuous relationship, and i-th of timestamp is not n-th of timestamp, then adds 1 to i and trigger the first acquisition module 11 and continue to obtain
Other times stamp in original time stamp sequence.
In the present embodiment, the first return execution module 12 judges the pass between i-th of timestamp and (i-1)-th timestamp
A kind of feasible pattern of system is: i-th of timestamp and (i-1)-th timestamp is obtained, when being based on i-th of timestamp and (i-1)-th
Between stab, obtain the deviation (being denoted as i-th of deviation in order to facilitate description) between i-th of timestamp and (i-1)-th timestamp,
If i-th of deviation has continuity, it is determined that the relationship between i-th of timestamp and (i-1)-th timestamp is continuous closes
System, if i-th of deviation does not have continuity, the relationship between i-th of timestamp and (i-1)-th timestamp is discontinuous
Relationship.Wherein whether i-th of deviation has successional judgement and determines whether i-th of timestamp is n-th of timestamp
Explanation please refer to embodiment of the method, this is no longer illustrated.
First memory module 13, if being continuous close for the relationship between i-th of timestamp and (i-1)-th timestamp
System, and i-th of timestamp is n-th of timestamp, then stores the in the original time stamp sequence the 1st timestamp, deposits
The 2nd timestamp is stored up to the respective deviation of n-th of timestamp and storage deviation number.
In the present embodiment, it stores the 1st timestamp in original time stamp sequence, store the 2nd timestamp to n-th
A kind of feasible pattern of the respective deviation of timestamp and storage deviation number is: according to the 1st timestamp to n-th of time
The sequence in original time stamp sequence is stabbed, the 2nd the 1st timestamp of storage, storage timestamp are respective to n-th of timestamp
Deviation and storage deviation number are into continuous time stamp sequence.
That is, also saying relative to original time stamp sequence, each storage unit is stored in original time stamp sequence
One timestamp, and the 1st storage unit storage in continuous time stamp sequence is the 1st timestamp, other storage units
Storage be timestamp deviation, and in continuous time stamp sequence the content of each storage unit storage be still according to it is original when
Between stab sequence in the 1st timestamp to n-th of timestamp sequence, and continuous time stamp sequence a storage unit in
Store deviation number.
The wherein deviation of the 2nd timestamp x-th of timestamp into n-th of timestamp are as follows: x-th of timestamp and xth-
The deviation between deviation or x-th of timestamp and the 1st timestamp between 1 timestamp, x be from 2 into n
Any one number, illustrates and please refers to embodiment of the method, no longer illustrates this present embodiment.
It furthermore whether is number in continuous time stamp sequence convenient for the current data of determination in order to during data convert
According to, can by way of identifier to continuous time stamp sequence be marked, as continuous time stamp sequence in the 1st for mark
Know the value of symbol, the value of the identifier is used to show that the relationship between the timestamp of continuous time stamp sequence storage to be to connect
Continuous relationship, such as when the value of identifier is 1, it is shown to be the timestamp of continuous time stamp sequence and continuous time stamp sequence storage
Between relationship be serial relation, then the 2nd storage unit is stored into n-th of storage unit in data convert
The mode that tn=tn-1+ △ t+dn (n >=2) can be used in data restores timestamp, and dn is then that n-th of storage unit stores
The corresponding deviation of n-th of timestamp, △ t are the sampling interval, which also can store in continuous time stamp sequence,
Related description in embodiment of the method is please referred to for the storage in deviation and sampling interval.
From above-mentioned technical proposal it is found that by obtaining i-th of timestamp in original time stamp sequence, if i-th of time
Relationship between stamp and (i-1)-th timestamp is serial relation and i-th of timestamp is not that n-th of timestamp then adds 1 return to i
I-th of the timestamp obtained in original time stamp sequence is executed, if the relationship between i-th of timestamp and (i-1)-th timestamp
For serial relation and i-th of timestamp is that n-th of timestamp then stores the 1st timestamp in original time stamp sequence, storage
2nd timestamp can be restored each to the respective deviation of n-th of timestamp and storage deviation number by deviation
The corresponding unique time stamps of deviation, being achieved in by way of storing deviation reduces the occupancy of memory space, in this way
It does not need to abandon deviation when storing deviation, and makes original time stamp sequence by way of storing deviation
Each timestamp in column can accurate reproduction, to improve the integrality and authenticity of timestamp.
Opposite, if in the case that the relationship between i-th of timestamp and (i-1)-th timestamp is discontinuous relationship,
I-th of timestamp is also required to be stored, and present embodiments provides the structural schematic diagram of another data storage device thus, explains
State the storage mode when relationship between i-th of timestamp and (i-1)-th timestamp is discontinuous relationship, the data storage device
It on the basis of fig. 4 may include: that the second memory module 14, second returns to execution module 15 and third memory module 16, such as Fig. 5
It is shown.
Second memory module 14, if the relationship between i-th of timestamp and (i-1)-th timestamp is discontinuous
Relationship, and i-th of timestamp is n-th of timestamp, then individually stores i-th of timestamp, i-th of timestamp is such as stored in one
In a independent time stamp sequence.
Wherein judge the relationship between i-th of timestamp and (i-1)-th timestamp and determines that i-th of timestamp is not n-th
A timestamp please refers to the explanation in above method embodiment, no longer illustrates this present embodiment.
It is corresponding with continuous time stamp sequence, independent time stamp sequence is also required to configure taking for an identifier for it
Value, such as value in the 1st record identifier of independent time stamp sequence, the value of the identifier and continuous time are stabbed in sequence
The value of identifier is different, if the value of identifier in independent time stamp sequence is 0, to show in independent time stamp sequence
It is discontinuous relationship that each timestamp of storage, which is with the relationship of other times stamp,.
Herein it should be understood that if an original time stamp sequence, obtain at least one continuous time stamp sequence and
At least one independent time stabs sequence, and each independent time stamp sequence only stores a timestamp, then in storage consecutive hours
Between stab sequence and independent time stamp sequence when, need according to continuous time stab sequence and independent time stamp sequence in timestamp in original
Sequence in beginning timestamp sequence stores, if original time stamp sequence is by 10 timestamps, wherein the 1st timestamp is to the 3rd
A timestamp forms a continuous time stamp sequence (being denoted as continuous time stamp sequence 1 for ease of description), and the 4th timestamp exists
(it is denoted as independent time stamp sequence 1 for ease of description) in one independent time stamp sequence, the 5th timestamp sequence is to the 10th
Timestamp form continuous time stamp sequence (be denoted as continuous time stamp sequence 2 for ease of description, then in storage this three
The positional relationship of a timestamp sequence are as follows: continuous time stabs sequence 1, independent time stamp sequence 1 and continuous time and stabs sequence 2, this
Sample can successively restore the data in these three timestamp sequences in reduction, the sequence of the timestamp after reduction are as follows:
1st timestamp, the 2nd timestamp ..., the 10th timestamp, sequence and the timestamp in original time stamp sequence
It sorts identical.
If multiple timestamps are stored in an independent time stamp sequence, in order to make the sequence of the timestamp restored
It is identical as the sequence of timestamp in original time stamp sequence, then it needs to stab in sequence and independent time stamp sequence in continuous time and deposit
The sequence of timestamp and deviation in original time stamp sequence is stored up, it in this way can be according to the sequence to reduction in reduction
Timestamp is arranged.
Second returns to execution module 15, if being not for the relationship between i-th of timestamp and (i-1)-th timestamp
Serial relation, and i-th of timestamp is not n-th of timestamp, then i-th of timestamp is determined as the original time stamp
The 1st new timestamp in sequence, and is added by 1 and triggers the first acquisition module 11 by i and continues to obtain in original time stamp sequence
Other times stamp.
That is, the relationship between some timestamp in original time stamp sequence and its previous timestamp is not connect
Continuous relationship, then can using timestamp as the 1st new timestamp in original time stamp sequence, then from newly the 1st when
Between stamp start successively to obtain the other times stamp after being located at the 1st new timestamp in original time stamp sequence, and to new
The 1st timestamp and the other times stamp after the 1st new timestamp carry out the judgement of relationship and based on relationship
Storage.
For example, the relationship between the 5th timestamp and the 4th timestamp in original time stamp sequence is discontinuous closes
System, and the 5th timestamp is not n-th of timestamp (i.e. the last one timestamp), then using the 5th timestamp as the new the 1st
A timestamp, and continue successively to obtain the other times stamp after the 1st new timestamp, i.e., the 6th timestamp is to n-th
Timestamp.
Third memory module 16, for the 1st timestamp in the original time stamp sequence to (i-1)-th timestamp
Based on the relationship storage between timestamp.
In the present embodiment, timestamp is based on to the 1st timestamp in original time stamp sequence to (i-1)-th timestamp
Between relationship storage need the value based on i depending on, it is specific: if the value of i is equal to 2, individually to store original time stamp
The 1st timestamp in sequence.
If the value of i is greater than 2, if being serial relation and the time adjacent to each other there are relationship in original time stamp sequence
The continuous time of stamp composition stabs sequence, then stores the 1st timestamp in continuous time stamp sequence, stores the 2nd timestamp extremely
The respective deviation of m-th of timestamp and storage deviation number, m-1 are continuous time to stab sequence large deviations value number.
That is it is greater than 2 in the value of i, if between multiple timestamps continuous each other in original time stamp sequence
Relationship be serial relation, then be considered as this multiple timestamp and form continuous times stamp sequence.Such as original time stamp sequence
Into (i-1)-th timestamp, to+a timestamps of jth, (a is the nature more than or equal to 1 to j-th of timestamp to 1st timestamp of column
Number) in, the relationship between two timestamps of arbitrary neighborhood is serial relation, then regards j-th of timestamp to+a timestamps of jth
A continuous time stamp sequence is formed, then for this continuous time stamp sequence, using j-th of timestamp as the 1st
Timestamp stores the 1st timestamp in continuous time stamp sequence, storage other times stab respective deviation and storage deviation
It is worth number, the acquisition modes that other times stab respective deviation is please referred to the explanation in above method embodiment.
If the value of i is greater than 2, if j-th timestamp and -1 timestamp of jth in original time stamp sequence nucleotide sequence it
Between relationship be discontinuous relationship and the relationship between+1 timestamp of jth is discontinuous relationship, then when individually storing original
Between stab sequence in j-th of timestamp.Such as j-th of timestamp can be stored in one independent time stamp sequence, for
The explanation of independent time stamp sequence please refers to the related description in above method embodiment.Specifically, above method implementation please be join
Example, details are not described herein.
The embodiment of the present invention also provides a kind of data recovery device, and structure is as shown in fig. 6, may include: the second acquisition
Module 21, the first recovery module 22 and the second recovery module 23.
Second obtains module 21, and for the identifier in acquisition time stamp sequence, wherein timestamp sequence is based on above-mentioned
The sequence that data storage device handles original time stamp sequence, and the identifier in timestamp sequence can be based on it is upper
It states data storage device to obtain the setting of identifier-location, such as above-mentioned data storage device sets the 1st in sequence to
Identifier then can obtain identifier from the 1st.
First recovery module 22, if the value for the identifier in the timestamp sequence shows the timestamp sequence
Sequence is stabbed for continuous time, then obtains in the continuous time stamp sequence and indicates the 1st timestamp, indicate the 2nd timestamp extremely
The respective deviation of n-th of timestamp and the field for indicating deviation number, and based on the 1st timestamp of the expression, expression
2nd timestamp obtains the 1st timestamp extremely to the field of the respective deviation of e-th of timestamp and expression deviation number
E-th of timestamp, e-1 are the deviation number for the continuous time stabbing sequential recording.
Wherein the value of the identifier in timestamp sequence shows that timestamp sequence is that continuous time one kind of stamp sequence can
Line mode is: based on the identifier in timestamp sequence, the value of identifier is obtained, if the value of identifier meets the first threshold
Value, then the timestamp sequence is continuous time to stab sequence,, should if the value of identifier is 1 if first threshold can be 1
Timestamp sequence is continuous time to stab sequence, and first threshold can be depending on practical application, and the present embodiment does not limit its value.
If timestamp sequence is continuous time to stab sequence, the 1st time stored in continuous time stamp sequence is obtained
Stamp, the 2nd timestamp of storage to the respective deviation of e-th of timestamp and the field for storing deviation number, from these fields
Middle acquisition data are restored, and are such as obtained for the 1st timestamp by N system operation, as continuous time stamp sequence uses
The 1st timestamp can be then restored when binary storage by binary arithmetic operation, when for the 2nd timestamp and e-th
Between for stamp, then can be obtained based on respective deviation and tn=tn-1+ △ t+dn (n >=2) reduction.
Second recovery module 23, if the value for the identifier in the timestamp sequence shows the timestamp sequence
Sequence is stabbed for independent time, then the timestamp recorded in the independent time stamp sequence is calculated.Wherein in timestamp sequence
The value of identifier show that timestamp sequence is that independent time stabs a kind of feasible pattern of sequence and is: based in timestamp sequence
Identifier, obtain the value of identifier, if the value of identifier meets second threshold, the timestamp sequence be it is independent when
Between stab sequence, if second threshold can be 0, if the value of identifier be 0, the timestamp sequence be independent time stab sequence
Column, second threshold can be depending on practical application, and the present embodiment does not limit its value.
A kind of feasible pattern of timestamp being calculated in independent time stamp sequence is: independent time is stabbed appointing in sequence
The data are restored timestamp by N system operation by the data of one storage unit storage, as independent time stamp sequence uses two
System then can restore timestamp by binary arithmetic operation when storing.
From above-mentioned technical proposal it is found that being obtained after above-mentioned date storage method is handled in original time stamp sequence
Timestamp sequence, if the value of the identifier in timestamp sequence show timestamp sequence be continuous time stab sequence, obtain
Take indicated in continuous time stamp sequence the 1st timestamp, indicate the 2nd timestamp to the respective deviation of e-th of timestamp and
Indicate the field of deviation number, and respective to e-th of timestamp based on the 2nd the 1st timestamp of expression, expression timestamp
Deviation and the field for indicating deviation number, obtain the 1st timestamp to e-th of timestamp, if the mark in timestamp sequence
The value for knowing symbol shows that timestamp sequence is that independent time stabs sequence, then the time recorded in independent time stamp sequence is calculated
Stamp realizes the reduction to the timestamp recorded in timestamp sequence.
It should be noted that all the embodiments in this specification are described in a progressive manner, each embodiment weight
Point explanation is the difference from other embodiments, and the same or similar parts between the embodiments can be referred to each other.
For device class embodiment, since it is basically similar to the method embodiment, so being described relatively simple, related place ginseng
See the part explanation of embodiment of the method.
Finally, it is to be noted that, herein, relational terms such as first and second and the like be used merely to by
One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation
Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning
Covering non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes that
A little elements, but also including other elements that are not explicitly listed, or further include for this process, method, article or
The intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence "including a ...", is not arranged
Except there is also other identical elements in the process, method, article or apparatus that includes the element.
The foregoing description of the disclosed embodiments can be realized those skilled in the art or using the present invention.To this
A variety of modifications of a little embodiments will be apparent for a person skilled in the art, and the general principles defined herein can
Without departing from the spirit or scope of the present invention, to realize in other embodiments.Therefore, the present invention will not be limited
It is formed on the embodiments shown herein, and is to fit to consistent with the principles and novel features disclosed in this article widest
Range.
The above is only a preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art
For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications are also answered
It is considered as protection scope of the present invention.