标签:head nta 一个 元素 field tor class pre off
redis的List存储结构:一个链表加上压缩列表实现的
redis c语言源码
双向循环列表
# define QL_FILL_BITS 16
# define QL_COMP_BITS 16
# define QL_BM_BITS 4 /
typedef struct quicklist {
quicklistNode *head; 头节点
quicklistNode *tail; 尾节点
unsigned long count; /* total count of all entries in all ziplists */ ziplist里面存储的元素的数量
unsigned long len; /* number of quicklistNodes */ 节点数
int fill : QL_FILL_BITS; /* fill factor for individual nodes */ zplist挂在存在压缩列表的个数或者容量
unsigned int compress : QL_COMP_BITS; /* depth of end nodes not to compress;0=off */ 节点的zip;ist是否压缩
unsigned int bookmark_count: QL_BM_BITS;
quicklistBookmark bookmarks[];
} quicklist;
在每个quicklist里存储的很多个quicklistNod
/* quicklistNode is a 32 byte struct describing a ziplist for a quicklist. * We use bit fields keep the quicklistNode at 32 bytes. * count: 16 bits, max 65536 (max zl bytes is 65k, so max count actually < 32k). * encoding: 2 bits, RAW=1, LZF=2. * container: 2 bits, NONE=1, ZIPLIST=2. * recompress: 1 bit, bool, true if node is temporary decompressed for usage. * attempted_compress: 1 bit, boolean, used for verifying during testing. * extra: 10 bits, free for future use; pads out the remainder of 32 bits */
quicklistNode里面的存储 typedef struct quicklistNode { struct quicklistNode *prev; 上一个节点 struct quicklistNode *next;下一个节点 unsigned char *zl; 当前结点指针 unsigned int sz; 当前存储读诵好元素 /* ziplist size in bytes */ unsigned int count : 16; /* count of items in ziplist */ unsigned int encoding : 2; /* RAW==1 or LZF==2 */ unsigned int container : 2; /* NONE==1 or ZIPLIST==2 */ 选用一个ziplist unsigned int recompress : 1; /* was this node previous compressed? */ 启用压缩列表标记 unsigned int attempted_compress : 1; /* node can‘t compress; too small */ unsigned int extra : 10; /* more bits to steal for future usage */ } quicklistNode;
标签:head nta 一个 元素 field tor class pre off
原文地址:https://www.cnblogs.com/wangbiaohistory/p/14829568.html