<div dir="ltr">That code can't work, it is pseudo-code.<div><br></div><font color="#c27ba0"><span style="font-family:arial,sans-serif;font-size:14px">As I already tried to explain, if you're concerned about performance,</span><br style="font-family:arial,sans-serif;font-size:14px">
<span style="font-family:arial,sans-serif;font-size:14px">the current inmemory backend isn't the answer you are looking for.</span></font><br><div><font color="#c27ba0"><span style="font-family:arial,sans-serif;font-size:14px"><br>
</span></font></div><div><span style="font-family:arial,sans-serif;font-size:14px"><font color="#000000">I will write a memory based SE with WAND merge algorithm and proximity </font></span><font color="#000000" face="arial, sans-serif"><span style="font-size:14px">similarity algorithm(BM25 don't use position).</span></font></div>
<div><font color="#000000" face="arial, sans-serif"><span style="font-size:14px">Thank you very much.</span></font></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-06-26 14:33 GMT+08:00 Olly Betts <span dir="ltr"><<a href="mailto:olly@survex.com" target="_blank">olly@survex.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Thu, Jun 26, 2014 at 01:19:20PM +0800, Yanxiong Lu wrote:<br>
> There may be some solutions,for example<br>
> class XAPIAN<br>
> {<br>
</div>>     *static* int InitDatabase();  //for reading only, do not need lock, but<br>
<div class="">> if writing use lock<br>
>     int Search(); //safe in one object, do not need lock<br>
> };<br>
> XIPIAN xp[ THREAD_NUM ];<br>
><br>
> one thread use one object, they use one database.<br>
> these can be in memory with one database.<br>
<br>
</div>As I already tried to explain, if you're concerned about performance,<br>
the current inmemory backend isn't the answer you are looking for.<br>
Eliminating the need for the user to lock around searches isn't going to<br>
magically solve that.<br>
<br>
I don't really see how your 6 line sketch above helps either.  Xapian<br>
makes *NO* thread-safety guarantees - even in the "reading only" case<br>
you should be locking.  Even if it happens to work currently, there's<br>
no guarantee it'll work in the next release.<br>
<br>
Cheers,<br>
    Olly<br>
</blockquote></div><br></div>