Compression method of power load data and terminal

文档序号:1921480 发布日期:2021-12-03 浏览:15次 中文

阅读说明:本技术 电力负荷数据的压缩方法及终端 (Compression method of power load data and terminal ) 是由 朱雅魁 陶鹏 申洪涛 张洋瑞 张超 张冰玉 于 2021-07-15 设计创作,主要内容包括:本发明提供了一种电力负荷数据的压缩方法及终端,该方法包括:获取待压缩数据集合;将第一数据作为第二数据的基准数据,计算第二数据与第一数据的差值,其中,第一数据为数据集合中位于第二数据之前的与第二数据距离最近的非空数据;若第二数据与第一数据的差值小于等于第一预设值,则将第二数据与第一数据的差值按照第一预设数据结构存储至压缩序列中第二数据对应的位置,其中,差值的绝对值为a×10~(n),第一预设数据结构包括第一值、第二值和第三值,第一值用于表示差值为正数或负数,第二值为10~(n)中的指数n的值,第三值为a的值,其中,n为负整数。本发明能够提高电力数据的压缩速度。(The invention provides a compression method and a terminal for power load data, wherein the method comprises the following steps: acquiring a data set to be compressed; taking the first data as reference data of the second data, and calculating a difference value between the second data and the first data, wherein the first data is non-null data which is positioned before the second data and is closest to the second data in the data set; if the difference value between the second data and the first data is less than or equal to a first preset value, storing the difference value between the second data and the first data to a position corresponding to the second data in the compressed sequence according to a first preset data structure, wherein the absolute value of the difference value is a multiplied by 10 n The first preset data structure includes a first value for indicating whether the difference value is a positive number or a negative number, a second value of 10, and a third value n The third value is a value of a, wherein n is a negative integer. The invention can improve the compression speed of the power data.)

1. A method of compressing power load data, comprising:

acquiring a data set to be compressed, taking first data as reference data of second data, and calculating a difference value between the second data and the first data, wherein the first data is non-null data which is positioned in the data set before the second data and is closest to the second data;

if the difference value between the second data and the first data is smaller than or equal to a first preset value, storing the difference value between the second data and the first data to a position corresponding to the second data in the compressed sequence according to a first preset data structure, wherein the absolute value of the difference value is a multiplied by 10nThe first preset data structure comprises a first value, a second value and a third value, the first value is used for indicating that the difference value is a positive number or a negative number, and the second value is 10nThe third value is the value of a, wherein n is 0 or a negative integer.

2. The method according to claim 1, wherein the first predetermined data structure further includes type information of a data structure, the first predetermined data structure is composed of two bytes, a first bit is used for representing the type information of the first predetermined data structure, a second bit is used for representing the first value, third to fifth bits are used for representing an absolute value of the second value, and sixth to sixteenth bits are used for representing the third value.

3. The method of claim 2, further comprising:

if third data exists in the data set and the third data is missing data, inserting a second preset data structure in a position corresponding to the third data in the compressed sequence, wherein the second preset structure comprises a second preset value, and the second preset value is used for indicating that the third data is missing data.

4. The method of claim 3, further comprising:

and if the first data is the first data in the data set, or the difference value between the second data and the first data is greater than the first preset value, storing the first data or the second data in the compressed sequence through a third preset data structure.

5. The method according to claim 4, wherein the second predetermined data structure and the third data structure further contain type information of the data structure, wherein the second predetermined data structure and the third predetermined data structure are of the same type, and the second predetermined data structure and the first data structure are of different types.

6. The method of claim 5, wherein the second predetermined data structure is composed of one byte, a first bit is used for indicating the type information of the second predetermined data structure, and second to eighth bits are used for indicating the second predetermined value;

a first bit of the third preset data structure is used for representing type information of the third preset data structure, and second to eighth bits are used for representing a fourth value used for representing type information of data stored in the third data structure;

if the data type information that the fourth value is used for representing is integer data, the third preset data structure is composed of three bytes, and ninth to twenty-fourth bits are values for storing data;

if the data type represented by the fourth value is single-precision floating-point data, the third preset data structure is composed of five bytes, and ninth to forty bits are values for storing data;

if the data type indicated by the fourth value is double-precision floating-point data, the third preset data structure is composed of nine bytes, and the ninth bit to the seventy-th bit are values for storing data.

7. The method of claim 6, further comprising performing a data decompression process:

acquiring a data sequence to be decompressed;

obtaining type information of a data structure according to the first bit of data;

and decompressing the data according to the type information of the data structure.

8. The method of claim 7, wherein decompressing data according to the type information of the data structure comprises:

if the type information of the data structure is used for representing a second preset data structure or a third preset data structure, reading a second bit to an eighth bit;

if the values from the second bit to the eighth bit are the second preset value, judging that the data corresponding to the data structure are missing data;

if the values from the second bit to the eighth bit are the fourth value, obtaining the data stored in the data structure according to the data type information corresponding to the fourth value, and inserting the data into a decompression sequence;

if the type information of the data structure is used for representing a first preset data structure, acquiring the first value, the second value and the third value, acquiring a difference value between the second data and the first data according to the first value, the second value and the third value, adding the difference value and the first data to obtain the second data, and inserting the second data into the decompression sequence.

9. The method of any one of claims 1 to 8, further comprising:

after a compressed sequence corresponding to the data set is obtained, a compressed file containing the compressed sequence is created;

naming the compressed file according to a preset strategy to obtain a file name;

storing, in a database, identification information of the power load devices and the data set, directory path information of the compressed file.

10. A terminal comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of the preceding claims 1 to 9 when executing the computer program.

Technical Field

The invention belongs to the technical field of computers, and particularly relates to a compression method of power load data and a terminal.

Background

Data compression, which means that on the premise of not losing useful information, the data volume is reduced or data is recombined through a data compression algorithm, and the redundancy of the data is reduced to reduce the storage space and improve the transmission, storage and processing efficiency.

In the power industry, power characteristic data such as load curves, voltages, currents and the like need to be continuously recorded for important loads, and due to the fact that a user data sampling period is short, a continuous time span is large, a user base number is large, and the data are usually directly recorded by a database in the industry, the quantity of current power data is large, storage cost is large, the query time span is not too long, or the query time is too long, even the database is down and the like.

In order to solve the above problem, the power load data is usually compressed and then stored, but the compression rate of the existing compression method for the power load data is low.

Disclosure of Invention

In view of this, the present invention provides a method and a terminal for compressing power load data, which can improve the compression rate of the power load data compression.

A first aspect of an embodiment of the present invention provides a method for compressing power load data, including:

acquiring a data set to be compressed, taking first data as reference data of second data, and calculating a difference value between the second data and the first data, wherein the first data is non-null data which is positioned in the data set before the second data and is closest to the second data;

if the difference value between the second data and the first data is smaller than or equal to a first preset value, storing the difference value between the second data and the first data to a position corresponding to the second data in the compressed sequence according to a first preset data structure, wherein the absolute value of the difference value is a multiplied by 10nThe first preset data structure comprises a first value, a second value and a third value, the first value is used for indicating that the difference value is a positive number or a negative number, and the second value is 10nThe third value is the value of a, wherein n is a negative integer.

In a possible implementation manner, the first preset data structure further includes type information of a data structure, the first preset data structure is composed of two bytes, a first bit is used for representing the type information of the first preset data structure, a second bit is used for representing the first value, third to fifth bits are used for representing an absolute value of the second value, and sixth to sixteenth bits are used for representing the third value.

In one possible implementation, the method further includes:

if third data exists in the data set and the third data is missing data, inserting a second preset data structure in a position corresponding to the third data in the compressed sequence, wherein the second preset structure comprises a second preset value, and the second preset value is used for indicating that the third data is missing data.

In one possible implementation, the method further includes:

and if the first data is the first data in the data set, or the difference value between the second data and the first data is greater than the first preset value, storing the first data or the second data in the compressed sequence through a third preset data structure.

In a possible implementation manner, the second preset data structure and the third data structure further include type information of the data structure, where the second preset data structure and the third preset data structure are the same in type, and the second preset data structure and the first data structure are different in type.

In a possible implementation manner, the second preset data structure is composed of one byte, a first bit is used for representing the type information of the second preset data structure, and second to eighth bits are used for representing the second preset value;

a first bit of the third preset data structure is used for representing type information of the third preset data structure, and second to eighth bits are used for representing a fourth value used for representing type information of data stored in the third data structure;

if the data type information that the fourth value is used for representing is integer data, the third preset data structure is composed of three bytes, and ninth to twenty-fourth bits are values for storing data;

if the data type represented by the fourth value is single-precision floating-point data, the third preset data structure is composed of five bytes, and ninth to forty bits are values for storing data;

if the data type indicated by the fourth value is double-precision floating-point data, the third preset data structure is composed of nine bytes, and the ninth bit to the seventy-th bit are values for storing data.

In one possible implementation, the method further includes performing a data decompression process:

acquiring a data sequence to be decompressed;

obtaining type information of a data structure according to the first bit of data;

and decompressing the data according to the type information of the data structure.

In a possible implementation manner, the decompressing data according to the type information of the data structure includes:

if the type information of the data structure is used for representing a second preset data structure or a third preset data structure, reading a second bit to an eighth bit;

if the values from the second bit to the eighth bit are the second preset value, judging that the data corresponding to the data structure are missing data;

if the values from the second bit to the eighth bit are the fourth value, obtaining the data stored in the data structure according to the data type information corresponding to the fourth value, and inserting the data into a decompression sequence;

if the type information of the data structure is used for representing a first preset data structure, acquiring the first value, the second value and the third value, acquiring a difference value between the second data and the first data according to the first value, the second value and the third value, adding the difference value and the first data to obtain the second data, and inserting the second data into the decompression sequence.

In one possible implementation, the method further includes: after a compressed sequence corresponding to the data set is obtained, a compressed file containing the compressed sequence is created;

naming the compressed file according to a preset strategy to obtain a file name;

storing, in a database, identification information of the power load devices and the data set, directory path information of the compressed file.

In a second aspect, an embodiment of the present invention provides a terminal, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the steps of the method according to the first aspect or any possible implementation manner of the first aspect.

The embodiment of the invention provides a compression method and a compression device for power load data, wherein the characteristics of power load curve data are analyzed, the difference value between two adjacent data is usually small, and the data is compressed by storing the difference value in a compression sequence, so that the data storage capacity is reduced, the complexity of a compression algorithm is reduced, and the compression rate is increased.

Drawings

In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.

Fig. 1 is a flowchart of an implementation of a method for compressing power load data according to an embodiment of the present invention;

FIG. 2 is a diagram of a data structure provided by an embodiment of the invention;

FIG. 3 is a schematic diagram of another data structure provided by embodiments of the present invention;

FIG. 4 is a schematic diagram of another data structure provided by embodiments of the present invention;

FIG. 5 is a flow chart of another implementation of a method for compressing power load data according to an embodiment of the present invention;

FIG. 6 is a schematic structural diagram of an apparatus for compressing power load data according to an embodiment of the present invention;

fig. 7 is a schematic diagram of a terminal according to an embodiment of the present invention.

Detailed Description

In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.

In order to make the objects, technical solutions and advantages of the present invention more apparent, the following description is made by way of specific embodiments with reference to the accompanying drawings.

Referring to fig. 1, it shows a flowchart of an implementation of a method for compressing power load data according to an embodiment of the present invention, which is detailed as follows:

s101, acquiring a data set to be compressed, taking first data as reference data of second data, and calculating a difference value between the second data and the first data, wherein the first data is non-null data which is located before the second data and is closest to the second data in the data set.

The data sets to be compressed are data of preset types in a preset time period corresponding to the same power load device, and the data in the data sets to be compressed are arranged according to the time sequence.

Optionally, the preset time period may be one month or one year, which is not limited in the embodiment of the present invention.

The data set includes data of a preset type of the power load device in a preset time period, that is, single item of collected information of the power load device in the preset time period, such as total power data, voltage data, or current data.

The data in the data set are arranged according to the sequence of acquisition, namely the sequence of time from early to late.

Binary storage of data has three forms: the integer data occupies two bytes, namely 16 bits; single precision floating point type data occupies 4 bytes, namely 32 bits; the double-precision floating-point type occupies 8 bytes, i.e., 64 bits.

In actual data storage, the type information of the data is also stored, so that the integer data, the single-precision floating-point data and the double-precision floating-point data occupy more than 2 bytes, 4 bytes and 8 bytes of memory in the storage process.

Due to the diversity of the power load data, the data sets to be compressed usually include the three types of data.

If the power load data is not compressed but stored directly, the analysis shows that the memory occupied by the data is very large.

In the data acquisition process of the power load equipment, the variation of two adjacent data is small, namely the absolute value of the difference between the latter data and the former data is small.

Therefore, the first data is used as the reference data of the second data, and the difference between the second data and the first data is calculated.

It should be noted that the first data is non-null data located before the second data in the data set and closest to the second data.

When there is missing data, the location corresponding to the missing data may be a null data.

For example, 5 data are arranged in order in the data set, and are data 1, data 2, missing data, data 4, and data 5, respectively, so that the reference data of data 2 is data 1, the reference data of data 4 is data 2, and the reference data of data 5 is data 4.

S102, if the difference value between the second data and the first data is smaller than or equal to a first preset value, storing the difference value between the second data and the first data to a position corresponding to the second data in the compressed sequence according to a first preset data structure, wherein the absolute value of the difference value is a multiplied by 10nThe first preset data structure comprises a first value, a second value and a third value, the first value is used for indicating that the difference value is a positive number or a negative number, and the second value is 10nThe third value is the value of a, wherein n is a negative integer.

An embodiment of the present invention provides a data structure as shown in fig. 2, where the data structure shown in fig. 2 is a first preset data structure in this step.

Optionally, as shown in fig. 2, the first preset data structure further includes type information of a data structure, where the first preset data structure is composed of two bytes, a first bit is used to represent the type information of the first preset data structure, a second bit is used to represent the first value, third to fifth bits are used to represent an absolute value of the second value, and sixth to sixteenth bits are used to represent the third value.

The first preset data structure shown in fig. 2 only occupies 16 bits, i.e. two bytes, and compared with the storage manner in step S101, i.e. integer data, single-precision floating-point data, and double-precision floating-point data, the memory footprint is greatly reduced.

If the second data is different from the first dataThe absolute value of the value is a x 10nThe first preset data structure includes a first value for indicating whether the difference value is a positive number or a negative number, a second value of 10, and a third valuenThe third value is a value of a, wherein n is a negative integer.

With reference to fig. 2, optionally, the first bit is used to indicate the type information of the first preset data structure, where 0 may be used to indicate the type information of the first preset data structure, and 1 may also be used to indicate the type information of the first preset data structure, which is not limited in this embodiment of the present invention.

The second bit is used for representing the first value, and the first value is used for representing that the difference value of the second data and the first data is a positive number or a negative number. Optionally, when the second bit is 0, the difference is a positive number, and when the second bit is 1, the difference is a negative number, or when the second bit is 0, the difference is a negative number, and when the second bit is 1, the difference is a positive number, which is not limited in the embodiment of the present invention.

The third to fifth bits are used to represent an exponent n, n being 0 or a negative integer. It can be seen that n is in the range of-7, -6, -5, -4, -3, -2, -1, 0.

The sixth bit to the sixteenth bit, 11 bits in total, are used to represent a third value, that is, the value of a, and it can be seen that the value range of a is any value from 0 to 2047.

Thus, the first predetermined data structure may be used to indicate that the absolute value is at 1 × 10-7Any data between 2047.

Based on this, the first preset value may be set to 2047.

Optionally, if third data exists in the data set and the third data is missing data, a second preset data structure is inserted into a position corresponding to the third data in the compressed sequence, where the second preset structure includes a second preset value, and the second preset value is used to indicate that the third data is missing data.

And if the first data is the first data in the data set, or the difference value between the second data and the first data is greater than the first preset value, storing the first data or the second data in the compressed sequence through a third preset data structure.

The second preset data structure and the third data structure further include type information of the data structures, wherein the second preset data structure and the third preset data structure are the same in type, and the second preset data structure and the first data structure are different in type.

Optionally, the second preset data structure is composed of a byte, a first bit is used for indicating the type information of the second preset data structure, and second to eighth bits are used for indicating the second preset value;

a first bit of the third preset data structure is used for representing type information of the third preset data structure, and second to eighth bits are used for representing a fourth value used for representing type information of data stored in the third data structure;

if the data type information that the fourth value is used for representing is integer data, the third preset data structure is composed of three bytes, and ninth to twenty-fourth bits are values for storing data;

if the data type represented by the fourth value is single-precision floating-point data, the third preset data structure is composed of five bytes, and ninth to forty bits are values for storing data;

if the data type indicated by the fourth value is double-precision floating-point data, the third preset data structure is composed of nine bytes, and the ninth bit to the seventy-th bit are values for storing data.

The second preset data structure and the third preset data structure are described below with reference to fig. 3 and 4, respectively.

Fig. 3 is a schematic diagram of a data structure according to an embodiment of the present invention, and optionally, a schematic diagram of a second preset data structure; fig. 4 is a schematic diagram of another data structure provided in the embodiment of the present invention, and optionally, a schematic diagram of a third preset data structure.

As shown in fig. 3 and 4, the first bit of the second preset data structure and the first bit of the third preset data structure are used to indicate the type information of the data structure. The second preset data structure and the third preset data structure are of the same type, and the second preset data structure and the first data structure are of different types.

For example, if the type information of the first preset data structure is represented by 1, the type information of the second preset data structure and the third preset data structure is represented by 0; or, if the type information of the first preset data structure is represented by 0, the type information of the second preset data structure and the third preset data structure is represented by 1, which is not limited in this embodiment of the present invention.

If a data to be compressed is missing data, a second preset data structure is inserted into a position corresponding to the data in the compressed sequence, as shown in fig. 3, where second to 8 th bits of the data structure store a second preset value, and the second preset value is used to indicate that the data is missing data.

From the above analysis, it can be seen that the first predetermined data structure can only store the value whose absolute value is smaller than or equal to 2047, and if the difference between the second data and the first data is greater than 2047, the difference cannot be stored through the first predetermined data structure. Based on this, for the second data with a difference value greater than 2047 from the first data, or the first data in the data set, in conjunction with fig. 4, the embodiment of the present invention further provides a third preset data structure as shown in fig. 4.

The first bit in the third predetermined data structure is used to indicate the type information of the data structure, and the type of the third predetermined data structure is the same as the type of the second predetermined data structure. The second to eight bits are used to represent a fourth value, which is used to represent type information of data stored in the third data structure, for example:

if the data type information indicated by the fourth value is integer data, the third preset data structure is composed of three bytes, and the ninth bit to the twenty-fourth bit are values for storing data, at this time, optionally, the fourth value is 24, and may be used to indicate that the data structure occupies 3 bytes in total of 24 bits;

if the data type indicated by the fourth value is single-precision floating-point data, the third preset data structure is composed of five bytes, and the ninth bit to the forty th bit are values for storing data, at this time, optionally, the fourth value is 40, and may be used to indicate that the data structure occupies 5 bytes in total of 40 bits;

if the data type indicated by the fourth value is double-precision floating-point data, the third preset data structure is composed of nine bytes, and the ninth bit to the seventy-th bit are values for storing data, at this time, optionally, the fourth value is 72, and may be used to indicate that the data structure occupies 9 bytes in total of 72 bits.

It should be noted that the second preset value is different from the fourth value. For example, the second preset value may be set to 8, which indicates that the data is missing data.

Further, the second preset value can also be other values for representing other specific types of data that may be encountered in practical applications, and the storage of specific data based on the idea of the present invention is within the protection scope of the embodiment of the present invention.

The following describes the compression process of the above data by a specific example.

For example, 5 data are arranged in order in the data set, and are data 1, data 2, missing data, data 4, and data 5, respectively, so that the reference data of data 2 is data 1, the reference data of data 4 is data 2, and the reference data of data 5 is data 4.

The absolute value of the difference between data 2 and data 1 is less than 2047, the absolute value of the difference between value 4 and value 2 is greater than 2047, and the absolute value of the difference between value 5 and value 4 is less than 2047.

Starting a compression process, sequentially compressing the data according to the arrangement sequence of the data in the data set, firstly compressing data 1, compressing the data 1 through a third preset data structure shown in fig. 4 and inserting a preset compression sequence, wherein the data 1 is the first data in the data set;

the absolute value of the difference between data 2 and data 1 is smaller than 2047, the difference X between data 2 and data 1 is obtained, and X1 is converted into the absolute value of a × 10nIn the form of a and n, respectively, with a first predetermined numberStore X1 according to structure and insert the compressed sequence in order;

if the third data is missing data, inserting a second preset data structure in the compressed sequence in sequence;

if the absolute value of the difference value between the data 4 and the data 2 is greater than 2047, storing the data 2 through a third preset data structure and inserting the data 2 into a compression sequence in sequence;

the absolute value of the difference between the data 5 and the data 4 is smaller than 2047, the difference X2 between the data 5 and the data 4 is obtained, and X2 is converted into the absolute value of a × 10nTo obtain the values of a and n, respectively, and store X2 with a first predetermined data structure and insert the compressed sequences in order.

And if the data 5 is the last data in the set, completing compression and outputting a compressed sequence.

The traditional compression method is either to directly compress the file and is not beneficial to structured access, or the compression and decompression are relatively complex, the processing speed is slow, and the system response is not timely when reading a large amount of user data. The method and the device reduce data storage overhead, improve compression rate and realize quick reading and displaying of data.

Therefore, the invention can realize lossless compression on the basis of reducing the storage capacity and improve the speed of compressing the power load data by compressing the same type of power data of the same power load equipment, calculating the difference value between the next data and the previous data according to the characteristic that the difference value between the two adjacent data is smaller, and storing the difference value through a data structure which occupies a smaller memory if the difference value is smaller than a first preset value.

Fig. 5 is a flowchart illustrating an implementation of another method for compressing power load data according to an embodiment of the present invention, which is detailed as follows:

s501, acquiring a data sequence to be decompressed.

A compressed sequence is obtained by the method shown in fig. 1, and when the compressed sequence needs to be decompressed, the compressed sequence is the data sequence to be decompressed in this step.

S502, obtaining the type information of the data structure according to the data of the first bit.

As can be seen from the method shown in fig. 1 and the three preset data structures shown in fig. 2 to 4, the first bit of each data structure is used to represent type information of the data structure, where the second preset data structure and the third preset data structure have the same type, and the second preset data structure and the first data structure have different types.

S503, decompressing the data according to the type information of the data structure.

Optionally, if the type information of the data structure is used to indicate a second preset data structure or a third preset data structure, reading the second bit to the eighth bit;

if the values from the second bit to the eighth bit are the second preset value, judging that the data corresponding to the data structure are missing data;

if the values from the second bit to the eighth bit are the fourth value, obtaining the data stored in the data structure according to the data type information corresponding to the fourth value, and inserting the data into a decompression sequence;

if the type information of the data structure is used for representing a first preset data structure, acquiring the first value, the second value and the third value, acquiring a difference value between the second data and the first data according to the first value, the second value and the third value, adding the difference value and the first data to obtain the second data, and inserting the second data into the decompression sequence.

The decompression process is described below as an example.

In this step, the following description will be made by taking an example in which 5 pieces of data are sequentially arranged in the original data set, and are data 1, data 2, missing data, data 4, and data 5, respectively, so that the reference data of data 2 is data 1, the reference data of data 4 is data 2, and the reference data of data 5 is data 4.

Through steps S101 to S102, a compression sequence is obtained, and the compression sequence sequentially stores: data 1 stored by the third preset data structure, a difference X1 of data 2 and data 1 stored by the first preset data structure, missing data stored by the second preset data structure, data 4 stored by the third preset data structure, a difference X2 of data 5 and data 4 stored by the first preset data structure.

It is assumed that the type information of the first preset data structure is represented by 1, and the type information of the second preset data structure and the third preset data structure is represented by 0.

The decompression process is: reading a first bit of the sequence to obtain 0, if the first bit is judged to be a second preset data structure or a third preset data structure, reading bits 2 to 8 to obtain type information of data 1, and if the data 1 is integer data, reading bits 9 to 24 to obtain a value of the data 1, and storing the value into a decompression sequence;

continuing to read data, reading the first bit to obtain 1, judging as the first preset data structure, reading the second bit, judging whether the difference value is positive or negative, reading the third to fifth bits to obtain the value of n, reading the 6 th to 16 th bits to obtain the value of a, calculating a x 10nCombining the value of the second bit to obtain a difference value X1, adding X1 and data 1 to obtain data 2, and storing the data 2 in a decompression sequence;

continuing to read data, wherein the first bit is 0, judging that the data is a second preset data structure or a third preset data structure, reading 2-8 bits to obtain a second preset value, and judging that the data corresponding to the position is missing data;

continuing to read data, wherein the first bit is 0, if the data is judged to be in the second preset data structure or the third preset data structure, reading the 2 nd to 8 th bits to obtain the type information of the data 4, and if the data 4 is single-precision floating point type data, reading the 9 th to 40 th bits to obtain the value of the data 4, and storing the value into a decompression sequence;

continuing to read data, reading the first bit to obtain 1, judging as the first preset data structure, reading the second bit, judging whether the difference value is positive or negative, reading the third to fifth bits to obtain the value of n, reading the 6 th to 16 th bits to obtain the value of a, calculating a x 10nCombining the value of the second bit to obtain a difference value X2, adding X2 and data 4 to obtain data 5, and storing the data 5 in a solutionIn a compressed sequence;

and finishing data reading and finishing decompression.

Further, after the compression is completed, the compressed sequence is stored in a preset database so as to facilitate subsequent indexing and searching, including: after a compressed sequence corresponding to the data set is obtained, a compressed file containing the compressed sequence is created; naming the compressed file according to a preset strategy to obtain a file name; storing, in a database, identification information of the power load devices and the data set, directory path information of the compressed file.

Optionally, the load curve data of a single power load device may be compressed by taking a natural year as a preset time period to obtain a compressed file, the file name is stored by taking the user number + the copied load year as the file name, and the user name, the user number, the recording start time point, the total data point, the daily load point, the time interval between load records, the directory path of the compressed file, and the like of the load are recorded in the database.

And compressing the load curves of all the electricity customers, and storing the compressed files in the database by adopting the same method as the method.

The embodiment of the invention also provides a database storage format example, which is as follows:

field(s) Type (B) Description of the invention
ID number Data entry unique ID
Cons_name Char(64) Name of a house
Cons_no Char(10) House number
Start_time datetime Recording start time point
Sum_num number Total number of data points
Day_piont number Load points per day
Sepa_time number Time interval (min) between load records
File_path Varchar2 Directory path of the compressed file

Therefore, the invention can realize lossless compression on the basis of reducing the storage capacity and improve the speed of compressing the power load data by compressing the same type of power data of the same power load equipment, calculating the difference value between the next data and the previous data according to the characteristic that the difference value between the two adjacent data is smaller, and storing the difference value through a data structure which occupies a smaller memory if the difference value is smaller than a first preset value.

It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.

The following are embodiments of the apparatus of the invention, reference being made to the corresponding method embodiments described above for details which are not described in detail therein.

Fig. 6 is a schematic structural diagram of a compression apparatus for power load data according to an embodiment of the present invention, and for convenience of description, only the parts related to the embodiment of the present invention are shown, and detailed descriptions are as follows:

as shown in fig. 6, the compression device 6 for power load data includes: a data acquisition module 61, a difference value calculation module 62 and a compression module 63;

the data acquisition module 61 is configured to: acquiring a data set to be compressed, wherein the data set to be compressed is data of a preset type in a preset time period corresponding to the same power load equipment, and the data in the data set to be compressed are arranged according to the time sequence;

the difference calculation module 62 is configured to: taking first data as reference data of second data, and calculating a difference value between the second data and the first data, wherein the first data is non-null data which is positioned before the second data in the data set and is closest to the second data;

the compression module 63 is configured to: if the difference value between the second data and the first data is smaller than or equal to a first preset value, storing the difference value between the second data and the first data to a position corresponding to the second data in the compressed sequence according to a first preset data structure, wherein the absolute value of the difference value is a multiplied by 10nThe first preset data structure comprises a first value, a second value and a third value, the first value is used for indicating that the difference value is a positive number or a negative number, and the second value is 10nThe third value is the value of a, whereinAnd n is 0 or a negative integer.

Optionally, the first preset data structure further includes type information of a data structure, where the first preset data structure is composed of two bytes, a first bit is used to represent the type information of the first preset data structure, a second bit is used to represent the first value, third to fifth bits are used to represent an absolute value of the second value, and sixth to sixteenth bits are used to represent the third value.

Optionally, the compression module 63 is further configured to: if third data exists in the data set and the third data is missing data, inserting a second preset data structure in a position corresponding to the third data in the compressed sequence, wherein the second preset structure comprises a second preset value, and the second preset value is used for indicating that the third data is missing data.

Optionally, the compression module 63 is further configured to: and if the first data is the first data in the data set, or the difference value between the second data and the first data is greater than the first preset value, storing the first data or the second data in the compressed sequence through a third preset data structure.

Optionally, the second preset data structure and the third data structure further include type information of the data structure, where the second preset data structure and the third preset data structure have the same type, and the second preset data structure and the first data structure have different types.

Optionally, the second preset data structure is composed of a byte, a first bit is used for indicating the type information of the second preset data structure, and second to eighth bits are used for indicating the second preset value;

a first bit of the third preset data structure is used for representing type information of the third preset data structure, and second to eighth bits are used for representing a fourth value used for representing type information of data stored in the third data structure;

if the data type information that the fourth value is used for representing is integer data, the third preset data structure is composed of three bytes, and ninth to twenty-fourth bits are values for storing data;

if the data type represented by the fourth value is single-precision floating-point data, the third preset data structure is composed of five bytes, and ninth to forty bits are values for storing data;

if the data type indicated by the fourth value is double-precision floating-point data, the third preset data structure is composed of nine bytes, and the ninth bit to the seventy-th bit are values for storing data.

Optionally, the apparatus further includes a decompression module 64, configured to obtain a data sequence to be decompressed; obtaining type information of a data structure according to the first bit of data; and decompressing the data according to the type information of the data structure.

The decompression module 64 is further configured to: if the type information of the data structure is used for representing a second preset data structure or a third preset data structure, reading a second bit to an eighth bit;

if the values from the second bit to the eighth bit are the second preset value, judging that the data corresponding to the data structure are missing data;

if the values from the second bit to the eighth bit are the fourth value, obtaining the data stored in the data structure according to the data type information corresponding to the fourth value, and inserting the data into a decompression sequence;

if the type information of the data structure is used for representing a first preset data structure, acquiring the first value, the second value and the third value, acquiring a difference value between the second data and the first data according to the first value, the second value and the third value, adding the difference value and the first data to obtain the second data, and inserting the second data into the decompression sequence.

Optionally, the apparatus further includes a storage module 65, configured to create a compressed file including a compressed sequence after obtaining the compressed sequence corresponding to the data set; naming the compressed file according to a preset strategy to obtain a file name; storing, in a database, identification information of the power load devices and the data set, directory path information of the compressed file.

Therefore, the device disclosed by the invention can be used for compressing the same type of power data of the same power load equipment, calculating the difference value between the next data and the previous data according to the characteristic that the difference value between the two adjacent data is smaller, and storing the difference value through a data structure which occupies a smaller memory if the difference value is smaller than a first preset value, so that lossless compression on the basis of reducing the memory space is realized, and the speed of compressing the power load data is increased.

Fig. 7 is a schematic diagram of a terminal according to an embodiment of the present invention. As shown in fig. 7, the terminal 7 of this embodiment includes: a processor 70, a memory 71 and a computer program 72 stored in said memory 71 and executable on said processor 70. The processor 70, when executing the computer program 72, implements the steps in the above-described embodiments of the compression method for power load data, such as the steps 101 to 102 shown in fig. 1. Alternatively, the processor 70, when executing the computer program 72, implements the functions of the modules/units in the above-described device embodiments, such as the modules/units 61 to 65 shown in fig. 6.

Illustratively, the computer program 72 may be partitioned into one or more modules/units that are stored in the memory 71 and executed by the processor 70 to implement the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 72 in the terminal 7. For example, the computer program 72 may be divided into the modules/units 61 to 65 shown in fig. 6.

The terminal 7 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal 7 may include, but is not limited to, a processor 70, a memory 71. It will be appreciated by those skilled in the art that fig. 7 is only an example of a terminal 7 and does not constitute a limitation of the terminal 7, and that it may comprise more or less components than those shown, or some components may be combined, or different components, for example the terminal may further comprise input output devices, network access devices, buses, etc.

The Processor 70 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.

The memory 71 may be an internal storage unit of the terminal 7, such as a hard disk or a memory of the terminal 7. The memory 71 may also be an external storage device of the terminal 7, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) and the like provided on the terminal 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the terminal 7. The memory 71 is used for storing the computer program and other programs and data required by the terminal. The memory 71 may also be used to temporarily store data that has been output or is to be output.

It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.

In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.

Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.

In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal and method may be implemented in other ways. For example, the above-described apparatus/terminal embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.

The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.

The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method according to the above embodiments may be implemented by a computer program, which may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the steps of the embodiments of the method for compressing power load data may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media which may not include electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.

The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

18页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种混合云的数据存储方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!