You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Robert Kirchgessner (JIRA)" <ji...@apache.org> on 2005/12/08 02:14:08 UTC
[jira] Created: (LUCENE-479) MultiReader.numDocs incorrect after undeleteAll
MultiReader.numDocs incorrect after undeleteAll
-----------------------------------------------
Key: LUCENE-479
URL: http://issues.apache.org/jira/browse/LUCENE-479
Project: Lucene - Java
Type: Bug
Components: Index
Versions: CVS Nightly - Specify date in submission
Reporter: Robert Kirchgessner
Priority: Minor
Calling MultiReader.undeleteAll does not clear cached numDocs value. So the subsequent numDocs() call returns a wrong value if there were deleted documents in the index. Following patch fixes the bug and adds a test showing the issue.
Index: src/test/org/apache/lucene/index/TestMultiReader.java
===================================================================
--- src/test/org/apache/lucene/index/TestMultiReader.java (revision 354923)
+++ src/test/org/apache/lucene/index/TestMultiReader.java (working copy)
@@ -69,6 +69,18 @@
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);
Index: src/java/org/apache/lucene/index/MultiReader.java
===================================================================
--- src/java/org/apache/lucene/index/MultiReader.java (revision 354923)
+++ src/java/org/apache/lucene/index/MultiReader.java (working copy)
@@ -122,6 +122,7 @@
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:
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
[jira] Resolved: (LUCENE-479) MultiReader.numDocs incorrect after undeleteAll
Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LUCENE-479?page=all ]
Doug Cutting resolved LUCENE-479:
---------------------------------
Fix Version: 1.9
Resolution: Fixed
I committed this. Thanks!
> MultiReader.numDocs incorrect after undeleteAll
> -----------------------------------------------
>
> Key: LUCENE-479
> URL: http://issues.apache.org/jira/browse/LUCENE-479
> Project: Lucene - Java
> Type: Bug
> Components: Index
> Versions: CVS Nightly - Specify date in submission
> Reporter: Robert Kirchgessner (JIRA)
> Priority: Minor
> Fix For: 1.9
> Attachments: undeleteAll.patch
>
> Calling MultiReader.undeleteAll does not clear cached numDocs value. So the subsequent numDocs() call returns a wrong value if there were deleted documents in the index. Following patch fixes the bug and adds a test showing the issue.
> Index: src/test/org/apache/lucene/index/TestMultiReader.java
> ===================================================================
> --- src/test/org/apache/lucene/index/TestMultiReader.java (revision 354923)
> +++ src/test/org/apache/lucene/index/TestMultiReader.java (working copy)
> @@ -69,6 +69,18 @@
> 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);
> Index: src/java/org/apache/lucene/index/MultiReader.java
> ===================================================================
> --- src/java/org/apache/lucene/index/MultiReader.java (revision 354923)
> +++ src/java/org/apache/lucene/index/MultiReader.java (working copy)
> @@ -122,6 +122,7 @@
> 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:
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
[jira] Updated: (LUCENE-479) MultiReader.numDocs incorrect after undeleteAll
Posted by "Robert Kirchgessner (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LUCENE-479?page=all ]
Robert Kirchgessner updated LUCENE-479:
---------------------------------------
Attachment: undeleteAll.patch
> MultiReader.numDocs incorrect after undeleteAll
> -----------------------------------------------
>
> Key: LUCENE-479
> URL: http://issues.apache.org/jira/browse/LUCENE-479
> Project: Lucene - Java
> Type: Bug
> Components: Index
> Versions: CVS Nightly - Specify date in submission
> Reporter: Robert Kirchgessner
> Priority: Minor
> Attachments: undeleteAll.patch
>
> Calling MultiReader.undeleteAll does not clear cached numDocs value. So the subsequent numDocs() call returns a wrong value if there were deleted documents in the index. Following patch fixes the bug and adds a test showing the issue.
> Index: src/test/org/apache/lucene/index/TestMultiReader.java
> ===================================================================
> --- src/test/org/apache/lucene/index/TestMultiReader.java (revision 354923)
> +++ src/test/org/apache/lucene/index/TestMultiReader.java (working copy)
> @@ -69,6 +69,18 @@
> 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);
> Index: src/java/org/apache/lucene/index/MultiReader.java
> ===================================================================
> --- src/java/org/apache/lucene/index/MultiReader.java (revision 354923)
> +++ src/java/org/apache/lucene/index/MultiReader.java (working copy)
> @@ -122,6 +122,7 @@
> 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:
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org