Multi-strategy compression scheme
A system includes a memory and a processor, where the processor is in communication with the memory. The processor is configured to receive a request to compress a schema. The schema is analyzed to determine whether to apply a first type of compression or a second type of compression, where analyzing the schema includes determining whether the schema exceeds a threshold level. Upon determining that the schema exceed the threshold level, a compressed schema is generated by performing the second type of compression. Next, the processor responds to the request with the compressed schema.
1. A system, comprising:
a memory; and
a processor in communication with the memory, wherein the processor is configured to:
create an output message associated with an application, wherein the output message comprises data and a schema having contents;
setting a threshold level for schemas related to the application;
inspect the output message to determine whether to compress the output message;
analyze the schema to determine whether to apply a first type of compression or a second type of compression, wherein analyzing the schema includes determining based on the contents of the schema whether the schema exceeds the threshold level;
upon determining that the schema exceeds the threshold level, generate a compressed schema by performing the second type of compression;
upon determining that the schema is within the threshold level, generate the compressed schema by performing the first type of compression; and
send the output message comprising the data and the compressed schema.
2. The system of claim 1 , wherein the first type of compression is short text string compression and the second type of compression is text compression.
3. The system of claim 1 , wherein analyzing the schema comprises:
parsing the schema into words; and
determining whether an average length of the words is less than or equal to the threshold level.
4. The system of claim 1 , wherein analyzing the schema comprises:
determining a size of the schema; and
determining whether the size of the schema is less than or equal to the threshold level.
5. The system of claim 1 , wherein analyzing the schema comprises:
parsing the schema into words; and
determining a percentage of the words included in a curated dictionary is less than or equal to the threshold level.
6. A method, comprising:
creating an output message associated with an application, wherein the output message comprises data and a schema having contents;
setting a threshold level for schemas related to the application;
inspecting the output message to determine whether to compress the output message;
analyzing the schema to determine whether to apply a first type of compression or a second type of compression, wherein analyzing the schema includes determining based on the contents of the schema whether the schema exceeds the threshold level;
upon determining that the schema exceed the threshold level, generating a compressed schema by performing the second type of compression;
upon determining that the schema is within the threshold level, generating the compressed schema by performing the first type of compression; and
sending the output message comprising the data and the compressed schema.
7. The method of claim 6 , wherein the first type of compression is short text string compression and the second type of compression is text compression.
8. The method of claim 6 , wherein the second type of compression is a Huffman coding compression algorithm.
9. The method of claim 6 , wherein the first type of compression is a shoco compression algorithm.
10. The method of claim 6 , wherein analyzing the schema comprises:
parsing the schema into words; and
determining whether an average length of the words is less than or equal to the threshold level.
11. The method of claim 6 , wherein analyzing the schema comprises:
determining a size of the schema; and
determining whether the size of the schema is less than or equal to the threshold level.
12. The method of claim 6 , wherein analyzing the schema comprises:
parsing the schema into words; and
determining a percentage of the words included in a curated dictionary is less than or equal to the threshold level.
13. A non-transitory machine readable medium storing code, which when executed by a processor is configured to:
create an output message associated with an application, wherein the output message comprises data and a schema having contents;
set a threshold level for schemas related to the application;
inspect the output message to determine whether to compress the output message;
analyze the schema to determine whether to apply a first type of compression or a second type of compression, wherein analyzing the schema includes determining based on the contents of the schema whether the schema exceeds the threshold level;
upon determining that the schema exceed the threshold level, generate a compressed schema by performing the second type of compression;
upon determining that the schema is within the threshold level, generate the compressed schema by performing the first type of compression; and
send the output message comprising the data and the compressed schema.
14. The non-transitory machine readable medium of claim 13 , wherein the first type of compression is short text string compression and the second type of compression is text compression.
15. The non-transitory machine readable medium of claim 13 , wherein analyzing the schema comprises:
parsing the schema into words; and
determining whether an average length of the words is less than or equal to the threshold level.
16. The non-transitory machine readable medium of claim 13 , wherein analyzing the schema comprises:
determining a size of the schema; and
determining whether the size of the schema is less than or equal to the threshold level.
17. The non-transitory machine readable medium of claim 13 , wherein analyzing the schema comprises:
parsing the schema into words; and
determining a percentage of the words included in a curated dictionary is less than or equal to the threshold level.