19 using Lucene.Net.Analysis.Tokenattributes;
20 using Lucene.Net.Documents;
22 namespace Lucene.Net.Index
36 internal bool omitTermFreqAndPositions;
41 this.termsHashPerField = termsHashPerField;
42 this.perThread = perThread;
43 this.fieldInfo = fieldInfo;
44 docState = termsHashPerField.docState;
45 fieldState = termsHashPerField.fieldState;
46 omitTermFreqAndPositions = fieldInfo.omitTermFreqAndPositions;
49 internal override int GetStreamCount()
51 if (fieldInfo.omitTermFreqAndPositions)
57 internal override void Finish()
61 internal bool hasPayloads;
63 internal override void SkippingLongTerm()
69 return String.CompareOrdinal(fieldInfo.name, other.fieldInfo.name);
76 omitTermFreqAndPositions = fieldInfo.omitTermFreqAndPositions;
77 payloadAttribute = null;
80 internal override bool Start(
IFieldable[] fields,
int count)
82 for (
int i = 0; i < count; i++)
83 if (fields[i].IsIndexed)
96 payloadAttribute = null;
100 internal void WriteProx(FreqProxTermsWriter.PostingList p,
int proxCode)
103 if (payloadAttribute == null)
109 payload = payloadAttribute.
Payload;
112 if (payload != null && payload.internalLength > 0)
114 termsHashPerField.WriteVInt(1, (proxCode << 1) | 1);
115 termsHashPerField.WriteVInt(1, payload.internalLength);
116 termsHashPerField.WriteBytes(1, payload.data, payload.internalOffset, payload.internalLength);
120 termsHashPerField.WriteVInt(1, proxCode << 1);
121 p.lastPosition = fieldState.position;
124 internal override void NewTerm(RawPostingList p0)
128 System.Diagnostics.Debug.Assert(docState.TestPoint(
"FreqProxTermsWriterPerField.newTerm start"));
129 FreqProxTermsWriter.PostingList p = (FreqProxTermsWriter.PostingList) p0;
130 p.lastDocID = docState.docID;
131 if (omitTermFreqAndPositions)
133 p.lastDocCode = docState.docID;
137 p.lastDocCode = docState.docID << 1;
139 WriteProx(p, fieldState.position);
143 internal override void AddTerm(RawPostingList p0)
146 System.Diagnostics.Debug.Assert(docState.TestPoint(
"FreqProxTermsWriterPerField.addTerm start"));
148 FreqProxTermsWriter.PostingList p = (FreqProxTermsWriter.PostingList) p0;
150 System.Diagnostics.Debug.Assert(omitTermFreqAndPositions || p.docFreq > 0);
152 if (omitTermFreqAndPositions)
154 if (docState.docID != p.lastDocID)
156 System.Diagnostics.Debug.Assert(docState.docID > p.lastDocID);
157 termsHashPerField.WriteVInt(0, p.lastDocCode);
158 p.lastDocCode = docState.docID - p.lastDocID;
159 p.lastDocID = docState.docID;
164 if (docState.docID != p.lastDocID)
166 System.Diagnostics.Debug.Assert(docState.docID > p.lastDocID);
173 termsHashPerField.WriteVInt(0, p.lastDocCode | 1);
176 termsHashPerField.WriteVInt(0, p.lastDocCode);
177 termsHashPerField.WriteVInt(0, p.docFreq);
180 p.lastDocCode = (docState.docID - p.lastDocID) << 1;
181 p.lastDocID = docState.docID;
182 WriteProx(p, fieldState.position);
187 WriteProx(p, fieldState.position - p.lastPosition);