You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Michael McCandless (JIRA)" <ji...@apache.org> on 2007/01/01 14:50:27 UTC
[jira] Resolved: (LUCENE-758) IndexReader.isCurrent fails when
using two IndexReaders
[ http://issues.apache.org/jira/browse/LUCENE-758?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael McCandless resolved LUCENE-758.
---------------------------------------
Resolution: Invalid
> IndexReader.isCurrent fails when using two IndexReaders
> -------------------------------------------------------
>
> Key: LUCENE-758
> URL: http://issues.apache.org/jira/browse/LUCENE-758
> Project: Lucene - Java
> Issue Type: Bug
> Affects Versions: 2.0.1
> Environment: Operating System: other
> Platform: other
> Reporter: Bernhard Messer
> Priority: Minor
>
> there is a problem in IndexReader.isCurrent() if using two reader instances where one of them is based on a RAMDirectory. If there is an index and we open two IndexReaders where one is based on a FSDirectory and the other is based on a RAMDirectory, the IndexReader using the RAMDirectory does not recognize when the underlaying index has changed. The method IndexReader.isCurrent() always returns true. The testcase below shows the problem.
> I did not find an ideal solution to solve the problem. I think the best way would be to change the IndexReader.isCurrent() implementation from:
> public boolean isCurrent() throws IOException {
> return SegmentInfos.readCurrentVersion(directory) == segmentInfos.getVersion();
> }
> to something like:
> public boolean isCurrent() throws IOException {
> return directory.readCurrentVersion() == segmentInfos.getVersion();
> }
> As far as i can see this would work for FS- and RAMDirectory. But then the implementing Directory classes have to know about "segment" files and there formating details.
> What do others think ?
> /**
> * additional testcase for IndexReaderTest to show the problem when using two different Readers
> */
> public void testIsCurrentWithCombined() throws Exception {
> String tempDir = System.getProperty("tempDir");
> if (tempDir == null)
> throw new IOException("tempDir undefined, cannot run test");
> File indexDir = new File(tempDir, "lucenetestiscurrent");
> Directory fsStore = FSDirectory.getDirectory(indexDir, true);
>
> IndexWriter writer = new IndexWriter(fsStore, new SimpleAnalyzer(), true);
> addDocumentWithFields(writer);
> writer.close();
>
> IndexReader reader1 = IndexReader.open(fsStore);
> IndexReader reader2 = IndexReader.open(new RAMDirectory(fsStore));
>
> assertTrue(reader1.isCurrent());
> assertTrue(reader2.isCurrent());
>
> reader1.deleteDocument(0);
> reader1.close();
>
> // BUG: reader based on the RAMDirectory does not recognize the index change.
> assertFalse(reader2.isCurrent());
>
> reader2.close();
> }
--
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