lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shai Erera (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-1593) Optimizations to TopScoreDocCollector and TopFieldCollector
Date Fri, 24 Apr 2009 17:08:31 GMT

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

Shai Erera commented on LUCENE-1593:
------------------------------------

bq. I think it should work fine, for most types, because we'd set docID (the tie breaker)
to Integer.MAX_VALUE. No special additional if is then required, since that entry would always
compare at the bottom?

That's not so simple. Let's say I initialize the sentinel of IntComp to Integer.MAX_VALUE.
That should have guaranteed that any 'int' < MAX_VAL would compare better. But the code
in TFC compares the current doc against the 'bottom'. For all Sentinels, it means MAX_VAL.
If the input doc's val < MAX_VAL, it compares better. Otherwise, it is rejected, because:
# If it is bigger than the bottom, it should be rejected.
# 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.
Actually, the tie is broken only after it's in queue, when the latter calls compare(). This
assumption removed the 'if' that checked for doc Id value, so if I reinstate it, we don't
really gain anything, right (replacing 'if (queueFull)' with 'if (bottom.doc > doc + docBase)')?

bq. For String we should be able to use U+FFFF.

If we resolve the core issues with sentinel values, than this will be the value I'd use for
Strings, right.

bq. I think we could fix this by allowing one to pass in a docbase when searching?

I actually would like to propose the following: MultiSearcher already fixes the FD.doc before
inserting it to the queue. I can do the same for the FieldDoc.fields() value, in case one
of the fields is FIELD_DOC. This can happen just after searcher.search() returns, and before
MS adds the results to its own FieldDocSortedHitQueue. I already did it, and all the testMultiSearch
cases fail, but that's because they just assert that the bug exists :).
If you think a separate issue is still required, I can do it, but that would mean that the
tests will fail until we fix it, or I don't change Sort in this issue and do it as part of
the other one.

bq. let's fix it to be a deterministic test?

Will do, but it depends - if a new issue is required, I'll do it there.

bq. I was wrong about this

I must say I still didn't fully understand what do you mean here. I intended to keep that
to after everything else will work in that issue's scope, and note if there are any tests
that fail, or BQ actually behaves properly. So I'll simply count on what you say is true :),
since I'm not familiar with that code.

> 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-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message