That's right, this is fine. Many unit tests rely on it.
RAMDirectory is similar to UNIX in that deletion of an open file is
allowed, yet anything that had the file open can continue to read
from it. "Delete on last close".
Also note that we don't write & rename a segments.new file anymore
(as of 2.1). Instead we write segments_N, where N increases each
time the writer commits.
Mike
Otis Gospodnetic wrote:
I don't think there are any problems with doing both operations at
the same time.
Otis
--
Sematext -- http://sematext.com/ -- Lucene - Solr - Nutch
----- Original Message ----
From: jian chen <[EMAIL PROTECTED]>
To: java-user@lucene.apache.org
Sent: Friday, May 16, 2008 7:12:34 PM
Subject: simultaneous read and writes to the RAMDirectory
Lucene gurus,
I have a question regarding RAMDirectory usage. Can the
IndexWriter keep
adding documents to the index meanwhile the IndexReader is open on
this
RAMDirectory and searches going on?
I know in a FSDirectory case, the IndexWriter can add documents to
the index
meanwhile IndexReader reads from the index. This is because the
IndexWriter
just writes new index files rather than modifying existing index
files. The
only place (I remember) that the new and old indexes will conflict
is the
segment file. Again, once the IndexWriter commits the change (by
calling
close() method), the segment.new is renamed to segment atomically.
Since the
old segment file is cached in memory by the IndexReader, so not a
problem
for the IndexReader to serve search requests. The old segment file
is cached
in memory, the other files pointed to by the old segment file are
cached by
Linux anyway, or not removed by windows due to still being used.
Anyway, back to the RAMDirectory case. Having an IndexReader open
while
IndexWriter adding documents to it, will that cause any issue?
Thanks,
Jian
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]