You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by András Péteri <ap...@b2international.com> on 2015/03/02 13:17:41 UTC

Throwing CollectionTerminatedException from Collector.getLeafCollector

Hi,

According to IndexSearcher's code [1], if a Collector implementation is not
interested in collecting document hits from a particular leaf reader, it
can also throw CollectionTerminatedException from
Collector.getLeafCollector(LeafReaderContext). This option is however not
described in Collector's javadoc [2], only for LeafCollector.collect(int)
[3].

Is this considered an implementation detail, or a behavior that will likely
not go away in the future? It seems convenient to throw the exception
straight from getLeafCollector(...) if it is already known that no
information will be collected from a segment, instead of setting a flag on
the returned LeafCollector instance, or adding the test directly to
LeafCollector.collect(int).

[1]
https://github.com/apache/lucene-solr/blob/lucene_solr_5_0_0/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java#L584
[2]
https://github.com/apache/lucene-solr/blob/lucene_solr_5_0_0/lucene/core/src/java/org/apache/lucene/search/Collector.java
[3]
https://github.com/apache/lucene-solr/blob/lucene_solr_5_0_0/lucene/core/src/java/org/apache/lucene/search/LeafCollector.java#L84

Thanks,
András

Re: Throwing CollectionTerminatedException from Collector.getLeafCollector

Posted by Adrien Grand <jp...@gmail.com>.
Hi András,

It feels useful to me too, I think we should document this behaviour.
For the record, this other issue has just be open and mentions this
problem https://issues.apache.org/jira/browse/LUCENE-6326.

On Mon, Mar 2, 2015 at 1:17 PM, András Péteri
<ap...@b2international.com> wrote:
> Hi,
>
> According to IndexSearcher's code [1], if a Collector implementation is not
> interested in collecting document hits from a particular leaf reader, it
> can also throw CollectionTerminatedException from
> Collector.getLeafCollector(LeafReaderContext). This option is however not
> described in Collector's javadoc [2], only for LeafCollector.collect(int)
> [3].
>
> Is this considered an implementation detail, or a behavior that will likely
> not go away in the future? It seems convenient to throw the exception
> straight from getLeafCollector(...) if it is already known that no
> information will be collected from a segment, instead of setting a flag on
> the returned LeafCollector instance, or adding the test directly to
> LeafCollector.collect(int).
>
> [1]
> https://github.com/apache/lucene-solr/blob/lucene_solr_5_0_0/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java#L584
> [2]
> https://github.com/apache/lucene-solr/blob/lucene_solr_5_0_0/lucene/core/src/java/org/apache/lucene/search/Collector.java
> [3]
> https://github.com/apache/lucene-solr/blob/lucene_solr_5_0_0/lucene/core/src/java/org/apache/lucene/search/LeafCollector.java#L84
>
> Thanks,
> András



-- 
Adrien

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