Disclosure of Invention
In order to solve the above technical problem or at least partially solve the above technical problem, the present invention provides a data compression transmission method and apparatus, which solve the problem of data transmission performance degradation caused by network congestion when a database server is concurrently queried to obtain large data volume data under the condition of limited network bandwidth.
In order to achieve the above object, the embodiments of the present invention provide the following technical solutions:
in a first aspect, an embodiment of the present invention provides a data compression transmission method, which is applied to a client, and the method includes:
sending a first message to a server, wherein the first message is used for requesting to establish connection with the server; the first packet includes: a communication compression control parameter and a compression threshold parameter;
if the communication compression control parameter is not zero and the data packet size of the first data message is larger than the value of the compression threshold parameter, compressing the first data message according to a preset compression algorithm to generate a second data message; the first data message is a message with a fixed format obtained by encoding request data sent by an application layer according to a preset communication protocol; the second data message is a compressed data message of the first data message and carries compression identification information;
and sending the second data message to the server.
As an optional implementation manner in this embodiment of the present invention, after sending the first packet to the server, the method further includes:
receiving a second message sent by the server, wherein the second message is used for indicating whether the connection between the client and the server is successful or not;
judging whether the connection between the client and the server is successfully established according to the second message;
if the connection is successful, compressing the first data message according to a preset compression algorithm when the communication compression control parameter is not zero and the size of the data packet of the first data message is larger than the value of the compression threshold parameter to generate a second data message.
As an optional implementation manner in this embodiment of the present invention, after sending the second data packet to the server, the method further includes:
receiving a fourth data message sent by the server; the fourth data message is a data message decompressed by the third data message and carries compression identification information; the third data message is a data message generated after the first data message is subjected to database basic operation;
decompressing the fourth data message according to a preset compression algorithm, and recovering to obtain a third data message;
and sending the third data message to an application layer.
As an optional implementation manner of the embodiment of the present invention, if the communication compression control parameter is zero, or the packet size of the first data packet is smaller than or equal to the value of the compression threshold parameter, the first data packet is sent to the server.
As an optional implementation manner of the embodiment of the present invention, a data compression transmission method is provided, which is applied to a server, and the method includes:
receiving a first message sent by a client, wherein the first message is used for requesting to establish connection with a server; the first packet includes: a communication compression control parameter and a compression threshold parameter;
analyzing the first message to obtain the communication compression control parameter and the compression threshold parameter;
receiving a second data message sent by the client; the second data message is a compressed data message of the first data message and carries compression identification information; the first data message is a message with a fixed format obtained by encoding request data sent by an application layer according to a preset communication protocol;
decompressing the second data message according to a preset compression algorithm, and recovering to obtain a first data message;
and processing the first data message according to the decompression result to generate a third data message, wherein the third data message is generated after the first data message is subjected to database basic operation.
As an optional implementation manner in this embodiment of the present invention, after receiving a first packet sent by a client, the method further includes:
and sending a second message to the client, wherein the second message is used for indicating whether the connection between the client and the server is successful.
As an optional implementation manner in this embodiment of the present invention, after processing the first data packet according to a decompression result and generating a third data packet, the method further includes:
if the communication compression control parameter is not zero and the size of the data packet of the first data message is larger than the value of the compression threshold parameter, decompressing the third data message according to a preset compression algorithm to generate a fourth data message; the fourth data message is a data message decompressed by the third data message and carries compression identification information;
and sending the fourth data message to the client.
In a second aspect, an embodiment of the present invention provides a client, including:
the starting module is used for sending a first message to the server, and the first message is used for requesting to establish connection with the server; the first packet includes: a communication compression control parameter and a compression threshold parameter;
the compression module is used for compressing the first data message according to a preset compression algorithm to generate a second data message if the communication compression control parameter is not zero and the size of the data packet of the first data message is larger than the value of the compression threshold parameter; the first data message is a message with a fixed format obtained by encoding request data sent by an application layer according to a preset communication protocol; the second data message is a compressed data message of the first data message and carries compression identification information;
and the sending module is used for sending the second data message to the server.
As an optional implementation manner of the embodiment of the present invention, the client further includes:
the receiving response module is used for receiving a second message sent by the server, wherein the second message is used for indicating whether the connection between the client and the server is successful or not;
the judging connection module is used for judging whether the connection between the client and the server is successfully established according to the second message; if the connection is successful, compressing the first data message according to a preset compression algorithm when the communication compression control parameter is not zero and the size of the data packet of the first data message is larger than the value of the compression threshold parameter to generate a second data message.
As an optional implementation manner of the embodiment of the present invention, the client further includes:
the message receiving module is used for receiving a fourth data message sent by the server; the fourth data message is a data message decompressed by the third data message and carries compression identification information; the third data message is a data message generated after the first data message is subjected to database basic operation;
the message decompression module is used for decompressing the fourth data message according to a preset compression algorithm and recovering to obtain a third data message;
and the message sending module is used for sending the third data message to an application layer.
As an optional implementation manner of the embodiment of the present invention, the client further includes:
and the parameter judgment module is used for sending the first data message to the server side if the communication compression control parameter is zero or the size of the data packet of the first data message is smaller than or equal to the value of the compression threshold parameter.
In a third aspect, an embodiment of the present invention provides a server, including:
the connection module is used for receiving a first message sent by a client, wherein the first message is used for requesting to establish connection with a server; the first packet includes: a communication compression control parameter and a compression threshold parameter;
the analysis module is used for analyzing the first message to obtain the communication compression control parameter and the compression threshold parameter;
the receiving module is used for receiving a second data message sent by the client; the second data message is a compressed data message of the first data message and carries compression identification information; the first data message is a message with a fixed format obtained by encoding request data sent by an application layer according to a preset communication protocol;
the decompression module is used for decompressing the second data message according to a preset compression algorithm and recovering to obtain a first data message;
and the processing module is used for processing the first data message according to the decompression result to generate a third data message, wherein the third data message is generated after the first data message is subjected to database basic operation.
As an optional implementation manner of the embodiment of the present invention, the server further includes:
and the response sending module is used for sending a second message to the client, wherein the second message is used for indicating whether the connection between the client and the server is successful.
As an optional implementation manner of the embodiment of the present invention, the server further includes:
the compression processing module is used for decompressing the third data message according to a preset compression algorithm to generate a fourth data message if the communication compression control parameter is not zero and the size of the data packet of the first data message is larger than the value of the compression threshold parameter; the fourth data message is a data message decompressed by the third data message and carries compression identification information;
and the result sending module is used for sending the fourth data message to the client.
In a fourth aspect, an embodiment of the present invention provides an electronic device, which includes a memory and a processor, where the memory stores a computer program, and the processor implements the data compression transmission method according to the first aspect or any implementation manner of the first aspect when executing the computer program.
The data compression transmission method provided by the embodiment of the invention is applied to a client, and comprises the steps of firstly sending a first message comprising a communication compression control parameter and a compression threshold parameter to a server, then determining whether to compress the first data message according to the communication compression control parameter and the compression threshold parameter, compressing the first data message according to a preset compression algorithm to generate a second data message, and sending the second data message to the server. Because the first message comprises a communication compression control parameter and a compression threshold parameter, and the first data message is a message with a fixed format obtained by encoding request data sent by an application layer according to a preset communication protocol, before the request message is transmitted, the problem of CPU resource waste caused by compression processing of small data packets can be avoided by judging the relation between the size of the data packet of the first data message and the compression threshold parameter, and whether the first data message is compressed or not and the size of the compression ratio can be determined through the specific numerical value of the communication compression control parameter, so that the data transmission quantity is reduced, the data transmission density is increased, and the data transmission performance under a network bottleneck is improved.
Detailed Description
In order that the above objects, features and advantages of the present invention may be more clearly understood, a solution of the present invention will be further described below. It should be noted that the embodiments of the present invention and features of the embodiments may be combined with each other without conflict.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present invention may be practiced in other ways than those described herein; it is to be understood that the embodiments described in this specification are only some embodiments of the invention, and not all embodiments.
Relational terms such as "first" and "second," and the like may be used throughout the description and claims of the present invention to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
In the embodiments of the present invention, the words "exemplary" or "for example" are used to mean serving as an example, instance, or illustration. Any embodiment or design described as "exemplary" or "e.g.," an embodiment of the present invention is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the word "exemplary" or "such as" is intended to present concepts related in a concrete fashion. Further, in the description of the embodiments of the present invention, "a plurality" means two or more unless otherwise specified.
The overall concept of the embodiment of the invention is as follows: under the condition of limited bandwidth, when a service layer needs to perform concurrent query on a database server to obtain a large number of large result sets, a first message comprising communication compression control parameters and compression threshold parameters is sent to a server, whether the first data message is compressed or not is determined according to the communication compression control parameters and the compression threshold parameters, the first data message is compressed according to a preset compression algorithm to generate a second data message, and finally the second data message is sent to the server, so that the problem of data transmission performance reduction caused by network congestion is solved.
Network congestion refers to a phenomenon that when the number of packets in a certain part of a communication subnet is too large, the part of the network is too short to process, so that the performance of the part or even the whole network is reduced.
The application provides a data compression transmission method which can be applied to the application environment shown in fig. 1. FIG. 1 is a diagram illustrating an exemplary implementation of a data compression transmission method; the application environment includes aclient 11 and aserver 12. The client and the server are in data communication through a network. Specifically, a client sends a first message to a server, wherein the first message is used for requesting to establish connection with the server; the first packet includes: a communication compression control parameter and a compression threshold parameter; if the communication compression control parameter is not zero and the data packet size of the first data message is larger than the value of the compression threshold parameter, compressing the first data message according to a preset compression algorithm to generate a second data message; the first data message is a message with a fixed format obtained by encoding request data sent by an application layer according to a preset communication protocol; the second data message is a compressed data message of the first data message and carries compression identification information; and sending the second data message to the server. The client may be, but not limited to, various tablet computers, notebook computers, and desktop computers, and the server may be implemented by an independent server or a server cluster formed by a plurality of servers.
Based on the application scenario shown in fig. 1, an embodiment of the present invention provides a data compression transmission method, which is shown in fig. 2. In this embodiment, the data compression transmission method includes the following steps:
and S21, sending the first message to the server.
The first message is used for requesting to establish connection with a server; the first packet includes: a communication compression control parameter and a compression threshold parameter.
Specifically, the first message may be understood as a start message, which has two functions, and first, the connection opening message when the client communicates with the database server. When a client side inquires data through a database server, user authority verification is required to be firstly carried out, and a database is connected after a user name and a password are verified. Secondly, communication compression control parameters and compression threshold parameters are designed and added in the format of the starting message. In addition, the first packet may further include: application name, protocol version number, time format, precision and type of floating point number, etc.
The communication compression control parameter represents the transmission compression level of the communication between the client and the server, and the value range of the communication compression control parameter can be any integer from 0 to 9. Specifically, 0 indicates turning off communication compression, 1 to 9 indicates turning on the level of compression, the larger the number is, the higher the compression level is, the smaller the amount of transmission data after compression is, the higher the corresponding CPU consumption is. The value of the compression threshold parameter may be set according to network conditions and data transmission scenarios, for example, the value of the compression threshold parameter may be set to 100M.
For example, in one application scenario, the client and the server communicate according to the front-end and back-end communication protocol of the greater funding corporation, that is, communicate in the form of protocol data packets. For example, the first packet may include: host name, host IP address, host port, operation user name, operation user password, database name, compression level, compression byte, etc., examples are as follows: "host ═ myhost ═ 10.11.12.13, port ═ 54388, user ═ wli, password ═ asdfg 123! @ #, dbname ═ kingbase, comm _ compress ═ 2, and cmss _ min _ size ═ 1kbyte ". In practical applications, the communication protocol formats used by the client and the server in different application scenarios may be agreed by themselves, and are not limited herein.
Correspondingly, the server receives a first message sent by the client.
It can be understood that, in the present embodiment, the KCI interface provided by the human cash box (providing a native efficient C access interface) is utilized to implement access to the database, and mainly provides operations of connecting, disconnecting, performing add-delete-modify-check and transaction opening, transaction rollback, transaction commit, and the like for the database. In addition, a database connection pool and a monitoring thread and a maintenance thread are provided, so that the access efficiency of the database is improved.
Specifically, after receiving the first message sent by the client, the server executes step S31.
S31, analyzing the first message, and acquiring the communication compression control parameter and the compression threshold parameter.
Specifically, the server obtains a communication compression control parameter and a compression threshold parameter by analyzing the first message.
And S22, if the communication compression control parameter is not zero and the size of the data packet of the first data message is larger than the value of the compression threshold parameter, compressing the first data message according to a preset compression algorithm to generate a second data message.
The first data message is a message of a fixed format obtained by encoding request data sent by an application layer according to a preset communication protocol.
For example, the data communication compression function of the big vault database needs to select a proper compression algorithm to perform the compression and decompression functions. The data compression algorithm mainly comprises a lossy compression algorithm and a lossless compression algorithm, and the basic requirements on data in the database are accuracy and integrity, so the requirements of the data communication compression of the big gold storehouse on the compression algorithm can be completely restored, namely, the lossless compression algorithm is required. Meanwhile, considering that the contents to be compressed during data communication compression of the database of the big financial house are mainly text data contents and require high compression rate and compression efficiency, the preset compression algorithm can select an LZ77 algorithm to complete compression and decompression tasks of the data contents of the communication messages between the client and the server. The LZ77 algorithm uses a virtual window that can slide along with the compression process as a dictionary of terms, and the string to be compressed, if it appears in the window, outputs its appearance position and length. The term matching is carried out by using a fixed-size window instead of matching in all the coded information, because the time consumption of a matching algorithm is often large, the size of a dictionary must be limited to ensure the efficiency of the algorithm; as the compression progresses, the dictionary window is made to always contain the most recently encoded information, since for most information, the strings to be encoded tend to find matching strings more easily in the most recent context.
In addition, it is understood that, in different data communication scenarios, a suitable compression and decompression algorithm may be selected according to requirements, which is merely an example and is not limited specifically.
And S23, sending the second data message to the server.
The second data packet is a compressed data packet of the first data packet and carries the compression identification information.
For example, for implementing the data communication compression function, the data packet structure of the communication protocol between the client and the server of the big vault database may be as shown in table 1.
TABLE 1
Specifically, the compressed identification information may be represented by a character 'M', and after the message is decompressed, if the compressed identification bit of the data is 'M', the message is represented as a compressed message; if the compression identifier of the data is other characters or numbers, the message is represented as an uncompressed message.
Correspondingly, the server receives a second data message sent by the client.
Specifically, after receiving the second data message sent by the client, the server executes step S32.
And S32, decompressing the second data message according to a preset compression algorithm, and recovering to obtain the first data message.
The second data packet is a compressed data packet of the first data packet and carries the compression identification information.
And S33, processing the first data message according to the decompression result to generate a third data message.
The third data message is a data message generated after the first data message is subjected to database basic operation.
Specifically, the basic operations of the database include: basic operations of the database, such as creating the database, checking all information of the database, modifying a database coding set and removing the database; basic operations of the table, such as creating the table, viewing table information, modifying field attributes, removing the table; basic operations on fields, adding fields, deleting fields, inserting fields, modifying fields, looking up fields, etc.
Illustratively, after the first data packet is analyzed, the function of obtaining the packet is to add a field, and then a field adding operation is executed in a database corresponding to the server side to obtain a third data packet, where data of the third data packet includes a newly added field.
The data compression transmission method provided by the embodiment of the invention is applied to a client, and comprises the steps of firstly sending a first message comprising a communication compression control parameter and a compression threshold parameter to a server, then determining whether to compress the first data message according to the communication compression control parameter and the compression threshold parameter, compressing the first data message according to a preset compression algorithm to generate a second data message, and sending the second data message to the server. Because the first message comprises the communication compression control parameter and the compression threshold parameter, and the first data message is a message with a fixed format obtained by encoding the request data sent by the application layer according to a preset communication protocol, before the request message is transmitted, the problem of CPU resource waste caused by compression processing of small data packets can be avoided by judging the relation between the value of the compression threshold parameter and the size of the data packet of the first data message, and whether the first data message is compressed or not and the size of the compression ratio can be determined by the specific value of the communication compression control parameter, so that the data transmission quantity is reduced, the data transmission density is increased, and the data transmission performance under the network bottleneck is improved.
In an embodiment, on the basis of fig. 2, a data compression transmission method provided in an embodiment of the present invention, as shown in fig. 3, includes the following steps:
and S21, sending the first message to the server.
The first message is used for requesting to establish connection with a server; the first packet includes: a communication compression control parameter and a compression threshold parameter.
Correspondingly, the server receives a first message sent by the client.
Specifically, after receiving the first message sent by the client, the server executes step S31.
S31, analyzing the first message, and acquiring the communication compression control parameter and the compression threshold parameter.
Specifically, the server receives a first message for requesting connection, analyzes the first message, and stores a communication compression control parameter and a compression threshold parameter, wherein the two compression parameters are used as a basis for data compression processing in a subsequent data interaction process.
Before step S31, step S301 of sending a second message to the client is further performed.
And the second message is used for indicating whether the connection between the client and the server is successful.
Specifically, whether the connection between the client and the server is successfully established or not is judged according to the second message.
If the connection is successful, step S22 is executed.
And S22, if the communication compression control parameter is not zero and the size of the data packet of the first data message is larger than the value of the compression threshold parameter, compressing the first data message according to a preset compression algorithm to generate a second data message.
The first data message is a message of a fixed format obtained by encoding request data sent by an application layer according to a preset communication protocol; and the second data message is the compressed data message of the first data message and carries the compression identification information.
Specifically, when the first packet sent by the client sets the value of the communication compression control parameter to be non-zero, it indicates that the client needs to establish a connection for compressing the transmission data, and before the subsequent message is sent, if the size of the packet is larger than the set value of the compression threshold parameter, then compression processing is adopted.
And S23, sending the second data message to the server.
Correspondingly, the server receives a second data message sent by the client.
Specifically, after receiving the second data message sent by the client, the server executes step S32.
And S32, decompressing the second data message according to a preset compression algorithm, and recovering to obtain the first data message.
Specifically, after the server receives a second data message, which is sent by the client and is compressed with respect to the first data message, the second data message carries the compression identification information, and the second data message is determined to be a compressed message according to the compression identification information, so that the second data message is decompressed and recovered to obtain the first data message.
And S33, processing the first data message according to the decompression result to generate a third data message, wherein the third data message is generated after the first data message is subjected to database basic operation.
And S34, if the communication compression control parameter is not zero and the size of the data packet of the first data message is larger than the value of the compression threshold parameter, decompressing the third data message according to a preset compression algorithm to generate a fourth data message.
And the fourth data message is a data message decompressed by the third data message and carries compression identification information.
And S35, sending the fourth data message to the client.
Correspondingly, the client receives the fourth data message sent by the server.
Specifically, after receiving the fourth data packet sent by the server, the client performs step S24.
And S24, decompressing the fourth data message according to a preset compression algorithm, and recovering to obtain a third data message.
And S25, sending the third data message to an application layer.
Specifically, after the client receives a fourth data packet, which is sent by the server and is compressed with respect to the third data packet, since the fourth data packet carries the compression identification information, it is determined according to the compression identification information that the fourth data packet is a compressed packet, so that the fourth data packet is decompressed, the third data packet is recovered, and then the third data packet is sent to the application layer.
Illustratively, when a large result set is transmitted by a client and a server through a network concurrently, when a CPU is idle and the bandwidth is insufficient, the transmission efficiency is improved by starting a communication compression mode, and the overall performance is improved by about 30%. The following test is performed by taking a multithread concurrent acquisition large result set test scenario of the simulation power POC as an example:
wherein, the test database environment is: 64-core central processing unit, x86+220G memory, and hundred megabits of bandwidth. The test data size is: test table 500 has rows and 6 columns, data type int (integer) or varchar (variable length string), and each row has a size of about 16 kbytes. The test case environment is: JDK1.8, multithread concurrent execution query obtains results. By testing the compression effect table, it can be known that: when the starting compression level is 2, the efficiency is improved to the highest degree, and the efficiency is improved to about 25% -30%.
In addition, it should be noted that in this embodiment, the test is to use the CPU to replace the network resource, and a high-performance physical machine is required to process compression and decompression, otherwise the test effect may be greatly different.
In the process of data communication between the client and the server, a communication layer compression method is adopted to compress communication messages, so that the data transmission quantity is reduced, and the data transmission density is increased, thereby improving the transmission performance under the network bottleneck.
In an embodiment, if the communication compression control parameter is zero, or the packet size of the first data packet is smaller than or equal to the value of the compression threshold parameter, the first data packet is sent to the server.
Specifically, when the first packet of the client sets the communication compression control parameter to zero, which indicates that communication compression is closed, only the original data packet sent by the application layer needs to be transmitted. Or, when the size of the data packet of the first data packet is smaller than or equal to the value of the compression threshold parameter, it indicates that the data volume of the transmitted data packet is small, and the problem of consuming excessive network bandwidth in the transmission process is not caused, so that compression is not needed, and at this time, the original data packet is also only needed to be sent to the server.
In this case, the server receives the first data packet, and the compressed identification information carried by the first data packet is a character or a number other than the character 'M', which indicates that the first data packet is an uncompressed packet.
Correspondingly, the server executes step S33, and processes the first data packet according to the decompression result to generate a third data packet, where the third data packet is generated after the database basic operation is performed on the first data packet.
Specifically, since the first data packet is an uncompressed packet, it is not necessary to decompress the first data packet, and the first data packet is directly processed according to the analysis result of the first data packet. The specific processing manner has been described in the above embodiments, and is not described herein again.
In one embodiment, if the communication compression control parameter is zero, or the packet size of the third data packet is smaller than or equal to the value of the compression threshold parameter, the third data packet is sent to the client.
Specifically, before sending the data packet to the client, the server first determines whether the communication compression control parameter is zero, and if the communication compression control parameter is zero, it indicates that communication compression is closed, and then transmits a third data packet. And then judging whether the size of the data packet of the third data message is smaller than or equal to the value of the compression threshold parameter, if so, indicating that the data volume of the transmitted data packet is very small and the problem of consuming excessive network bandwidth in the transmission process is not caused, so that compression is not needed, and at the moment, only the uncompressed third data message needs to be sent to the server.
Correspondingly, the client receives the third data message, and since the compressed identification information carried by the third data message is other characters or numbers except for the character 'M', which indicates that the third data message is an uncompressed message, the third data message does not need to be decompressed, and the third data message is directly sent to the application layer.
In the process of data communication between the client and the server, the problem of CPU resource waste caused by processing of small data packets can be effectively avoided by the method of judging the communication compression control parameter and the compression threshold parameter before the client sends data and judging the communication compression control parameter and the compression threshold parameter before the server sends data.
The data compression transmission method provided by the embodiment of the invention is applied to a client, and comprises the steps of firstly sending a first message comprising a communication compression control parameter and a compression threshold parameter to a server, then determining whether to compress the first data message according to the communication compression control parameter and the compression threshold parameter, compressing the first data message according to a preset compression algorithm to generate a second data message, and sending the second data message to the server. Because the first message comprises a communication compression control parameter and a compression threshold parameter, and the first data message is a message with a fixed format obtained by encoding request data sent by an application layer according to a preset communication protocol, before the request message is transmitted, the problem of CPU resource waste caused by compression processing of small data packets can be avoided by judging the relation between the size of the data packet of the first data message and the compression threshold parameter, and whether the first data message is compressed or not and the size of the compression ratio can be determined through the specific numerical value of the communication compression control parameter, so that the data transmission quantity is reduced, the data transmission density is increased, and the data transmission performance under a network bottleneck is improved.
In one embodiment, as shown in fig. 4, there is provided aclient 400 comprising:
a startingmodule 410, configured to send a first message to a server, where the first message is used to request to establish a connection with the server; the first packet includes: a communication compression control parameter and a compression threshold parameter;
acompression module 420, configured to, if the communication compression control parameter is not zero and the size of the data packet of the first data packet is greater than the value of the compression threshold parameter, perform compression processing on the first data packet according to a preset compression algorithm to generate a second data packet; the first data message is a message with a fixed format obtained by encoding request data sent by an application layer according to a preset communication protocol; the second data message is a compressed data message of the first data message and carries compression identification information;
a sendingmodule 430, configured to send the second data packet to the server.
As an optional implementation manner of the embodiment of the present invention, the client further includes:
the receiving response module is used for receiving a second message sent by the server, wherein the second message is used for indicating whether the connection between the client and the server is successful or not;
the judging connection module is used for judging whether the connection between the client and the server is successfully established according to the second message; if the connection is successful, compressing the first data message according to a preset compression algorithm when the communication compression control parameter is not zero and the size of the data packet of the first data message is larger than the value of the compression threshold parameter to generate a second data message.
As an optional implementation manner of the embodiment of the present invention, the client further includes:
the message receiving module is used for receiving a fourth data message sent by the server; the fourth data message is a data message decompressed by the third data message and carries compression identification information; the third data message is a data message generated after the first data message is subjected to database basic operation;
the message decompression module is used for decompressing the fourth data message according to a preset compression algorithm and recovering to obtain a third data message;
and the message sending module is used for sending the third data message to an application layer.
As an optional implementation manner of the embodiment of the present invention, the client further includes:
and the parameter judgment module is used for sending the first data message to the server side if the communication compression control parameter is zero or the size of the data packet of the first data message is smaller than or equal to the value of the compression threshold parameter.
In one embodiment, as shown in fig. 5, there is provided aserver 500 comprising:
aconnection module 510, configured to receive a first message sent by a client, where the first message is used to request to establish a connection with a server; the first packet includes: a communication compression control parameter and a compression threshold parameter;
ananalyzing module 520, configured to analyze the first packet to obtain the communication compression control parameter and the compression threshold parameter;
areceiving module 530, configured to receive a second data packet sent by the client; the second data message is a compressed data message of the first data message and carries compression identification information; the first data message is a message with a fixed format obtained by encoding request data sent by an application layer according to a preset communication protocol;
thedecompression module 540 is configured to decompress the second data packet according to a preset compression algorithm, and recover to obtain a first data packet;
theprocessing module 550 is configured to process the first data packet according to the decompression result to generate a third data packet, where the third data packet is generated after the database basic operation is performed on the first data packet.
As an optional implementation manner of the embodiment of the present invention, the server further includes:
and the response sending module is used for sending a second message to the client, wherein the second message is used for indicating whether the connection between the client and the server is successful.
As an optional implementation manner of the embodiment of the present invention, the server further includes:
the compression processing module is used for decompressing the third data message according to a preset compression algorithm to generate a fourth data message if the communication compression control parameter is not zero and the size of the data packet of the first data message is larger than the value of the compression threshold parameter; the fourth data message is a data message decompressed by the third data message and carries compression identification information;
and the result sending module is used for sending the fourth data message to the client.
Fig. 6 is a schematic structural diagram of the electronic device for data compression and transmission according to the embodiment of the present invention. As shown in fig. 6, the electronic device for data compression and transmission provided by this embodiment includes: amemory 61 and aprocessor 62, thememory 61 being for storing computer programs; theprocessor 62 is configured to execute the steps performed by any of the embodiments of the data compression transmission method provided by the above-mentioned method embodiments when calling the computer program.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media having computer-usable program code embodied in the medium.
The processor may be a Central Processing Unit (CPU), other general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer readable media include both permanent and non-permanent, removable and non-removable storage media. Storage media may implement information storage by any method or technology, and the information may be computer-readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include transitory computer readable media (transmyedia) such as modulated data signals and carrier waves.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present disclosure, which enable those skilled in the art to understand or practice the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.