「Redis设计与实现」快速列表篇

  • 每个快速列表节点使用一个quicklist.h/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 */
    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;
  • quicklist用于持有quicklistNode节点
typedef struct quicklist {
    quicklistNode *head;
    quicklistNode *tail;
    unsigned long count;        /* total count of all entries in all ziplists */
    unsigned long len;          /* number of quicklistNodes */
    int fill : 16;              /* fill factor for individual nodes */
    unsigned int compress : 16; /* depth of end nodes not to compress;0=off */
} quicklist;
  • 每个快速列表节点使用一个quicklist.h/quicklistNode结构来表示
typedef struct quicklist {
    quicklistNode *head;
    quicklistNode *tail;
    unsigned long count;        /* total count of all entries in all ziplists */
    unsigned long len;          /* number of quicklistNodes */
    int fill : 16;              /* fill factor for individual nodes */
    unsigned int compress : 16; /* depth of end nodes not to compress;0=off */
} quicklist;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Redis主要支持的数据类型有5种:String ,Hash ,List ,Set ,和 Sorted Set。 ...
    爱情小傻蛋阅读 1,437评论 0 0
  • feisky云计算、虚拟化与Linux技术笔记posts - 1014, comments - 298, trac...
    不排版阅读 3,917评论 0 5
  • 毫不夸张地讲,今天真是从开学到现在过得最充实,最满意,最有意义的一天。从早晨六点起床,到此时此刻,真是感觉每分每秒...
    颖尼格马阅读 170评论 0 1
  • 1、一个人最好的生活状态,该看书时看书,该玩时尽情玩,有自己的生活和小情趣,没人爱时专注自己,有人爱时,有能力拥抱...
    然若一阅读 1,073评论 0 32
  • 解决问题,都是要付代价的。代价,就是成本。成本,是不去解决问题,就不会感受到的损失。就像,你不去买早餐,钱包里就不...
    陳靜純阅读 129评论 0 0