You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Christian Rodriguez <cr...@gmail.com> on 2004/09/28 02:02:36 UTC

Shouldnt IndexWriter.flushRamSegments() be public? or at least protected?

Hello,

I am trying to use transactions with the Lucene + BDB package. I want
to be able to open a directory, and IndexWriter and then do things
like:

open IndexWriter
start transaction 1
write something to the index
commit transaction 1 (or abort it)
start transaction 2
write something else to the index
commit transaction 2
etc...
close IndexWriter 
and everything else that needs to be closed

Now the problem I have is that I dont have a way to force a flush of
the IndexWriter without closing it and I need to do that before
commiting a transaction or I would get random errors. Shouldnt that
function be public, in case the user wants to force a flush at some
point that is not when the IndexWriter is closed? If not I am forced
to create a new IndexWriter and close it EVERY TIME I commit a
transaction (which in my application is very often).

I thought about creating a subclass of IndexWriter (something like
DbIndexWriter) that implements a flush function but everything I need
from IndexWriter is private (not even protected!) so I cant do this.

Any pointers or solutions to this problem? (Of course I would prefer
not to touch Lucene's code and make flushRamSegments() public myself,
since I dont want to break my code every time I update Lucene,
although I dont see why the user shouldnt be allow to flush segments
to the directory if they decide to... if it ruins the performance,
thats their call).

Thanks!
Xtian

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: Shouldnt IndexWriter.flushRamSegments() be public? or at least protected?

Posted by Doug Cutting <cu...@apache.org>.
Christian Rodriguez wrote:
> Now the problem I have is that I dont have a way to force a flush of
> the IndexWriter without closing it and I need to do that before
> commiting a transaction or I would get random errors. Shouldnt that
> function be public, in case the user wants to force a flush at some
> point that is not when the IndexWriter is closed? If not I am forced
> to create a new IndexWriter and close it EVERY TIME I commit a
> transaction (which in my application is very often).

Opening and closing IndexWriters should be a lightweight operation. 
Have you tried this and found it to be too slow?  A flush() would have 
to do just about the same work.

Doug

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org