1.IndexHeader 头部, 40 字节, 记录 IndexFile 的统计信息:
begainTimestamp: 该索引文件中包含消息的最小存储时间
endTimestamp: 该索引文件中包含消息的最大存储时间
begainPhyoffset: 该索引文件中包含消息的最大物理偏移量 (commitlog 文件偏移量)
endPhyoffset: 该索引文件中包含消息的最大物理偏移量 (commitlog 文件偏移量)
hashslotCount:hashslot 个数, 并不是 hash 槽的个数, 在这里意义不大
indexCount:Index 条目列表当前已使用的个数, Index 条目在 Index 条目列表中按顺序存储
2.Hash 槽, 一个 IndexFile 默认包含 500 万个 Hash 槽, 每个 Hash 槽存储的是落在该 Hash 槽的 hashcode 最新的 Index 的索引
3.Index 条目列表: 默认一个索引文件包含 2000 万个条目, 每一个 Index 条目结构如下
hashcode:key 的 hashcode
phyoffset: 消息对应的物理偏移量
timedif: 该消息存储时间与第一条消息的时间戳的差值, 小于 0 该消息无效
preIndexNo: 该条目的前一条记录的 Index 索引, 当出现 hash 冲突时, 构建的链表结构
关键: map<String 消息索引 key,long 消息物理偏移量 >
IndexFile#putKey
来源: http://www.bubuko.com/infodetail-3394674.html