Sample resolution of Lucene 3.0.0 (4)-indexfiles.java

Source: Internet
Author: User

I. Termhashperfield.add () method

This chapter goes on to the above, and in the previous chapter the Termhashperfield.add () method is the process of adding a term to the posting table, so I'll analyze the Add () method from the perspective of the algorithm:

final char[] tokenText = termAtt.termBuffer();;
final int tokenTextLen = termAtt.termLength();

The main thing to do in these two lines is to get the content and length of the words that are currently being parsed.

int downto = tokentextlen
int code = 0;
while (Downto > 0) {
Char ch = tokentext[--downto];

if (ch >= unicodeutil.uni_sur_low_start && ch <= unicodeutil.uni_sur_low_end) {
if (0 = down    To) {
//unpaired
ch = tokentext[downto] = Unicodeutil.uni_replacement_char;
    else {
Final char CH2 = tokentext[downto-1];
if (CH2 >= unicodeutil.uni_sur_high_start && CH2 <= unicodeutil.uni_sur_high_end) {
//Ok:high fol Lowed by the low.      This is a valid
//surrogate pair.
Code = ((code*31) + ch) *31+ch2;
downto--;
Continue;    
} else {
//unpaired
ch = tokentext[downto] = Unicodeutil.uni_replacement_char;
'
}
' Else if (ch >= unicodeutil.uni_sur_high_start && (ch <= unicodeutil.uni_sur_high_end | | 
ch = = 0xFFFF)) {
//unpaired or 0xffff
ch = tokentext[Downto] = Unicodeutil.uni_replacement_char;
}

Code = (code*31) + ch;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.