If youre crunching XML, it often makes sense to extract important info (customer number, customer job, quote id, etc.) that can be saved as normal columnar data to aid the search and retrieval of the compressed data.Recording this information in a database table can impose a significant tax on disk space.However, using a compression algorithm can alleviate this tax.
In this tip, Ill demonstrate two user-defined functions that implement ZLib compression to deflate and inflate data that is stored or accessed via DB2 as a large object data type (BLOB, CLOB, and XML). Multimedia files often involve large data that can be a problem to store and render. Advanced Folder Encryption 6.75 Registration Code Mp4 Video FilesFamiliar examples of multimedia compression include JPEG images, mp3 audio files, and mp4 video files. Unlike multimedia compression, data loss isnt acceptable with business documents, so a lossless algorithm is used to compress the data. Zlib is one such lossless compression algorithm, meaning that after being compressed and uncompressed, the data is restored to its exact original form. The aim of this article presents two user-defined DB2 for i functions called DEFLATE and INFLATE that are built to crunch and uncrunch large data columns and variables. On the IBM i, I figured CC would perform better than Java, so I sought a CC compression library. Advanced Folder Encryption 6.75 Registration Code Free Code IOut of all the free code I came across on the Internet, miniz was relatively simple for a non CC guy like myself. The primary reason for using a locator is memory management when compressing a wide range of data sizes. There are only two public methods meant for use by DB2 in this code: zlibinflate and zlibdeflate. For this project, I downloaded the latest version available: v1.14. These CREATE FUNCTION SQL statements are in the source header. For an introduction to writing external user-defined functions using RPG, see Reuse Your RPG Code with SQL User-Defined Functions. Three of them are called DEFLATE, and they accept a BLOB, CLOB, or XML parameter. The remaining three are called INFLATE (for BLOBs), INFLATECLOB, and INFLATEXML. However, use the correct INFLATE function to get the data back in its original format. All these functions use the same C code; the only difference among them is how DB2 interprets the data its exchanging with the function. However, because DB2 does not support the CAST of binary data back to DBCS (without writing a helper function), the ability to INFLATE double-byte data is currently unsupported. The compressed file size is only about 35K and the statement took about second to complete. If I had to store this kind of file in an application, I could crunch it and save about 30 in space, although it took 6.75 minutes on my virtualized test machine to deflate it (again the compression level was set to 10, which is max compression but minimal speed). Other document formats, such as PDFs, already store some of their elements, such as images, compressed (using zlib compression oddly enough), so large PDFs may not compress very well if their size is due to image content.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |