Start fmn index
IndexWriter:addDocument -> DocumentWriter:addDocument
Document object in lucene store origin target’s properties
The property fieldInfos
in DocumentWriter
store fields
1 | private FieldInfos fieldInfos; |
Build fmn index
1 |
|
write field size before loop
write field’s name in loop
write field’s setting in loop
If a document field’s name is name
store in index and tokenized
then xxx.fmn
will be like this
1 | 01 04 6e 61 6d 65 01 |
01
is fields size04
is field length6e 61 6d 65
is ASCII of name
01
is field setting
[size][01 lenght][01][01 setting][02 lenght][02][02 setting]……
Lucene type
In abstract class IndexOutput
self define type method1
2
3
4
5
6
7
8
9
10public void writeVInt(int i) throws IOException {
while ((i & ~0x7F) != 0) {
writeByte((byte)((i & 0x7f) | 0x80));
i >>>= 7;
}
writeByte((byte)i);
}
public void writeVLong(long i) throws IOException {
...
}
The variable int/long format, smaller values take fewer bytesint
writes between one and five bytes.long
writes between one and nine bytes.
0x7F
filt origin type no longer than 1 byte.(i & 0x7F) | 0x80
make byte first bit is 1
.
1 | public void writeString(String s) throws IOException { |
Write string’s length first.
Write String’s char array then.
1 | public void writeChars(String s, int start, int length) throws IOException { |
Write ASCII directly [1 byte]
Write UTF-8 two bytes [2 byte]
Write UTF-8 three bytes [3 byte]