base:streaming_1_2_4_8-bit_numbers_without_spanning_bytes
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
base:streaming_1_2_4_8-bit_numbers_without_spanning_bytes [2019-10-06 12:56] – created white_flame | base:streaming_1_2_4_8-bit_numbers_without_spanning_bytes [2019-10-06 13:09] (current) – white_flame | ||
---|---|---|---|
Line 5: | Line 5: | ||
As long as you're outputting 1, 2, 4, and 8 bit tokens (not 3 or 5-7 bit), you can keep all the bitfields aligned so they do not span byte boundaries, making the reading simpler. | As long as you're outputting 1, 2, 4, and 8 bit tokens (not 3 or 5-7 bit), you can keep all the bitfields aligned so they do not span byte boundaries, making the reading simpler. | ||
- | The reader will hold a byte buffer each for reading 1, 2, or 4-bit values. | + | The reader will hold a byte-sized |
- | The writer packs only tokens of the same bit length into each byte, creating a new output byte at the end of the stream whenever a new byte buffer for that bit length is required. The writer remembers where in the stream the various buffer bytes for each bit length resides, adding to it in place until it's full. | + | The writer packs only tokens of the same bit length into each byte, creating a new output byte at the end of the stream whenever a new buffer for that bit length is required. The writer remembers where in the stream the various buffer bytes for each bit length resides, adding to it in place until it's full. |
Example of writing this arbitrary token stream: | Example of writing this arbitrary token stream: | ||
Line 32: | Line 32: | ||
11: Write into the 2-bit buffer byte: | 11: Write into the 2-bit buffer byte: | ||
< | < | ||
+ | 11: Write into the 2-bit buffer byte: | ||
+ | < | ||
0101: Since the 4-bit buffer byte is full, create a new byte at the end of the stream for it: | 0101: Since the 4-bit buffer byte is full, create a new byte at the end of the stream for it: | ||
- | < | + | < |
When the specifically 1/2/4/8-bit reads are done in the same order as the writes were, all ordering is preserved. | When the specifically 1/2/4/8-bit reads are done in the same order as the writes were, all ordering is preserved. |
base/streaming_1_2_4_8-bit_numbers_without_spanning_bytes.txt · Last modified: 2019-10-06 13:09 by white_flame