diff options
author | antirez <antirez@gmail.com> | 2016-12-16 09:04:57 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2016-12-16 09:04:57 +0100 |
commit | d634c36253125e7f07bb161d76a89e3649213d6a (patch) | |
tree | 8dc07e9923ec822d4003b43c3db9140faeec4718 /src | |
parent | ac61f9062583d67dd43f7d698824464d1e30d84b (diff) | |
download | redis-d634c36253125e7f07bb161d76a89e3649213d6a.tar.gz |
ziplist.c explanation of format improved a bit.
Diffstat (limited to 'src')
-rw-r--r-- | src/ziplist.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/ziplist.c b/src/ziplist.c index f7d7877f7..684f8ccf8 100644 --- a/src/ziplist.c +++ b/src/ziplist.c @@ -8,24 +8,31 @@ * * ---------------------------------------------------------------------------- * - * ZIPLIST OVERALL LAYOUT: + * ZIPLIST OVERALL LAYOUT + * * The general layout of the ziplist is as follows: - * <zlbytes><zltail><zllen><entry><entry><zlend> * - * <zlbytes> is an unsigned integer to hold the number of bytes that the - * ziplist occupies. This value needs to be stored to be able to resize the + * <zlbytes> <zltail> <zllen> <entry> <entry> ... <entry> <zlend> + * + * All fields are stored in little endian. + * + * <uint32_t zlbytes> is an unsigned integer to hold the number of bytes that + * the ziplist occupies. This value needs to be stored to be able to resize the * entire structure without the need to traverse it first. * - * <zltail> is the offset to the last entry in the list. This allows a pop - * operation on the far side of the list without the need for full traversal. + * <uint32_t zltail> is the offset to the last entry in the list. This allows + * a pop operation on the far side of the list without the need for full + * traversal. + * + * <uint16_t zllen> is the number of entries. When this value is larger + * than 2^16-2, we need to traverse the entire list to know how many items it + * holds. * - * <zllen> is the number of entries.When this value is larger than 2**16-2, - * we need to traverse the entire list to know how many items it holds. + * <uint8_t zlend> is a single byte special value, equal to 255, which + * indicates the end of the list. * - * <zlend> is a single byte special value, equal to 255, which indicates the - * end of the list. + * ZIPLIST ENTRIES * - * ZIPLIST ENTRIES: * Every entry in the ziplist is prefixed by a header that contains two pieces * of information. First, the length of the previous entry is stored to be * able to traverse the list from back to front. Second, the encoding with an |