lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Halácsy Péter <halacsy.pe...@axelero.com>
Subject RE: IndexReader.lastModified() not correct
Date Wed, 07 Aug 2002 16:36:43 GMT
Scott!
I don't know whether you code is good or not. My question is: can this problem cause my exception?
> java.io.IOException: read past EOF
>         at java.lang.Throwable.fillInStackTrace(Native Method)
>         at java.lang.Throwable.fillInStackTrace(Compiled Code)
>         at java.lang.Throwable.<init>(Compiled Code)
>         at java.lang.Exception.<init>(Compiled Code)
>         at java.io.IOException.<init>(Compiled Code)
>         at 
> org.apache.lucene.store.FSInputStream.readInternal(Compiled Code)
>         at 
> org.apache.lucene.store.InputStream.readBytes(Compiled Code)
> 

I also cache the searcher. I think the searcher was not reopened and tried to read something
non-existing stuff

peter

> -----Original Message-----
> From: Scott Ganyo [mailto:scott.ganyo@eTapestry.com]
> Sent: Wednesday, August 07, 2002 6:32 PM
> To: 'Lucene Developers List'
> Subject: RE: IndexReader.lastModified() not correct
> 
> 
> Ok.  I've dug through all the code and although this isn't 
> too pretty, it
> looks to my untrained eye that this is probably the best way 
> to implement a
> corrected version that takes into consideration the deleted list.
> Basically, it checks the "segments" file as before, then checks the
> "segment.del" file in each segment, and takes the last time 
> any of those
> files were modified:
> 
>   public static long lastModified(final Directory directory) throws
> IOException {
>     synchronized (directory) {			  // 
> in- & inter-process
> sync
>       Long lastMod = (Long)new 
> Lock.With(directory.makeLock("commit.lock"))
> {
>         public Object doBody() throws IOException {
>           long last = directory.fileModified("segments"); // 
> last add time
>           SegmentInfos infos = new SegmentInfos();
>           infos.read(directory);
>           for (int i = 0; i < infos.size(); i++) {
>             String delFile = infos.info(i).name + ".del";
>             if (directory.fileExists(delFile)) {
>                 long lastDel = 
> directory.fileModified(delFile); // last
> delete time (per segment)
>                 if (lastDel > last) last = lastDel;
>             }
>           }
>           return new Long(last);
>         }
>       }.run();
>       return lastMod.longValue();
>     }
>   }
> 
> Please let me know if I've missed any shortcuts or if you 
> know of a better
> way...
> 
> Scott
> 
> > -----Original Message-----
> > From: Scott Ganyo [mailto:scott.ganyo@eTapestry.com]
> > Sent: Wednesday, August 07, 2002 9:27 AM
> > To: Lucene-Dev (E-mail)
> > Subject: IndexReader.lastModified() not correct
> > 
> > 
> > The current implementation of IndexReader.lastModified() does 
> > not return the
> > results I am expecting.  Here is the implementation:
> > 
> >   /** Returns the time the index in the named directory was 
> > last modified.
> > */
> >   public static long lastModified(File directory) throws 
> IOException {
> >     return FSDirectory.fileModified(directory, "segments");
> >   }
> > 
> > The problem is that the "segments" file is apparently not 
> > updated when just
> > doing a delete from an index.  This is causing me problems 
> > because I am
> > attempting to rely on on the lastModified() command for 
> IndexSearcher
> > caching.  The only solution that I have thought of so far 
> > (without changing
> > other parts of Lucene) is to make the lastModified() command 
> > look at all the
> > files in the last segment for the last modified date.
> > 
> > Thoughts?
> > 
> > Thanks,
> > Scott
> > 
> 

--
To unsubscribe, e-mail:   <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>


Mime
View raw message