mikemccand / stargazers-migration-test

Testing Lucene's Jira -> GitHub issues migration
0 stars 0 forks source link

TopFieldCollector(s) Should Prepopulate Sentinel Objects [LUCENE-8970] #967

Open mikemccand opened 4 years ago

mikemccand commented 4 years ago

We do not repopulate the hit queue with sentinel values today, thus leading to extra checks and extra code.


Legacy Jira details

LUCENE-8970 by Atri Sharma (@atris) on Sep 06 2019, updated Sep 13 2019

mikemccand commented 4 years ago

I did a prototype of this –- it is a bit hairy since, unlike TopDocsCollector, TopFieldComparator does not directly perform comparisons against the bottom but instead uses FieldComparator to do the job. The problem is that FieldComparatorcould maintain its internal queue, which needs to be accordingly set with sentinel values if the queue is prepopulated. This works well with straight implementations, but for comparators like RelevanceComparator, which do not use the passed in slot but instead depend on the presence of the scorer instance to generate the doc to be placed, this can be an issue.

I wonder if it is worth exposing a prePopulate API in FieldComparator which does what it advertises – allows prepopulating the internal structure used for maintaining docID mappings.

[Legacy Jira: Atri Sharma (@atris) on Sep 10 2019]

mikemccand commented 4 years ago

Maybe we can try to do a quick hack to see how much it could bring, but my intuition is that it wouldn't help with performance given that that we are looking at a condition that is easily predictable?

[Legacy Jira: Adrien Grand (@jpountz) on Sep 13 2019]