Hi, As part of my whole indexing thing, I want to move the databases around, from within the code. So, I figured that the safest bet would be to close the DB before attempting to move it. But there's no Xapian::Database::close() or even Xapian::WritableDatabase::close(). I have a global variable that holds the database, and I open it in the main(): // globals Xapian::WritableDatabase g_Xap; int main( int argc, char ** argv ) { g_Xap = Xapian::WritableDatabase( ... ); } So, I was thinking, in order to close it successfully, i could do this: g_Xap = Xapian::WritableDatabase(); But that doesn't force a close, it just does the whole refcount thing, which could potentially leave it open if someone still has it laying around. Why is there no close() method? What's the "official" way to close a DB? Cheers.
I was actually having this similar issue today as well (but using PHP). Inside a loop, I open certain databases based on a variable, which could have a re-occuring value. On those occasions that the value re-occurs, it tries to create a new XapianWriteableDatabase object with that value again but fails and throws an exception saying there is already a lock on that database. I was thinking that I needed a way to close the database before the last lines of the loop. Anyone know the proper way to close a database? Benny On 8/8/07, David Morris <dmorris@sirca.org.au> wrote:> > Hi, > > As part of my whole indexing thing, I want to move the databases > around, from within the code. So, I figured that the safest bet > would be to close the DB before attempting to move it. > > But there's no Xapian::Database::close() or even > Xapian::WritableDatabase::close(). > > I have a global variable that holds the database, and I open it > in the main(): > > // globals > Xapian::WritableDatabase g_Xap; > > int main( int argc, char ** argv ) > { > g_Xap = Xapian::WritableDatabase( ... ); > } > > So, I was thinking, in order to close it successfully, i > could do this: > > g_Xap = Xapian::WritableDatabase(); > > But that doesn't force a close, it just does the whole refcount > thing, which could potentially leave it open if someone still > has it laying around. > > Why is there no close() method? What's the "official" way to > close a DB? > > Cheers. > > > _______________________________________________ > Xapian-discuss mailing list > Xapian-discuss@lists.xapian.org > http://lists.xapian.org/mailman/listinfo/xapian-discuss >
David Morris wrote:> As part of my whole indexing thing, I want to move the databases > around, from within the code. So, I figured that the safest bet > would be to close the DB before attempting to move it. > > But there's no Xapian::Database::close() or even > Xapian::WritableDatabase::close()....> g_Xap = Xapian::WritableDatabase(); > > But that doesn't force a close, it just does the whole refcount > thing, which could potentially leave it open if someone still > has it laying around.It's worse that that - in fact, if there is any xapian object _derived_ from the WritableDatabase (like a PostingIterator) still around, the database won't get closed (though you won't be able to access it).> Why is there no close() method? What's the "official" way to > close a DB?It would definitely be good to add a close() method. There is an open bug about this issue: see http://www.xapian.org/cgi-bin/bugzilla/show_bug.cgi?id=173 Unfortunately, it's not that easy to add a close() method, because it would also require all the objects which use a database to cope with the database being closed underneath them. It'll get implemented at some stage, but we've been trying to think of a neat way of doing so... [Actually, bug #173 only discusses adding a close() method to the bindings, but I think the only plausible way of doing that would be to add a close() method to the C++ interface, and wrap it.] Feel free to comment on #173 if you have any thoughts. -- Richard
Reasonably Related Threads
- Compact databases and removing stale records at the same time
- 回复: A beginner in "Posting list encoding improvements"
- Compact databases and removing stale records at the same time
- A beginner in "Posting list encoding improvements"
- About memory index/search in multithread program