19 using Lucene.Net.Analysis.Tokenattributes;
20 using Lucene.Net.Documents;
23 namespace Lucene.Net.Index
46 this.perThread = perThread;
47 this.fieldInfo = fieldInfo;
48 docState = perThread.docState;
49 fieldState = perThread.fieldState;
50 this.consumer = perThread.consumer.AddField(
this, fieldInfo);
51 this.endConsumer = perThread.endConsumer.AddField(
this, fieldInfo);
54 public override void Abort()
60 public override void ProcessFields(
IFieldable[] fields,
int count)
63 fieldState.Reset(docState.doc.Boost);
65 int maxFieldLength = docState.maxFieldLength;
67 bool doInvert = consumer.Start(fields, count);
69 for (
int i = 0; i < count; i++)
82 if (fieldState.length > 0)
83 fieldState.position += docState.analyzer.GetPositionIncrementGap(fieldInfo.name);
89 int valueLength = stringValue.Length;
90 perThread.singleToken.Reinit(stringValue, 0, valueLength);
91 fieldState.attributeSource = perThread.singleToken;
92 consumer.Start(field);
103 docState.docWriter.SetAborting();
105 fieldState.offset += valueLength;
107 fieldState.position++;
108 anyToken = valueLength > 0;
116 if (streamValue != null)
117 stream = streamValue;
122 System.IO.TextReader reader;
123 System.IO.TextReader readerValue = field.
ReaderValue;
125 if (readerValue != null)
126 reader = readerValue;
130 if (stringValue == null)
131 throw new System.ArgumentException(
"field must have either TokenStream, String or Reader value");
132 perThread.stringReader.Init(stringValue);
133 reader = perThread.stringReader;
137 stream = docState.analyzer.ReusableTokenStream(fieldInfo.name, reader);
143 int startLength = fieldState.length;
147 int offsetEnd = fieldState.offset - 1;
149 bool hasMoreTokens = stream.IncrementToken();
151 fieldState.attributeSource = stream;
156 consumer.Start(field);
172 fieldState.position += posIncr;
173 if (fieldState.position > 0)
175 fieldState.position--;
179 fieldState.numOverlap++;
181 bool success =
false;
196 docState.docWriter.SetAborting();
198 fieldState.position++;
199 offsetEnd = fieldState.offset + offsetAttribute.
EndOffset;
200 if (++fieldState.length >= maxFieldLength)
202 if (docState.infoStream != null)
203 docState.infoStream.WriteLine(
"maxFieldLength " + maxFieldLength +
" reached for field " + fieldInfo.name +
", ignoring following tokens");
207 hasMoreTokens = stream.IncrementToken();
212 fieldState.offset += offsetAttribute.
EndOffset;
213 anyToken = fieldState.length > startLength;
222 fieldState.offset += docState.analyzer.GetOffsetGap(field);
223 fieldState.boost *= field.
Boost;
232 endConsumer.Finish();