mirror of https://github.com/apache/lucene.git
Fix LUCENE-479: After MultiReader.undeleteAll(), numDocs was incorrect. Contributed by Robert Kirchgessner.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@355181 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cf4c00556c
commit
e6400c63f0
|
@ -319,6 +319,9 @@ Bug fixes
|
|||
19. Corrected term offsets returned by ChineseTokenizer.
|
||||
(Ray Tsang via Erik Hatcher, LUCENE-324)
|
||||
|
||||
20. Fixed MultiReader.undeleteAll() to correctly update numDocs.
|
||||
(Robert Kirchgessner via Doug Cutting, LUCENE-479)
|
||||
|
||||
Optimizations
|
||||
|
||||
1. Disk usage (peak requirements during indexing and optimization)
|
||||
|
|
|
@ -122,6 +122,7 @@ public class MultiReader extends IndexReader {
|
|||
for (int i = 0; i < subReaders.length; i++)
|
||||
subReaders[i].undeleteAll();
|
||||
hasDeletions = false;
|
||||
numDocs = -1; // invalidate cache
|
||||
}
|
||||
|
||||
private int readerIndex(int n) { // find reader for doc n:
|
||||
|
|
|
@ -69,6 +69,18 @@ public class TestMultiReader extends TestCase {
|
|||
assertTrue(vector != null);
|
||||
TestSegmentReader.checkNorms(reader);
|
||||
}
|
||||
|
||||
public void testUndeleteAll() throws IOException {
|
||||
sis.read(dir);
|
||||
MultiReader reader = new MultiReader(dir, sis, false, readers);
|
||||
assertTrue(reader != null);
|
||||
assertEquals( 2, reader.numDocs() );
|
||||
reader.delete(0);
|
||||
assertEquals( 1, reader.numDocs() );
|
||||
reader.undeleteAll();
|
||||
assertEquals( 2, reader.numDocs() );
|
||||
}
|
||||
|
||||
|
||||
public void testTermVectors() {
|
||||
MultiReader reader = new MultiReader(dir, sis, false, readers);
|
||||
|
|
Loading…
Reference in New Issue