You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Paul Dlug (JIRA)" <ji...@apache.org> on 2007/03/14 16:06:09 UTC

[jira] Created: (LUCENE-832) NPE when calling isCurrent() on a ParallellReader

NPE when calling isCurrent() on a ParallellReader
-------------------------------------------------

                 Key: LUCENE-832
                 URL: https://issues.apache.org/jira/browse/LUCENE-832
             Project: Lucene - Java
          Issue Type: Bug
          Components: Index
    Affects Versions: 2.1, 2.0.0, 2.0.1, 2.2
            Reporter: Paul Dlug


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 {


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Resolved: (LUCENE-832) NPE when calling isCurrent() on a ParallellReader

Posted by "Michael Busch (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-832?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Busch resolved LUCENE-832.
----------------------------------

    Resolution: Fixed

Committed.

> NPE when calling isCurrent() on a ParallellReader
> -------------------------------------------------
>
>                 Key: LUCENE-832
>                 URL: https://issues.apache.org/jira/browse/LUCENE-832
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.0.0, 2.0.1, 2.1, 2.2
>            Reporter: Paul Dlug
>            Assignee: Michael Busch
>         Attachments: lucene-832.patch
>
>
> 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 {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Re: variuos IndexReader methods -- was: Re: [jira] Updated: (LUCENE-832) NPE when calling isCurrent() on a ParallellReader

Posted by Michael Busch <bu...@gmail.com>.
Chris Hostetter wrote:
> 
> isn't segmentInfos the kind of thing that should be refactored into the
> subclasses?  there might be a little duplication, but it shouldn't be
> significant (and it helps eliminate the odds of other problems like this
> in the future as more features/methods get added).
> 

Hmm, not sure about this. The commit/rollback logic in IndexReader uses
segmentInfos. I have to dig into this to understand how easy it is to
refactor it into the subclasses.

- Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Re: variuos IndexReader methods -- was: Re: [jira] Updated: (LUCENE-832) NPE when calling isCurrent() on a ParallellReader

Posted by Chris Hostetter <ho...@fucit.org>.
: We just have to make segmentInfos in IndexReader protected so that
: subclasses can implement the methods.

isn't segmentInfos the kind of thing that should be refactored into the
subclasses?  there might be a little duplication, but it shouldn't be
significant (and it helps eliminate the odds of other problems like this
in the future as more features/methods get added).


-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Re: variuos IndexReader methods -- was: Re: [jira] Updated: (LUCENE-832) NPE when calling isCurrent() on a ParallellReader

Posted by Michael Busch <bu...@gmail.com>.
Chris Hostetter wrote:
> is it just me, or does it seem like the base class versions of
> getVersion(), isOptimized(), and isCurrent() in IndexReader should all
> throw UnsupportedOperationException?
> 
> (it seems like ideally they should abstract, but that ship/API has sailed)
> 
> 

Hoss,

I think this makes sense because all these methods use the variable
IndexReader.segmentInfos which might be null in case this constructor is
used:
 protected IndexReader(Directory directory);

We just have to make segmentInfos in IndexReader protected so that
subclasses can implement the methods.

- Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


variuos IndexReader methods -- was: Re: [jira] Updated: (LUCENE-832) NPE when calling isCurrent() on a ParallellReader

Posted by Chris Hostetter <ho...@fucit.org>.
is it just me, or does it seem like the base class versions of
getVersion(), isOptimized(), and isCurrent() in IndexReader should all
throw UnsupportedOperationException?

(it seems like ideally they should abstract, but that ship/API has sailed)


: 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.



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Updated: (LUCENE-832) NPE when calling isCurrent() on a ParallellReader

Posted by "Michael Busch (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-832?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Busch updated LUCENE-832:
---------------------------------

    Attachment: lucene-832.patch

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...

> NPE when calling isCurrent() on a ParallellReader
> -------------------------------------------------
>
>                 Key: LUCENE-832
>                 URL: https://issues.apache.org/jira/browse/LUCENE-832
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.0.0, 2.0.1, 2.1, 2.2
>            Reporter: Paul Dlug
>            Assignee: Michael Busch
>         Attachments: lucene-832.patch
>
>
> 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 {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Assigned: (LUCENE-832) NPE when calling isCurrent() on a ParallellReader

Posted by "Michael Busch (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-832?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Busch reassigned LUCENE-832:
------------------------------------

    Assignee: Michael Busch

> NPE when calling isCurrent() on a ParallellReader
> -------------------------------------------------
>
>                 Key: LUCENE-832
>                 URL: https://issues.apache.org/jira/browse/LUCENE-832
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.0.0, 2.0.1, 2.1, 2.2
>            Reporter: Paul Dlug
>            Assignee: Michael Busch
>
> 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 {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org