lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Willnauer <simon.willna...@googlemail.com>
Subject Re: IndexReader.getSequentialSubReaders() usage in Lucene 2.9+
Date Thu, 27 May 2010 09:37:28 GMT
Hey Nikolay,

On Thu, May 27, 2010 at 11:00 AM, Nikolay Zamosenchuk
<nikolay.zamosenchuk@exoplatform.com> wrote:
> Hi, Dear colleagues!
> I have one question concerning IndexReader.getSequentialSubReaders()
> and it's usage.

getSequentialSubReaders() was introduced to support Per-Segment Search
in Lucene 2.9. It is used to access the readers a higher level reader
is composed of.
If you have a reader not being composed of a set of other readers this
method does nothing.
>
> Imagine there is a class extending DirectoryReader or MultiReader.
> Usually directory- or multi-reader consists of sub-readers (i.e.
> segment-readers). Is it safe enough to return always null in
> IndexReader.getSequentialSubReaders() ?

Yes it is safe to do so - actually the java doc says that you should
return null if you reader is not composed from child readers.

>
> We have a special Query and Weight classes that relies on custom
> extended IndexReader. If this method (getSequentialSubReaders) is not
> overridden, then our Weight class receives ReadOnlySegmentReader
> instance.

IndexSearcher tries to gather all subreaders from a Top-Level reader
when it is initialized. If you wanna use your top-level reader to be
the only reader used for searches just return null.
> I found that IndexSearcher.search(...) method changed in lucene
> 2.4.1->2.9.2, so subReaders are passed instead of original reader.
> I've also found, that returning null in
> IndexReader.getSequentialSubReaders() will avoid usage of subReaders.
> Seems returning the null helped and tests pessed.
> But there is a question, is it safe enough to return null in
> IndexReader.getSequentialSubReaders() ? Would it break some internal
> logic?

Afaik It would not break any logic though but if you work around per
segment readers you might not be able to benefit from the improvements
made by per segment search. In short: Per-Segment search uses
subreaders (SegementReaders) to reference for instance caches or
filters. If you use your top level reader for searches directly you
force lucene to invalidate all references where the reader is used if
the instance changes. While if you use segment readers you only need
to invalidate the caches of the segments which have changed.

simon


>
> Thanks much!
> --
> Best regards, Nikolay Zamosenchuk
> eXo (UA)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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


Mime
View raw message