Apache Solr open-source search software
always check skipping for terms, not just if dF > 16
Michael McCandless8eee4b5b3a72
diff --git a/lucene/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/src/java/org/apache/lucene/index/CheckIndex.javaindex e54309d3ebd..82477ea21e5 100644--- a/lucene/src/java/org/apache/lucene/index/CheckIndex.java+++ b/lucene/src/java/org/apache/lucene/index/CheckIndex.java@@ -813,61 +813,59 @@ public class CheckIndex {}// Test skipping- if (docFreq >= 16) {- if (hasPositions) {- for(int idx=0;idx<7;idx++) {- final int skipDocID = (int) (((idx+1)*(long) maxDoc)/8);- postings = terms.docsAndPositions(liveDocs, postings);- final int docID = postings.advance(skipDocID);- if (docID == DocsEnum.NO_MORE_DOCS) {- break;- } else {- if (docID < skipDocID) {- throw new RuntimeException("term " + term + ": advance(docID=" + skipDocID + ") returned docID=" + docID);- }- final int freq = postings.freq();- if (freq <= 0) {- throw new RuntimeException("termFreq " + freq + " is out of bounds");- }- int lastPosition = -1;- for(int posUpto=0;posUpto<freq;posUpto++) {- final int pos = postings.nextPosition();- if (pos < 0) {- throw new RuntimeException("position " + pos + " is out of bounds");- }- if (pos < lastPosition) {- throw new RuntimeException("position " + pos + " is < lastPosition " + lastPosition);- }- lastPosition = pos;- }-- final int nextDocID = postings.nextDoc();- if (nextDocID == DocsEnum.NO_MORE_DOCS) {- break;+ if (hasPositions) {+ for(int idx=0;idx<7;idx++) {+ final int skipDocID = (int) (((idx+1)*(long) maxDoc)/8);+ postings = terms.docsAndPositions(liveDocs, postings);+ final int docID = postings.advance(skipDocID);+ if (docID == DocsEnum.NO_MORE_DOCS) {+ break;+ } else {+ if (docID < skipDocID) {+ throw new RuntimeException("term " + term + ": advance(docID=" + skipDocID + ") returned docID=" + docID);+ }+ final int freq = postings.freq();+ if (freq <= 0) {+ throw new RuntimeException("termFreq " + freq + " is out of bounds");+ }+ int lastPosition = -1;+ for(int posUpto=0;posUpto<freq;posUpto++) {+ final int pos = postings.nextPosition();+ if (pos < 0) {+ throw new RuntimeException("position " + pos + " is out of bounds");}- if (nextDocID <= docID) {- throw new RuntimeException("term " + term + ": advance(docID=" + skipDocID + "), then .next() returned docID=" + nextDocID + " vs prev docID=" + docID);+ if (pos < lastPosition) {+ throw new RuntimeException("position " + pos + " is < lastPosition " + lastPosition);}+ lastPosition = pos;+ }++ final int nextDocID = postings.nextDoc();+ if (nextDocID == DocsEnum.NO_MORE_DOCS) {+ break;+ }+ if (nextDocID <= docID) {+ throw new RuntimeException("term " + term + ": advance(docID=" + skipDocID + "), then .next() returned docID=" + nextDocID + " vs prev docID=" + docID);}}- } else {- for(int idx=0;idx<7;idx++) {- final int skipDocID = (int) (((idx+1)*(long) maxDoc)/8);- docs = terms.docs(liveDocs, docs);- final int docID = docs.advance(skipDocID);- if (docID == DocsEnum.NO_MORE_DOCS) {+ }+ } else {+ for(int idx=0;idx<7;idx++) {+ final int skipDocID = (int) (((idx+1)*(long) maxDoc)/8);+ docs = terms.docs(liveDocs, docs);+ final int docID = docs.advance(skipDocID);+ if (docID == DocsEnum.NO_MORE_DOCS) {+ break;+ } else {+ if (docID < skipDocID) {+ throw new RuntimeException("term " + term + ": advance(docID=" + skipDocID + ") returned docID=" + docID);+ }+ final int nextDocID = docs.nextDoc();+ if (nextDocID == DocsEnum.NO_MORE_DOCS) {break;- } else {- if (docID < skipDocID) {- throw new RuntimeException("term " + term + ": advance(docID=" + skipDocID + ") returned docID=" + docID);- }- final int nextDocID = docs.nextDoc();- if (nextDocID == DocsEnum.NO_MORE_DOCS) {- break;- }- if (nextDocID <= docID) {- throw new RuntimeException("term " + term + ": advance(docID=" + skipDocID + "), then .next() returned docID=" + nextDocID + " vs prev docID=" + docID);- }+ }+ if (nextDocID <= docID) {+ throw new RuntimeException("term " + term + ": advance(docID=" + skipDocID + "), then .next() returned docID=" + nextDocID + " vs prev docID=" + docID);}}}