You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Christoph Goller <go...@detego-software.de> on 2003/10/26 15:24:43 UTC

Re: timestamp

I implemented the idea proposed last week concerning
the timestamp problem. Note that this patch does no
longer use touch and lastModified for synchronizing
index changes. It works as follows:

*) The file segments (SegmentInfos) gets an additional
long which counts the number of changes of the index.
It is automatically incremented whenever SegmentInfos
are written (called by IndexWriter).

*) IndexReader now does not compare timestamps in order
to find out whether it is stale. Instead it compares
the number of changes when it was created to the actual
contents of segments.

*) In doClose of SegmentReader instead of touching the
file segments, it is rewritten in order to update number
of changes.

*) In order for the whole idea to work, IndexReader needs
a copy of SegmentInfos, which substitutes the former
segmentInfosAge.

*) It would be easy to move the "number of changes" count
from the file segments into a seperate file or as Hani proposed
into the name of a file. The changes would only involve
SegmentInfos. However, I think that my current implementation
is already quite efficient. The changes mean almost no
overhead to IndexWriter, since whenever it changes the index
segments has to be rewritten anyway. There is also not much
overhead to IndexReader. Only one additional file has to be read
once in case of delete. There is some overhead to
SegmentReader.doClose. If deletedDocsDirty == true segments
has to be rewritten. However, in this case deletedDocs has to be
written too and it is probably much bigger in most of the cases.

*) I tested my patch and all unit tests are ok including
TestIndexReader for which I get failures without my patch.

*) My patch has two parts. The 1st one is applied to
src/java/org/apache/lucene/index
the 2nd one to
src/test/org/apache/lucene/index
(small changes necessary doe to constructor changes for
SegmentReader)

I am looking forward to feedback,

Christoph