《Redis 设计与实现》笔记 - 整数集合
数据结构
typedef struct intset {
// 编码方式
uint32_t encoding;
// 集合包含的元素数量
uint32_t length;
// 保存元素的数组
int8_t contents[];
} intset;+-------------------------+
| intset |
|-------------------------|
|encoding=INTSET_ENC_INT16|
|-------------------------|
| length=5 |
|-------------------------| +-----+--+--+---+-----+
| contents |-->|-6730|-5|18|233|14632|
+-------------------------+ +-----+--+--+---+-----+
+-------------------------+
| intset |
|-------------------------|
|encoding=INTSET_ENC_INT64|
|-------------------------|
| length=4 |
|-------------------------| +--------------------+-+-+-+
| contents |-->|-2675256175807981027|1|3|5|
+-------------------------+ +--------------------+-+-+-+升级策略
最后更新于