[
https://issues.apache.org/jira/browse/LUCENE-8151?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Horatiu Lazu updated LUCENE-8151:
---------------------------------
Attachment: LUCENE-8151.patch
> Redundant conditionals in JoinUtil
> ----------------------------------
>
> Key: LUCENE-8151
> URL: https://issues.apache.org/jira/browse/LUCENE-8151
> Project: Lucene - Core
> Issue Type: Improvement
> Reporter: Horatiu Lazu
> Priority: Trivial
> Attachments: LUCENE-8151.patch
>
>
> JoinUtil has a strange conditional structure, which can be collapsed under
> one function call:
> On line 200:
> {code:java}
> @Override
> public void collect(int doc) throws IOException {
> if (doc > sortedNumericDocValues.docID()) {
> sortedNumericDocValues.advance(doc);
> }
> if (doc == sortedNumericDocValues.docID()) {
> for (int i = 0; i < sortedNumericDocValues.docValueCount(); i++) {
> long value = sortedNumericDocValues.nextValue();
> joinValues.add(value);
> if (needsScore) {
> scoreAggregator.accept(value, scorer.score());
> }
> }
> }
> }{code}
> Instead, just do advanceExact, which returns a boolean indicating if it was
> successful:
> {code:java}
> @Override
> public void collect(int doc) throws IOException {
> if (sortedNumericDocValues.advanceExact(doc)) {
> for (int i = 0; i < sortedNumericDocValues.docValueCount(); i++) {
> long value = sortedNumericDocValues.nextValue();
> joinValues.add(value);
> if (needsScore) {
> scoreAggregator.accept(value, scorer.score());
> }
> }
> }
> }
> {code}
> I have the patch ready, it passes unit tests.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]