Mastering SQL Server 2017 by Miloš Radivojević

Mastering SQL Server 2017 by Miloš Radivojević

Author:Miloš Radivojević [Miloš Radivojević]
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2019-08-14T11:55:16+00:00


Find the longest match in the window for the look-ahead buffer

If a match is found, output the pointer P and move the coding position (and the window) L bytes forward

If a match is not found, output a null pointer and the first byte in the look-ahead buffer and move the coding position (and the window) one byte forward

If the look-ahead buffer is not empty, return to step 2

The following figure explains this process via an example:

LZ77 compression

The input stream chunk that is compressed in the figure is AABCBBABC:

The algorithm starts encoding from the beginning of the window of the input stream. It stores the first byte (the A value) in the result, together with the pointer (0,0), meaning this is a new value in this chunk.

The second byte is equal to the first one. The algorithm stores just the pointer (1,1) to the output. This means that in order to recreate this value, you need to move one byte back and read one byte.

The next two values, B and C, are new and are stored to the output together with the pointer (0,0).

Then the B value repeats. Therefore, the pointer (2,1) is stored, meaning that in order to find this value, you need to move two bytes back and read one byte.

Then the B value repeats again. This time, you need to move one byte back and read one byte to get the value, so the value is replaced with the pointer (1,1). You can see that when you move back and read the value, you get another pointer. You can have a chain of pointers.

Finally, the substring ABC is found in the stream. This substring can be also found in positions 2 to 4. Therefore, in order to recreate the substring, you need to move five bytes back and read 3 bytes, and the pointer (5,3) is stored in the compressed output.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.