2

Lucene系列(18)索引格式之kdm文件

 3 years ago
source link: http://huyan.couplecoders.tech/lucene/%E6%90%9C%E7%B4%A2%EF%BC%8C%E7%B4%A2%E5%BC%95%E6%96%87%E4%BB%B6/2021/04/02/lucene%E7%B3%BB%E5%88%97(18)%E7%B4%A2%E5%BC%95%E6%A0%BC%E5%BC%8F%E4%B9%8Bkdm%E6%96%87%E4%BB%B6/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

本文使用 Lucene 代码版本:8.7.0

本文学习kdm文件格式.

kdm,kdi,kdd 三个文件共同存储了Lucene中Point类型的数据及索引,Point存储及搜索过程中使用BKD树数据结构,因此这三个文件和BKD关系比较密切, 建议在阅读前了解相关的BKD树理论.

BKD树简单理论介绍

Lucene中对于BKD树的实现源码

.kdm 文件整体结构

2021-04-12-21-00-48

字段解析:

  • FileNumber: 域的名字
  • Meta: 对应的元数据
  • -1: 占位符
  • indexFilePoint: 索引文件(kdi)文件的指针
  • DataFilePointer: 数据文件(kdd)文件的指针

  • CodecHeader: 编码头
  • Dims: 数据存储的维度
  • IndexDims: 数据索引的维度
  • MaxPointInLeaf: 叶子中存储Point的最大数量
  • bytePerDim: 每个维度的数据长度
  • LeafNum: 叶子节点的数量
  • minPoint: 最大的点的值
  • maxPoint: 最大的点的值
  • pointCount: 点的数量
  • docCount: 出现的文档的数量
  • IndexLength:索引的长度
  • DataFilePointer: 数据文件的指针
  • IndexFilePointer: 索引文件的指针

相关写入代码分析

kdm文件的写入比较集中,大部分在org.apache.lucene.util.bkd.BKDWriter.writeIndex(org.apache.lucene.store.IndexOutput, org.apache.lucene.store.IndexOutput, int, int, byte[], long)中.

2021-04-12-21-03-48

比较简单,水一下.

最后,欢迎关注我的个人公众号【 呼延十 】,会不定期更新很多后端工程师的学习笔记。 也欢迎直接公众号私信或者邮箱联系我,一定知无不言,言无不尽。 %E6%89%AB%E7%A0%81_%E6%90%9C%E7%B4%A2%E8%81%94%E5%90%88%E4%BC%A0%E6%92%AD%E6%A0%B7%E5%BC%8F-%E6%A0%87%E5%87%86%E8%89%B2%E7%89%88.png

以上皆为个人所思所得,如有错误欢迎评论区指正。

欢迎转载,烦请署名并保留原文链接。

联系邮箱:[email protected]

更多学习笔记见个人博客或关注微信公众号 < 呼延十 >——>呼延十



About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK