zoukankan      html  css  js  c++  java
  • sphinx索引分析——文件格式和字典是double array trie 检索树,索引存储 – 多路归并排序,文档id压缩 – Variable Byte Coding

    1 概述

    这是基于开源的sphinx全文检索引擎的架构代码分析,本篇主要描述index索引服务的分析。当前分析的版本 sphinx-2.0.4

    2 index 功能

    3 文件表

    4 索引文件结构

    4.1 spa 文件

    存储文档属性,在extern文档信息存储模式下使用。

    spa文件格式 => 属性值存储
    itemitemitemitemitem
    docid attr0 attr1 attr mva(spm file position)
    spa文件格式 => 在文件的末尾存储每个属性的最大最小值
    itemitemitemitemitemitemitem
    attr0 min attr1 min attr0 max attr1 max attr mva max

    4.2 spi 文件

    存储词列表,词id和指向spd文件的指针。

    • wordid 采用crc32编码
    • 每64个word插入一个检查点,重新开始存储wordid和spd文件偏移的差值
    • 保存doc的计数值,hit的计数值
    spi文件格式 => 倒排索引存储
    itemitemitemitem
    wordid(crc32)或vlb spd文件偏移的差值 doc的计数值 hit的计数值
    spi文件格式 => 文件的末尾存储文件内的检查点信息
    itemitemitem
    checkpoint1 sWord len sWord 在文件内的 offset

    4.3 spd 文件

    存储每个词id可匹配的文档id列表。

    文件格式 => 只有一次命中的时候
    itemitemitemitem
    docid vlb hit count hit field hit position
    文件格式 => 多次命中的时候
    itemitemitemitem
    docid vlb hit count field mask hit file(spp) position 差值

    4.4 sph 文件

    存储索引头信息。

    格式0
    item0item1item2item3item4
    version bits docinfo mode schema min doc
    格式1
    item5item6item7item8item 9
    ckpoint pos ckpoint count total doc total bytes index setting
    格式2
    item10item 11item12item13
    tokenizer dictionary kill list min max index

    4.5 spk 文件

    存储kill-lists信息。

    4.6 spm 文件

    存储mva数据

    • 分块存储
    • 多路归并排序,创建spm文件
    spm文件格式
    itemitemitem
    docid A a0,a1,a2 … B b0,b1,b2 …

    4.7 sps 文件

    存储字符串属性

    4.8 spp 文件

    4.8.1 第一次扫描创建的命中文件(临时存储命中信息)

    存储每个词的命中数。

    • 文件内分块存储
    • 块内同类递增排序,优先级为 wordid > docid > hitpos
    • 在wordid,docid相等的条件下,hitpos差分存储
    • 在wordid相等的条件下docid差分存储
    • wordid差分存储
    hit block 的存储结构列表如下
    itemitemitemitemitem
    wordid0 docid0 pos0, pos1, pos2 … hitcount field mask
      docid1 pos0, pos1, pos2 … hitcount field mask
      docid2 pos0, pos1, pos2 … hitcount field mask
    wordid1 docid0 pos0, pos1, pos2 … hitcount field mask
      docid1 pos0, pos1, pos2 … hitcount field mask

    4.8.2 最终创建的spp文件格式

    当doc切换后存储的第一个是hit position, 后面存储的是差值。

    spp文件存储格式
    item
    hit position 差值

    4.9 sps 文件

    存储字符串属性数据。

     

  • 相关阅读:
    iOS 关于字体根据不同屏幕尺寸等比适配的问题(zz)
    安卓开发:一种快速提取安卓app的UI图标资源的方法
    申请邓白氏编码的时候总是提示 Enter a valid Street Address 怎么办?
    利用日期、经纬度求日出日落时间 C语言程序代码(zz)
    JS导出Excel 代码笔记
    Bootstrap系列 -- 44. 分页导航
    Bootstrap系列 -- 43. 固定导航条
    Bootstrap系列 -- 42. 导航条中的按钮、文本和链接
    Bootstrap系列 -- 41. 带表单的导航条
    Bootstrap系列 -- 40. 导航条二级菜单
  • 原文地址:https://www.cnblogs.com/bonelee/p/6251091.html
Copyright © 2011-2022 走看看