Breaking Eggs And Making Omelettes

Topics On Multimedia Technology and Reverse Engineering


Meta:

Clientside MySQL Compression

January 24th, 2008 by Multimedia Mike

I figured out yesterday's problem and the upshot is that x86_32 builds using gcc 2.95.3 have been reinstated for the FATE Server. So the nostalgic, sentimentalist users of FFmpeg should be happy to know the test suite is still being run through the old school compiler.

For reference, this is how to compress data using Python so that it will be suitable for insertion into a MySQL table (and so that MySQL will be able to decompress it with its built-in UNCOMPRESS() function):

PYTHON:
  1. import zlib
  2. from struct import *
  3.  
  4. # pack: the '<' symbol indicates little endian;
  5. # the 'l' means treat the quantity as a long (i.e., 4 bytes)
  6. compressed_string = pack('<l', len(raw_string))zlib.compress(raw_string, 9)

It can make an impressive difference, particularly with highly redundant text as is seen with compiler output. For example:

SQL:
  1. mysql> SELECT
  2.   LENGTH(stderr) AS encoded,
  3.   LENGTH(UNCOMPRESS(stderr)) AS decoded
  4.   FROM ...
  5.  
  6. +---------+---------+
  7. | encoded | decoded |
  8. +---------+---------+
  9. |   20831 | 1056570 |
  10. +---------+---------+

Posted in FATE Server, Python | No Comments »

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.