#Key Compression
07-Jan-90 15:39:00
Sb: #23530-#Key Compression
Fm: Al Stevens 71101,1262
To: shmuel cohen 70431,1617
Shmuel,
I've done it, and I talk about it in the upcoming June 1990 issue, but I
didn't include any source code. Here's how I do it.
Keys in a b-tree node are in collated sequence. The first key in a node
is always whole, that is it contains all its ASCII characters. If the next
key repeats any of the leading characters of the first, the repeated
characters are replaced by an escape sequence that specifies how many
characters repeat. This is a form of run-length-encoding. So if you had
these keys:
program, programmed, programmer, progress, progressive
the compressed form would be:
program, <7>med, <9>r, <5>ess, <8>ive
The bracketed digits represent the count which must take a form that
distinguishes them from valid characters. A tree navigator must be serial.
It must start at the first key in order to reconstruct any subsequent
compressed keys.
Al Stevens