Skip to content

Apache Lucene open-source search software

LUCENE-6271: fix nocommit in TestCodecs

Ryan Ernst1408332ea9b9
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java b/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java
index 364f944da2e..dafe4dd7083 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java
@@ -452,21 +452,15 @@ public class TestCodecs extends LuceneTestCase {
do {
term = field.terms[upto];
if (random().nextInt(3) == 1) {
- final PostingsEnum docs;
final PostingsEnum postings;
if (!field.omitTF) {
+ // TODO: we should randomize which postings features are available, but
+ // need to coordinate this with the checks below that rely on such features
postings = termsEnum.postings(null, null, PostingsEnum.ALL);
- if (postings != null) {
- docs = postings;
- } else {
- // nocommit: check
- docs = TestUtil.docs(random(), termsEnum, null, null, PostingsEnum.FREQS);
- }
} else {
- postings = null;
- docs = TestUtil.docs(random(), termsEnum, null, null, PostingsEnum.NONE);
+ postings = TestUtil.docs(random(), termsEnum, null, null, PostingsEnum.FREQS);
}
- assertNotNull(docs);
+ assertNotNull(postings);
int upto2 = -1;
boolean ended = false;
while(upto2 < term.docs.length-1) {
@@ -477,10 +471,10 @@ public class TestCodecs extends LuceneTestCase {
final int inc = 1+random().nextInt(left-1);
upto2 += inc;
if (random().nextInt(2) == 1) {
- doc = docs.advance(term.docs[upto2]);
+ doc = postings.advance(term.docs[upto2]);
assertEquals(term.docs[upto2], doc);
} else {
- doc = docs.advance(1+term.docs[upto2]);
+ doc = postings.advance(1+term.docs[upto2]);
if (doc == DocIdSetIterator.NO_MORE_DOCS) {
// skipped past last doc
assert upto2 == term.docs.length-1;
@@ -495,12 +489,13 @@ public class TestCodecs extends LuceneTestCase {
}
}
} else {
- doc = docs.nextDoc();
+ doc = postings.nextDoc();
assertTrue(doc != -1);
upto2++;
}
assertEquals(term.docs[upto2], doc);
if (!field.omitTF) {
+ // nocommit: asking for freq() here, but above when field.omitTF == false, PostingsEnum.NONE flag is passed?
assertEquals(term.positions[upto2].length, postings.freq());
if (random().nextInt(2) == 1) {
this.verifyPositions(term.positions[upto2], postings);
@@ -509,7 +504,7 @@ public class TestCodecs extends LuceneTestCase {
}
if (!ended) {
- assertEquals(DocIdSetIterator.NO_MORE_DOCS, docs.nextDoc());
+ assertEquals(DocIdSetIterator.NO_MORE_DOCS, postings.nextDoc());
}
}
upto++;