lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erick Erickson" <erickerick...@gmail.com>
Subject Re: Refreshing RAMDirectory
Date Tue, 11 Dec 2007 22:59:04 GMT
I can't speak to the errors, but how is the index being updated? An
indexwriter buffers changes and periodically flushes them out to
disk. So the writer may not have flushed your data, depending
upon how it's written.

Best
Erick

On Dec 11, 2007 5:37 PM, Ruslan Sivak <rsivak@istandfor.com> wrote:

> I have an index of about 10mb.  Since it's so small, I would like to
> keep it loaded in memory, and reload it about every minute or so,
> assuming that it has changed on disk.  I have the following code, which
> works, except it doesn't reload the changes.
>
> protected String indexName;
> protected IndexReader reader;
> private long lastCheck=0;
> ...
> protected IndexReader getReader() throws CorruptIndexException,
> IOException
>    {
>        if (reader==null || System.currentTimeMillis() > lastCheck+60000)
>        {
>            lastCheck=System.currentTimeMillis();
>            if (reader==null || !reader.isCurrent())
>            {
>                if (reader!=null)
>                    reader.close();
>
>                Directory dir = new RAMDirectory(indexName);
>                reader = IndexReader.open(dir);
>                searcher = new IndexSearcher(reader);
>            }
>        }
>        return reader;
> }
>
>
> Apparently reader.isCurrent() won't tell you if the underlying
> FSDirectory has changed.
>
> I also had the following code before:
> instead of
> if (reader==null || !reader.isCurrent())
> I had
> if (reader==null || reader.getVersion() !=
> IndexReader.getCurrentVersion(indexName))
>
>
> I was getting a bunch of this indexreader is closed errors, and I'm not
> sure why there's no method like reader.isClosed().
>
> Am I going about things the right way?  Is there a better implementation
> of what I'm looking to do?  Is there perhaps some function I'm not
> seeing which will let me know if the indexreader is closed?
>
> Russ
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message