private void  WriteTerm(Term term)
        {
            int start  = StringHelper.StringDifference(lastTerm.text, term.text);
            int length = term.text.Length - start;

            output.WriteVInt(start);                              // write shared prefix length
            output.WriteVInt(length);                             // write delta length
            output.WriteChars(term.text, start, length);          // write delta chars

            output.WriteVInt(fieldInfos.FieldNumber(term.field)); // write field num

            lastTerm = term;
        }
Exemple #2
0
        private void  WriteTerm(int fieldNumber, char[] termText, int termTextStart, int termTextLength)
        {
            // Compute prefix in common with last term:
            int start = 0;
            int limit = termTextLength < lastTermTextLength ? termTextLength : lastTermTextLength;

            while (start < limit)
            {
                if (termText[termTextStart + start] != lastTermText[start])
                {
                    break;
                }
                start++;
            }

            int length = termTextLength - start;

            output.WriteVInt(start);                                    // write shared prefix length
            output.WriteVInt(length);                                   // write delta length
            output.WriteChars(termText, start + termTextStart, length); // write delta chars
            output.WriteVInt(fieldNumber);                              // write field num
        }