LUCENE-9620: Implement AssertingWeight#count.

This commit is contained in:
Adrien Grand 2021-09-03 14:43:32 +02:00
parent 4bb018e904
commit b3ce44cd0d
1 changed files with 9 additions and 0 deletions

View File

@ -33,6 +33,15 @@ class AssertingWeight extends FilterWeight {
this.scoreMode = scoreMode; this.scoreMode = scoreMode;
} }
@Override
public int count(LeafReaderContext context) throws IOException {
final int count = in.count(context);
if (count < -1 || count > context.reader().numDocs()) {
throw new AssertionError("count=" + count + ", numDocs=" + context.reader().numDocs());
}
return count;
}
@Override @Override
public Matches matches(LeafReaderContext context, int doc) throws IOException { public Matches matches(LeafReaderContext context, int doc) throws IOException {
Matches matches = in.matches(context, doc); Matches matches = in.matches(context, doc);