LUCENE-1828: Fix MemoryIndex to call TokenStream.reset() and TokenStream.end().

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@806444 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Busch 2009-08-21 08:02:40 +00:00
parent d3cb8b3dbc
commit 5a40767d67
2 changed files with 5 additions and 1 deletions

View File

@ -78,6 +78,8 @@ Bug fixes
10. LUCENE-1792: Fix new query parser to set rewrite method for
multi-term queries. (Luis Alves, Mike McCandless via Michael Busch)
11. LUCENE-1828: Fix memory index to call TokenStream.reset() and
TokenStream.end(). (Tim Smith via Michael Busch)
New features

View File

@ -342,6 +342,7 @@ public class MemoryIndex implements Serializable {
PositionIncrementAttribute posIncrAttribute = (PositionIncrementAttribute) stream.addAttribute(PositionIncrementAttribute.class);
OffsetAttribute offsetAtt = (OffsetAttribute) stream.addAttribute(OffsetAttribute.class);
stream.reset();
while (stream.incrementToken()) {
String term = termAtt.term();
if (term.length() == 0) continue; // nothing to do
@ -363,7 +364,8 @@ public class MemoryIndex implements Serializable {
positions.add(pos, offsetAtt.startOffset(), offsetAtt.endOffset());
}
}
stream.end();
// ensure infos.numTokens > 0 invariant; needed for correct operation of terms()
if (numTokens > 0) {
boost = boost * docBoost; // see DocumentWriter.addDocument(...)