From e15f5a1b612055caf2b5800eb40827770d43c392 Mon Sep 17 00:00:00 2001 From: aevitas Date: Sat, 1 Apr 2023 13:11:45 +0200 Subject: [PATCH] Update IdentifiableQueryScorer.java --- .../common/query/IdentifiableQueryScorer.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/java/com/twitter/search/common/query/IdentifiableQueryScorer.java b/src/java/com/twitter/search/common/query/IdentifiableQueryScorer.java index 98c8340eb..bede1d632 100644 --- a/src/java/com/twitter/search/common/query/IdentifiableQueryScorer.java +++ b/src/java/com/twitter/search/common/query/IdentifiableQueryScorer.java @@ -25,36 +25,33 @@ public class IdentifiableQueryScorer extends FilteredScorer { @Override public DocIdSetIterator iterator() { - final DocIdSetIterator superDISI = super.iterator(); + DocIdSetIterator superIterator = super.iterator(); return new DocIdSetIterator() { @Override public int docID() { - return superDISI.docID(); + return superIterator.docID(); } @Override public int nextDoc() throws IOException { - int docid = superDISI.nextDoc(); - if (docid != NO_MORE_DOCS) { - attrCollector.collectScorerAttribution(docid, queryId); - } - return docid; + return collectAndReturn(superIterator.nextDoc()); } @Override public int advance(int target) throws IOException { - int docid = superDISI.advance(target); - if (docid != NO_MORE_DOCS) { - attrCollector.collectScorerAttribution(docid, queryId); - } - return docid; + return collectAndReturn(superIterator.advance(target)); } @Override public long cost() { - return superDISI.cost(); + return superIterator.cost(); } + + private int collectAndReturn(int docId) { + if (docId != NO_MORE_DOCS) { + attrCollector.collectScorerAttribution(docId, queryId); + } }; } }