[Xapian-discuss] Node.js binding

Richard Boulton richard at tartarus.org
Thu Oct 20 11:51:52 BST 2011


On 20 October 2011 06:31, Liam <xapian at networkimprov.net> wrote:
> Do any of these potentially hit the disk? I'd guessed that none of them
> did...
>  Enquire::Enquire(database)
>  Query::Query(...);
>  Enquire::set_query(query);
>  MSet::size()
Pretty sure all the above are safe.

>  MSetIterator:: operator *(), get_percent(), get_document()
get_document() is not safe here - the documents can be lazily loaded
into the MSet object, so this can hit disk or network.

>  Document::Document
I think the constructor is safe.  But be aware that other Document
methods can be unsafe, because documents can also load parts of their
data lazily.

> I assumed these do:
>  Database::Database(file)
>  Enquire::get_mset()
>  Document::get_data()

Yes - these definitely usually involve IO (or at least, if the
database is inmemory, they could take a significant amount of time).

One concern about putting some Xapian accesses into a subthread; it is
not safe to call methods on Xapian API objects concurrently, so you'll
need to protect calls with some locking scheme, or some convention to
avoid this.  Seems very tricky to do right, to me, and might therefore
be safer to just do everything in a subthread.

-- 
Richard



More information about the Xapian-discuss mailing list