clucene中segments.gen文件分析

1,作用

随着索引的文件发生变化,比如删除索引等,会使得index中存在多个segments_N,一些older generation的索引暂时不能被删掉,例如正在提交的索引或是一些自定义策略如IndexDeletionPolicy的使用。而程序打开索引的时候,只能选择一个generation打开。
Lucene每次都会选最大N对应的segments索引的打开。
2, 格式

segments.gen文件的物理结构包括一个

Int32位的version头,和两个Int64位的generation

具体代码在 void SegmentInfos::write(Directory* directory)

output = directory->createOutput(IndexFileNames::SEGMENTS_GEN);
      try {
        output->writeInt(FORMAT_LOCKLESS);
        output->writeLong(generation);
        output->writeLong(generation);
      } _CLFINALLY(
        output->close();
        _CLDELETE(output);
      )

发布了48 篇原创文章 · 获赞 7 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/wenxinfly/article/details/102626325
gen