Issue Details (XML | Word | Printable)

Key: LUCENE-832
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Michael Busch
Reporter: Paul Dlug
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Lucene - Java

NPE when calling isCurrent() on a ParallellReader

Created: 14/Mar/07 03:05 PM   Updated: 01/Aug/07 12:43 AM
Return to search
Component/s: Index
Affects Version/s: 2.0.0, 2.1, 2.2
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works lucene-832.patch 2007-07-31 11:38 PM Michael Busch 4 kB
Issue Links:
Reference
 

Lucene Fields: New
Resolution Date: 01/Aug/07 12:43 AM


 Description  « Hide
As demonstrated by the test case below, if you call isCurrent() on a ParallelReader it causes an NPE. Fix appears to be to add an isCurrent() to ParallelReader which calls it on the underlying indexes but I'm not sure what other problems may be lurking here. Do methods such as getVersion(), lastModified(), isOptimized() also have to be rewritten or is this a use case where ParallelReader will never mimic IndexReader perfectly? At the very least this behavior should be documented so others know what to expect.

[junit] Testcase: testIsCurrent(org.apache.lucene.index.TestParallelReader): Caused an ERROR
[junit] null
[junit] java.lang.NullPointerException
[junit] at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:502)
[junit] at org.apache.lucene.index.SegmentInfos.readCurrentVersion(SegmentInfos.java:336)
[junit] at org.apache.lucene.index.IndexReader.isCurrent(IndexReader.java:316)
[junit] at org.apache.lucene.index.TestParallelReader.testIsCurrent(TestParallelReader.java:146)

Index: src/test/org/apache/lucene/index/TestParallelReader.java
===================================================================
— src/test/org/apache/lucene/index/TestParallelReader.java (revision 518122)
+++ src/test/org/apache/lucene/index/TestParallelReader.java (working copy)
@@ -135,6 +135,15 @@
assertEquals(docParallel.get("f4"), docSingle.get("f4"));
}
}
+
+ public void testIsCurrent() throws IOException { + Directory dir1 = getDir1(); + Directory dir2 = getDir2(); + ParallelReader pr = new ParallelReader(); + pr.add(IndexReader.open(dir1)); + pr.add(IndexReader.open(dir2)); + assertTrue(pr.isCurrent()); + }

// Fiels 1-4 indexed together:
private Searcher single() throws IOException {



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Hoss Man added a comment - 14/Mar/07 06:01 PM
shades of LUCENE-781 here.

Michael Busch added a comment - 31/Jul/07 11:38 PM
This patch fixes ParallelReader similar to LUCENE-781:
  • ParallelReader.getVersion() now throws an
    UnsupportedOperationException.
  • ParallelReader.isOptimized() now checks if all underlying
    indexes are optimized and returns true in such a case.
  • ParallelReader.isCurrent() now checks if all underlying
    IndexReaders are up to date and returns true in such a case.
  • Additional tests in TestParallelReader to test these methods.

All tests pass. I'm planning to commit this soon...


Michael Busch added a comment - 01/Aug/07 12:43 AM
Committed.