mirror of https://github.com/apache/lucene.git
LUCENE-3040: three more missed cases of tokenStream->reusableTokenStream
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1102827 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5669d283ff
commit
993488ea07
|
@ -78,7 +78,7 @@ public class Highlighter
|
||||||
public final String getBestFragment(Analyzer analyzer, String fieldName,String text)
|
public final String getBestFragment(Analyzer analyzer, String fieldName,String text)
|
||||||
throws IOException, InvalidTokenOffsetsException
|
throws IOException, InvalidTokenOffsetsException
|
||||||
{
|
{
|
||||||
TokenStream tokenStream = analyzer.tokenStream(fieldName, new StringReader(text));
|
TokenStream tokenStream = analyzer.reusableTokenStream(fieldName, new StringReader(text));
|
||||||
return getBestFragment(tokenStream, text);
|
return getBestFragment(tokenStream, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ public class Highlighter
|
||||||
int maxNumFragments)
|
int maxNumFragments)
|
||||||
throws IOException, InvalidTokenOffsetsException
|
throws IOException, InvalidTokenOffsetsException
|
||||||
{
|
{
|
||||||
TokenStream tokenStream = analyzer.tokenStream(fieldName, new StringReader(text));
|
TokenStream tokenStream = analyzer.reusableTokenStream(fieldName, new StringReader(text));
|
||||||
return getBestFragments(tokenStream, text, maxNumFragments);
|
return getBestFragments(tokenStream, text, maxNumFragments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -305,11 +305,12 @@ class LuceneMethods {
|
||||||
|
|
||||||
int position = 0;
|
int position = 0;
|
||||||
// Tokenize field and add to postingTable
|
// Tokenize field and add to postingTable
|
||||||
TokenStream stream = analyzer.tokenStream(fieldName, reader);
|
TokenStream stream = analyzer.reusableTokenStream(fieldName, reader);
|
||||||
CharTermAttribute termAtt = stream.addAttribute(CharTermAttribute.class);
|
CharTermAttribute termAtt = stream.addAttribute(CharTermAttribute.class);
|
||||||
PositionIncrementAttribute posIncrAtt = stream.addAttribute(PositionIncrementAttribute.class);
|
PositionIncrementAttribute posIncrAtt = stream.addAttribute(PositionIncrementAttribute.class);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
stream.reset();
|
||||||
while (stream.incrementToken()) {
|
while (stream.incrementToken()) {
|
||||||
position += (posIncrAtt.getPositionIncrement() - 1);
|
position += (posIncrAtt.getPositionIncrement() - 1);
|
||||||
position++;
|
position++;
|
||||||
|
@ -323,6 +324,7 @@ class LuceneMethods {
|
||||||
}
|
}
|
||||||
if (position > maxFieldLength) break;
|
if (position > maxFieldLength) break;
|
||||||
}
|
}
|
||||||
|
stream.end();
|
||||||
} finally {
|
} finally {
|
||||||
stream.close();
|
stream.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue