mirror of https://github.com/apache/lucene.git
LUCENE-6271: simplify CheckIndex's PostingsEnum uses
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene6271@1670380 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
198ec5516b
commit
ca6a9ca92a
|
@ -917,8 +917,7 @@ public class CheckIndex implements Closeable {
|
|||
|
||||
final Status.TermIndexStatus status = new Status.TermIndexStatus();
|
||||
int computedFieldCount = 0;
|
||||
|
||||
PostingsEnum docs = null;
|
||||
|
||||
PostingsEnum postings = null;
|
||||
|
||||
String lastField = null;
|
||||
|
@ -1068,9 +1067,7 @@ public class CheckIndex implements Closeable {
|
|||
throw new RuntimeException("docfreq: " + docFreq + " is out of bounds");
|
||||
}
|
||||
sumDocFreq += docFreq;
|
||||
|
||||
docs = termsEnum.postings(liveDocs, docs);
|
||||
// nocommit: check null
|
||||
|
||||
postings = termsEnum.postings(liveDocs, postings, PostingsEnum.ALL);
|
||||
|
||||
if (hasFreqs == false) {
|
||||
|
@ -1095,18 +1092,11 @@ public class CheckIndex implements Closeable {
|
|||
}
|
||||
}
|
||||
|
||||
final PostingsEnum docs2;
|
||||
if (postings != null) {
|
||||
docs2 = postings;
|
||||
} else {
|
||||
docs2 = docs;
|
||||
}
|
||||
|
||||
int lastDoc = -1;
|
||||
int docCount = 0;
|
||||
long totalTermFreq = 0;
|
||||
while(true) {
|
||||
final int doc = docs2.nextDoc();
|
||||
final int doc = postings.nextDoc();
|
||||
if (doc == DocIdSetIterator.NO_MORE_DOCS) {
|
||||
break;
|
||||
}
|
||||
|
@ -1114,7 +1104,7 @@ public class CheckIndex implements Closeable {
|
|||
visitedDocs.set(doc);
|
||||
int freq = -1;
|
||||
if (hasFreqs) {
|
||||
freq = docs2.freq();
|
||||
freq = postings.freq();
|
||||
if (freq <= 0) {
|
||||
throw new RuntimeException("term " + term + ": doc " + doc + ": freq " + freq + " is out of bounds");
|
||||
}
|
||||
|
@ -1124,7 +1114,7 @@ public class CheckIndex implements Closeable {
|
|||
// When a field didn't index freq, it must
|
||||
// consistently "lie" and pretend that freq was
|
||||
// 1:
|
||||
if (docs2.freq() != 1) {
|
||||
if (postings.freq() != 1) {
|
||||
throw new RuntimeException("term " + term + ": doc " + doc + ": freq " + freq + " != 1 when Terms.hasFreqs() is false");
|
||||
}
|
||||
}
|
||||
|
@ -1196,20 +1186,20 @@ public class CheckIndex implements Closeable {
|
|||
// Re-count if there are deleted docs:
|
||||
if (liveDocs != null) {
|
||||
if (hasFreqs) {
|
||||
docs = termsEnum.postings(null, docs);
|
||||
postings = termsEnum.postings(null, postings);
|
||||
docCount = 0;
|
||||
totalTermFreq = 0;
|
||||
while(docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
|
||||
visitedDocs.set(docs.docID());
|
||||
while(postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
|
||||
visitedDocs.set(postings.docID());
|
||||
docCount++;
|
||||
totalTermFreq += docs.freq();
|
||||
totalTermFreq += postings.freq();
|
||||
}
|
||||
} else {
|
||||
docs = termsEnum.postings(null, docs, PostingsEnum.NONE);
|
||||
postings = termsEnum.postings(null, postings, PostingsEnum.NONE);
|
||||
docCount = 0;
|
||||
totalTermFreq = -1;
|
||||
while(docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
|
||||
visitedDocs.set(docs.docID());
|
||||
while(postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
|
||||
visitedDocs.set(postings.docID());
|
||||
docCount++;
|
||||
}
|
||||
}
|
||||
|
@ -1296,15 +1286,15 @@ public class CheckIndex implements Closeable {
|
|||
} else {
|
||||
for(int idx=0;idx<7;idx++) {
|
||||
final int skipDocID = (int) (((idx+1)*(long) maxDoc)/8);
|
||||
docs = termsEnum.postings(liveDocs, docs, PostingsEnum.NONE);
|
||||
final int docID = docs.advance(skipDocID);
|
||||
postings = termsEnum.postings(liveDocs, postings, PostingsEnum.NONE);
|
||||
final int docID = postings.advance(skipDocID);
|
||||
if (docID == DocIdSetIterator.NO_MORE_DOCS) {
|
||||
break;
|
||||
} else {
|
||||
if (docID < skipDocID) {
|
||||
throw new RuntimeException("term " + term + ": advance(docID=" + skipDocID + ") returned docID=" + docID);
|
||||
}
|
||||
final int nextDocID = docs.nextDoc();
|
||||
final int nextDocID = postings.nextDoc();
|
||||
if (nextDocID == DocIdSetIterator.NO_MORE_DOCS) {
|
||||
break;
|
||||
}
|
||||
|
@ -1409,13 +1399,12 @@ public class CheckIndex implements Closeable {
|
|||
throw new RuntimeException("seek to existing term " + seekTerms[i] + " failed");
|
||||
}
|
||||
|
||||
docs = termsEnum.postings(liveDocs, docs, PostingsEnum.NONE);
|
||||
// nocommit: null check still needed? how to replace?
|
||||
if (docs == null) {
|
||||
postings = termsEnum.postings(liveDocs, postings, PostingsEnum.NONE);
|
||||
if (postings == null) {
|
||||
throw new RuntimeException("null DocsEnum from to existing term " + seekTerms[i]);
|
||||
}
|
||||
|
||||
while(docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
|
||||
|
||||
while (postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
|
||||
totDocCount++;
|
||||
}
|
||||
}
|
||||
|
@ -1428,13 +1417,12 @@ public class CheckIndex implements Closeable {
|
|||
}
|
||||
|
||||
totDocFreq += termsEnum.docFreq();
|
||||
docs = termsEnum.postings(null, docs, PostingsEnum.NONE);
|
||||
// nocommit: null check still needed? how to replace?
|
||||
if (docs == null) {
|
||||
postings = termsEnum.postings(null, postings, PostingsEnum.NONE);
|
||||
if (postings == null) {
|
||||
throw new RuntimeException("null DocsEnum from to existing term " + seekTerms[i]);
|
||||
}
|
||||
|
||||
while(docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
|
||||
while(postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
|
||||
totDocCountNoDeletes++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue