text stringlengths 0 99.6k |
|---|
can easily calculate where each record starts and thus |
randomly skip to any record in the file. THE MANAGER, and |
other database programs pad their records with spaces. In |
either case there is a great deal of space to be gained when |
packing this type of file. We have seen some DBASE III files |
in excess of 1 megabyte 'crunch' down to only 50,000 |
characters or so. Most of this is due to packing. |
ARC VERSION 2.20 PAGE - 29 |
There is one slight problem with this method. Suppose |
you are using a zero-byte as the control character. If a |
sequence of only one zero is encountered, you cannot code it |
to the output file since it will be interpreted as a control |
character. You must send a three byte control sequence to |
code the single zero. An example of this would be as |
follows: |
.:0801 06 08 01 00 8f 00 0c 08 |
.:0809 02 00 8f 00 12 08 03 00 |
.:0811 8f 00 00 00 00 00 00 00 and so on.... |
This would be stored on disk as the sequence: |
06 08 01 00 00 01 8f 00 00 01 0c 08 02 00 00 01 |
8f 00 00 01 12 08 03 00 00 01 8f 00 00 07 ..... |
We went from 24 bytes to 30! Not much of a savings. |
It is because of this problem with packing that |
squeezed files are occasionally shorter than their squashed |
equivalent. |
ARC VERSION 2.20 PAGE - 30 |
Huffman coding is somewhat more complex. It is probably |
the most elegant of all the compression methods used and |
certainly the most common. It takes advantage of the fact |
that some characters are used more often than others in |
most files. Text files contain many spaces, and letters |
like a,e or c are much more common than x, z, or q. Graphics |
files contain many zeros or $ff's and machine language |
programs tend to contain more LDA's and STA's than EOR's or |
ROR's. |
Suppose now that a file contains only the characters a |
through z. Since there are only 26 characters used, a five |
bit binary number, which can take on 32 possible values, |
would be more than adequate to represent each character. We |
could assign a five bit number to each of the characters a |
to z and gain 3 bits per character or 37.5% |
Huffman coding takes this one step further. |
Suppose also that some of the characters occur much |
more often in the file than do others. We could gain even |
more space if the frequently occurring characters were |
assigned codes less than five bits long, and the less |
frequently occurring characters were assigned codes that |
were five or more bits long. The Huffman algorithm does just |
that. |
The Huffman algorithm converts fixed length codes (8 |
bit characters) into codes whose length in bits is inversely |
proportional to their probability of occurrence in the data |
file. For example, suppose your data file looked something |
like this: |
ARC VERSION 2.20 PAGE - 31 |
abracadabra |
The character frequency distribution is as follows: |
total bits total bits |
character frequency huffman code unsqueezed squeezed |
--------- --------- ------------ ---------- ----------- |
a 5 0 8 * 5 = 40 1 * 5 = 5 |
b 2 10 8 * 2 = 16 2 * 2 = 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.