lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bernhard Messer <Bernhard.Mes...@intrafind.de>
Subject IndexReader.getCurrentVersion() and IndexReader.lastModified()
Date Wed, 02 Jun 2004 13:08:46 GMT
Hi,

I'm sending a patch which should help to fix a problem using the new 
method IndexReader.getCurrentVersion(). As far as i understand the 
current lucene documentation, developers should use this new method to 
verify if an index is out of date. The older method 
IndexReader.lastModified() is deprecated and therefore a possible 
candidate for deletion.

The problem with getCurrentVersion is, that it's base is 0, when 
creating a new index. Therefore the version number will be identical if 
you delete an index and recreate a new one,  using the same document 
set, doesn't matter if there is a change in the document content or a 
different analyzer is used. The idea of the patch is to intialize the 
version number with the current time in millis as base when creating a 
new SegmentInfos object. So it's "nearly" impossible to get the same 
version number again.

Without this patch, it's impossible for developers to store an 
IndexReader in cache and check it's validity thru getCurrentVersion.

In the attachment is the patch and a JUnit TestCase which tests the 
scenario with a sample implementation for an IndexReader cache.

As far as i can see, there are no negativ side effects when implementing 
this patch. But let's see what the lucene-specialists will see ;-)
 
best regards
Bernhard






Mime
View raw message