internal void Seek(long pointer, long p, Term t, TermInfo ti) { input.Seek(pointer); position = p; termBuffer.Set(t); prevBuffer.Reset(); termInfo.Set(ti); }
/// <summary>Called when we are done adding docs to this term </summary> internal override void Finish() { long skipPointer = skipListWriter.WriteSkip(out_Renamed); // TODO: this is abstraction violation -- we should not // peek up into parents terms encoding format termInfo.Set(df, parent.freqStart, parent.proxStart, (int)(skipPointer - parent.freqStart)); // TODO: we could do this incrementally UnicodeUtil.UTF16toUTF8(parent.currentTerm, parent.currentTermStart, utf8); if (df > 0) { parent.termsOut.Add(fieldInfo.number, utf8.result, utf8.length, termInfo); } lastDocID = 0; df = 0; }
/// <summary>Adds a new <fieldNumber, termBytes>, TermInfo> pair to the set. /// Term must be lexicographically greater than all previous Terms added. /// TermInfo pointers must be positive and greater than all previous. /// </summary> internal void Add(int fieldNumber, byte[] termBytes, int termBytesLength, TermInfo ti) { System.Diagnostics.Debug.Assert(CompareToLastTerm(fieldNumber, termBytes, termBytesLength) < 0 || (isIndex && termBytesLength == 0 && lastTermBytesLength == 0), "Terms are out of order: field=" + fieldInfos.FieldName(fieldNumber) + " (number " + fieldNumber + ")" + " lastField=" + fieldInfos.FieldName(lastFieldNumber) + " (number " + lastFieldNumber + ")" + " text=" + System.Text.Encoding.UTF8.GetString(termBytes, 0, termBytesLength) + " lastText=" + System.Text.Encoding.UTF8.GetString(lastTermBytes, 0, lastTermBytesLength)); System.Diagnostics.Debug.Assert(ti.freqPointer >= lastTi.freqPointer, "freqPointer out of order (" + ti.freqPointer + " < " + lastTi.freqPointer + ")"); System.Diagnostics.Debug.Assert(ti.proxPointer >= lastTi.proxPointer, "proxPointer out of order (" + ti.proxPointer + " < " + lastTi.proxPointer + ")"); if (!isIndex && size % indexInterval == 0) { other.Add(lastFieldNumber, lastTermBytes, lastTermBytesLength, lastTi); // add an index term } WriteTerm(fieldNumber, termBytes, termBytesLength); // write term output.WriteVInt(ti.docFreq); // write doc freq output.WriteVLong(ti.freqPointer - lastTi.freqPointer); // write pointers output.WriteVLong(ti.proxPointer - lastTi.proxPointer); if (ti.docFreq >= skipInterval) { output.WriteVInt(ti.skipOffset); } if (isIndex) { output.WriteVLong(other.output.FilePointer - lastIndexPointer); lastIndexPointer = other.output.FilePointer; // write pointer } lastFieldNumber = fieldNumber; lastTi.Set(ti); size++; }
/// <summary>Sets the argument to the current TermInfo in the enumeration. /// Initially invalid, valid after next() called for the first time. /// </summary> internal void TermInfo(TermInfo ti) { ti.Set(termInfo); }