20 namespace Lucene.Net.Index
22 internal sealed
class SegmentTermEnum :
TermEnum, System.ICloneable
25 internal FieldInfos fieldInfos;
27 internal long position = - 1;
29 private TermBuffer termBuffer =
new TermBuffer();
30 private TermBuffer prevBuffer =
new TermBuffer();
31 private TermBuffer scanBuffer =
new TermBuffer();
35 private readonly
int format;
36 private readonly
bool isIndex =
false;
37 internal long indexPointer = 0;
38 internal int indexInterval;
39 internal int skipInterval;
40 internal int maxSkipLevels;
41 private readonly
int formatM1SkipInterval;
43 internal SegmentTermEnum(
IndexInput i, FieldInfos fis,
bool isi)
50 int firstInt = input.ReadInt();
59 skipInterval = System.Int32.MaxValue;
67 if (format < TermInfosWriter.FORMAT_CURRENT)
68 throw new CorruptIndexException(
"Unknown format version:" + format +
" expected " + TermInfosWriter.FORMAT_CURRENT +
" or higher");
70 size = input.ReadLong();
76 indexInterval = input.ReadInt();
77 formatM1SkipInterval = input.ReadInt();
81 skipInterval = System.Int32.MaxValue;
85 indexInterval = input.ReadInt();
86 skipInterval = input.ReadInt();
87 if (format <= TermInfosWriter.FORMAT)
90 maxSkipLevels = input.ReadInt();
93 System.Diagnostics.Debug.Assert(indexInterval > 0,
"indexInterval=" + indexInterval +
" is negative; must be > 0");
94 System.Diagnostics.Debug.Assert(skipInterval > 0,
"skipInterval=" + skipInterval +
" is negative; must be > 0");
96 if (format > TermInfosWriter.FORMAT_VERSION_UTF8_LENGTH_IN_BYTES)
98 termBuffer.SetPreUTF8Strings();
99 scanBuffer.SetPreUTF8Strings();
100 prevBuffer.SetPreUTF8Strings();
104 public System.Object Clone()
106 SegmentTermEnum clone = null;
109 clone = (SegmentTermEnum) base.MemberwiseClone();
111 catch (System.Exception)
116 clone.termInfo =
new TermInfo(termInfo);
118 clone.termBuffer = (TermBuffer) termBuffer.Clone();
119 clone.prevBuffer = (TermBuffer) prevBuffer.Clone();
120 clone.scanBuffer =
new TermBuffer();
125 internal void Seek(
long pointer,
long p,
Term t,
TermInfo ti)
135 public override bool Next()
137 if (position++ >= size - 1)
139 prevBuffer.Set(termBuffer);
144 prevBuffer.Set(termBuffer);
145 termBuffer.Read(input, fieldInfos);
147 termInfo.docFreq = input.ReadVInt();
148 termInfo.freqPointer += input.ReadVLong();
149 termInfo.proxPointer += input.ReadVLong();
157 if (termInfo.docFreq > formatM1SkipInterval)
159 termInfo.skipOffset = input.ReadVInt();
165 if (termInfo.docFreq >= skipInterval)
166 termInfo.skipOffset = input.ReadVInt();
170 indexPointer += input.ReadVLong();
178 internal int ScanTo(
Term term)
180 scanBuffer.Set(term);
182 while (scanBuffer.CompareTo(termBuffer) > 0 && Next())
194 get {
return termBuffer.ToTerm(); }
200 return prevBuffer.ToTerm();
222 public override int DocFreq()
224 return termInfo.docFreq;
229 internal long FreqPointer()
231 return termInfo.freqPointer;
236 internal long ProxPointer()
238 return termInfo.proxPointer;
242 protected override void Dispose(
bool disposing)