micpalmia commented on a change in pull request #1343: LUCENE-8103: Use
two-phase iteration in Query- and DoubleValuesSource
URL: https://github.com/apache/lucene-solr/pull/1343#discussion_r392568557
##########
File path:
lucene/core/src/java/org/apache/lucene/search/DoubleValuesSource.java
##########
@@ -608,22 +608,25 @@ public DoubleValues getValues(LeafReaderContext ctx,
DoubleValues scores) throws
return new DoubleValues() {
private final TwoPhaseIterator tpi = scorer.twoPhaseIterator();
private final DocIdSetIterator disi = (tpi == null) ?
scorer.iterator() : tpi.approximation();
-
- private int scorerDoc = -1;
- private boolean thisDocMatches = false;
+ private Boolean thisDocMatches = false;
@Override
public double doubleValue() throws IOException {
- return thisDocMatches ? scorer.score() : Double.NaN;
+ return (thisDocMatches != null && thisDocMatches) ? scorer.score() :
Double.NaN;
}
@Override
public boolean advanceExact(int doc) throws IOException {
- if (scorerDoc < doc) {
- scorerDoc = disi.advance(doc);
- thisDocMatches = tpi==null || tpi.matches();
+ if (disi.docID() < doc) {
Review comment:
You mean something like the following?
```
assert disi.docID() < doc;
disi.advance(doc);
thisDocMatches = null;
if (disi.docID() == doc) {
[...]
```
The disi can advance potentially much further than the requested `doc`, and
that means that, for potentially many requested `doc`s afterwards
,`disi.docID() > doc` might hold. Tests fail for the edit above.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]