Re: [zoie]How can the index files be searched where ZoieSystem is started?

51 views
Skip to first unread message

Johnbin Wang

unread,
Jun 22, 2011, 10:51:59 PM6/22/11
to zoie
I changed the method ZoieSystem.getIndexReaders() as follows, and it works.
 
public List<ZoieIndexReader<R>> getIndexReaders() throws IOException
{
       return  this._searchIdxMgr.getIndexReaders();
}
 
I don't know why the codes before can not work.

 
On Thu, Jun 23, 2011 at 10:16 AM, Johnbin <johnbi...@gmail.com> wrote:
Description: I have a lucene index directory(i.e. /opt/zoieIndex, the
index files' size in which is about 50M ) and pass this directory to
ZoieSystem constructor, just like the following code.

File idxDir = new File("/opt/zoieIndex");
ZoieSystem<IndexReader, String> idxSystem = createZoie(
                               idxDir, true, 20, new WhitespaceAnalyzer(), null,
idxSystem.start();

Then I get  index readers for searching.
readers = idxSystem.getIndexReaders();
reader = new MultiReader(readers.toArray(new IndexReader[readers
                                       .size()]), false);
for (int i = 0; i < readers.size(); i++) {
                               IndexReader ir = readers.get(i);
}
searcher = new IndexSearcher(reader);


But I can not search anything.  So how can the index files be
searched ? What else I need to do ?

Thank you !



--
cheers,
Johnbin Wang

Johnbin

unread,
Jun 22, 2011, 10:16:44 PM6/22/11
to zoie

Xiaoyang Gu

unread,
Jun 23, 2011, 2:20:28 AM6/23/11
to zo...@googlegroups.com
You can try to specify NoopReaderCache instead of DefaultReaderCache when you create ZoieSystem.
Try to use ZoieConfig.java to create Zoie instance.



Xiaoyang




--
You received this message because you are subscribed to the Google Groups "zoie" group.
To post to this group, send email to zo...@googlegroups.com.
To unsubscribe from this group, send email to zoie+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/zoie?hl=en.

Johnbin Wang

unread,
Jun 23, 2011, 2:42:15 AM6/23/11
to zo...@googlegroups.com
Thank you, it works. But I still want to know the difference among DefaultReaderCache, NoopReaderCache  and SmartReaderCache. What scene should I use them in?
--
cheers,
Johnbin Wang

Xiaoyang Gu

unread,
Jun 23, 2011, 3:26:55 AM6/23/11
to zo...@googlegroups.com
Well, NoopReaderCache pretty much works like there's no reader cache, or zoie before we introduced it.

Also before, zoie's index readers cannot be passed between threads safely/easily, since thread local was used and was uncacheable.

An important client requested a freshness feature, so we introduced a reader cache.

DefaultReaderCache would refresh the reader every freshness amount of time. Apparently we forget to fresh it at startup, which is probably why your code didn't work. But if could wait freshness amount of time, it should be there. Also you can force a refresh at startup time.  If you use the same reader for a while instead of always use newest one,  you may have better cpu/memory cache utility. Of course, this can be severely affected by application's behavior.

SmartReaderCache, does what DefaultReaderCache does, plus it help application avoid the reference counting on index readers. This reduces amount of synchronized/locked code path, which in turn may reduce the amount of context switches. In implementation, it uses weak reference and let GC trigger the reference counting.

We never had the bandwidth to compare performance in production environment, nor do I expect them to be very different.


Xiaoyang

Johnbin Wang

unread,
Jun 23, 2011, 3:45:18 AM6/23/11
to zo...@googlegroups.com
Thank you for your reply!  You are doing a great job! 
As a code lover, I'd like to dive into codes and make some contributions to zoie!

李峰

unread,
Jan 5, 2013, 2:45:17 AM1/5/13
to zo...@googlegroups.com
When using Zoie-Solr package, AlreadyClosedException would be thrown in below case

1) new solr searcher
  1.1) SearchIndexManager.getIndexReaders -> disk reader
2) reopen solr searcher
  2.1) SearchIndexManager.getIndexReaders -> new disk reader, there are updates flushed to disk.
  2.2) ZoieSolrMultiReader -> return old disk reader to recycle list
  2.3) solr new searcher is under warming, so app is using old searcher (and old disk reader).
  2.4) DefaultReaderCache recycle the old disk reader, AlreadyClosedException is thrown
Reply all
Reply to author
Forward
0 new messages