lucene icon indicating copy to clipboard operation
lucene copied to clipboard

Stop double-checking priority queue inserts

Open stefanvodita opened this issue 11 months ago • 2 comments

Description

There are several occurrences in our code where we check that an incoming value can be inserted in a priority queue and then call insertWithOverflow, which re-does the check. Let's stop checking before calling insertWithOverflow.

Credit to @epotyom for noticing this in AbstractSortedSetDocValueFacetCounts.

stefanvodita avatar Mar 10 '24 08:03 stefanvodita

Maybe we can also extract out a common function from all the Facets inserting into a priority queue, as @Shradha26 suggests.

stefanvodita avatar Mar 10 '24 19:03 stefanvodita

Maybe we can also extract out a common function from all the Facets inserting into a priority queue, as @Shradha26 suggests.

I can't see a way to do this cleanly since e.g. StringValueFacetCounts uses TopOrdAndIntQueue while the TaxonomyFacets abstract class uses TopOrdAndNumberQueue which gets casted to int in setIncomingValue. If we refactored this to a util method, we would lose the ability to override setIncomingValue in the case of non-int queues.

I'll submit a PR for the issue in the initial description.

slow-J avatar Jun 14 '24 12:06 slow-J