[ 
https://issues.apache.org/jira/browse/LUCENE-1593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12702503#action_12702503
 ] 

Michael McCandless commented on LUCENE-1593:
--------------------------------------------

bq. If it equals, it's also rejected, since now that we move to returning docs 
in order, it is assumed that this doc's doc Id is greater than whatever is in 
the queue, and so it's rejected.

Argh, you are right... so the approach will fail if any of the first topN (eg 
10) hits have a field value equal to the sentinel value.  I guess we could do 
two separate passes: a "startup" pass (while queue is filling up) and a "the 
rest" pass that knows the queue is full.  But that's getting rather ugly; 
probably we should leave this optimization to source code specialization.

bq.  I can do the same for the FieldDoc.fields() value, in case one of the 
fields is FIELD_DOC.

Excellent!  Let's just do this as part of this issue.

bq. I must say I still didn't fully understand what do you mean here.

I also did not understand how BooleanScorer works until Doug explained it (see 
the comment at the top).

Right now it gathers hits of each clause in a reversed linked list, which it 
then makes a 2nd pass to collect.  So the Collector will see docIDs in reverse 
order for that clause.  I thought we could simply fix the linking to be forward 
and we'd have docIDs in order.  But that isn't quite right because any new 
docIDs hit by the 2nd clause will be inserted at the end of the linked list, 
out of order.

> Optimizations to TopScoreDocCollector and TopFieldCollector
> -----------------------------------------------------------
>
>                 Key: LUCENE-1593
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1593
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>            Reporter: Shai Erera
>             Fix For: 2.9
>
>
> This is a spin-off of LUCENE-1575 and proposes to optimize TSDC and TFC code 
> to remove unnecessary checks. The plan is:
> # Ensure that IndexSearcher returns segements in increasing doc Id order, 
> instead of numDocs().
> # Change TSDC and TFC's code to not use the doc id as a tie breaker. New docs 
> will always have larger ids and therefore cannot compete.
> # Pre-populate HitQueue with sentinel values in TSDC (score = Float.NEG_INF) 
> and remove the check if reusableSD == null.
> # Also move to use "changing top" and then call adjustTop(), in case we 
> update the queue.
> # some methods in Sort explicitly add SortField.FIELD_DOC as a "tie breaker" 
> for the last SortField. But, doing so should not be necessary (since we 
> already break ties by docID), and is in fact less efficient (once the above 
> optimization is in).
> # Investigate PQ - can we deprecate insert() and have only 
> insertWithOverflow()? Add a addDummyObjects method which will populate the 
> queue without "arranging" it, just store the objects in the array (this can 
> be used to pre-populate sentinel values)?
> I will post a patch as well as some perf measurements as soon as I have them.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to