Field信息:

DocumentWriter类中曾经描述,DocumentWriter类的一个功能是调用与

Field相关的类,写Field信息。写Field信息有两个类FieldInfos类和FieldWriter类,前者是用于写Field name信息,后者写Field value信息。

 

1.Field name信息:

Field name信息是用FieldInfo结构体表示,即FieldInfo表示一个Field

name信息。FieldInfos操作所有的FieldInfo,读和写操作,类似SegmentInfoSegmentInfos

   FieldInfo结构如下:

      String name;// The name of the field

      boolean isIndexed;// true if the field is indexed

      int number;

boolean storeTermVector;// true if the term vector should be stored

      // true if the term vector with offsets should be stored

boolean storeOffsetWithTermVector;      

//true if the term vector with positions should be stored

boolean storePositionWithTermVector;

// true if the norms for the indexed field should be omitted

boolean omitNorms;

  

   FieldInfos类和Field的关系可以看成SegmentInfosSegInfos的关系。但FieldInfos并不像SegmentInfos一样,继承自于Vector,而是包含了容器类型的变量。这里有两个容器,ArrayListHashMap,提供了按NameNumber两种存储。

   最终,FieldInfos写的文件(fnm)结构如下:

FieldInfos (.fnm)

 <ul>

<li>field的个数,int</li>

<li>field的名字,string类型<li>

<li>byte类型,记录该Field的相关信息,包括:

isIndexedstoreTermVectorstoreOffsetWithTermVector

storePositionWithTermVectoromitNorms

 每个信息用一个bit表示,1表示是,0表示否

</li>

</ul>

 

2.Field value信息:

FieldWriter类用于写FieldValue信息,这有两个文件fdx文件和fdt

文件。Fdx文件为域索引文件,记载相应的field在域值的指针;fdt则是域值信息。

   Fdx文件中文档n的域值信息就存在n*8的位置,格式如下:

Fdx:< FieldvaluesPosition > SegSize 

 

Fdt文件的格式如下:

Fdt:< FieldCount, <FieldNum, Bits, value>FieldCount>DocCount
posted on 2008-07-12 22:57  wanghoney  阅读(378)  评论(0编辑  收藏  举报