LUCENE-6271: fix nocommits in term vectors tests

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene6271@1670424 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan Ernst 2015-03-31 18:57:49 +00:00
parent a1eebea5a2
commit 07c20804b1
3 changed files with 6 additions and 13 deletions

View File

@ -292,8 +292,7 @@ public class TestTermVectorsReader extends LuceneTestCase {
//System.out.println("Term: " + term);
assertEquals(testTerms[i], term);
assertNotNull(termsEnum.postings(null, null));
// nocommit: check
assertNull(termsEnum.postings(null, null, PostingsEnum.ALL)); // no pos
assertNotNull(termsEnum.postings(null, null, PostingsEnum.ALL));
}
reader.close();
}

View File

@ -453,15 +453,12 @@ public abstract class BaseTermVectorsFormatTestCase extends BaseIndexFileFormatT
bits.clear(0);
PostingsEnum docsAndPositionsEnum = termsEnum.postings(bits, random().nextBoolean() ? null : this.docsEnum.get(), PostingsEnum.POSITIONS);
assertEquals(ft.storeTermVectorOffsets() || ft.storeTermVectorPositions(), docsAndPositionsEnum != null);
// nocommit: check
if (docsAndPositionsEnum != null) {
if (terms.hasPositions()) {
assertEquals(PostingsEnum.NO_MORE_DOCS, docsAndPositionsEnum.nextDoc());
}
bits.set(0);
docsAndPositionsEnum = termsEnum.postings(random().nextBoolean() ? bits : null, random().nextBoolean() ? null : docsAndPositionsEnum, PostingsEnum.POSITIONS);
assertEquals(ft.storeTermVectorOffsets() || ft.storeTermVectorPositions(), docsAndPositionsEnum != null);
if (terms.hasPositions() || terms.hasOffsets()) {
assertEquals(0, docsAndPositionsEnum.nextDoc());
final int freq = docsAndPositionsEnum.freq();

View File

@ -1087,9 +1087,10 @@ public final class TestUtil {
return docs(random, termsEnum, liveDocs, reuse, flags);
}
// Returns a DocsEnum from a positioned TermsEnum, but
// randomly sometimes uses a DocsAndFreqsEnum, DocsAndPositionsEnum.
// Returns a PostingsEnum with random features available
public static PostingsEnum docs(Random random, TermsEnum termsEnum, Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
// TODO: simplify this method? it would be easier to randomly either use the flags passed, or do the random selection,
// FREQS should be part fo the random selection instead of outside on its own?
if (random.nextBoolean()) {
if (random.nextBoolean()) {
final int posFlags;
@ -1099,11 +1100,7 @@ public final class TestUtil {
case 2: posFlags = PostingsEnum.PAYLOADS; break;
default: posFlags = PostingsEnum.ALL; break;
}
PostingsEnum docsAndPositions = termsEnum.postings(liveDocs, null, posFlags);
// nocommit: check
if (docsAndPositions != null) {
return docsAndPositions;
}
return termsEnum.postings(liveDocs, null, posFlags);
}
flags |= PostingsEnum.FREQS;
}