mirror of https://github.com/apache/lucene.git
LUCENE-2858: fix test
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene2858@1237305 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
03819e5190
commit
adbadb03aa
|
@ -22,6 +22,8 @@ import java.util.Random;
|
|||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat;
|
||||
import org.apache.lucene.index.AtomicIndexReader;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.DocsEnum;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
|
@ -34,6 +36,7 @@ import org.apache.lucene.util.BytesRef;
|
|||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.LineFileDocs;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.ReaderUtil;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
||||
public class TestReuseDocsEnum extends LuceneTestCase {
|
||||
|
@ -48,19 +51,21 @@ public class TestReuseDocsEnum extends LuceneTestCase {
|
|||
writer.commit();
|
||||
|
||||
IndexReader open = IndexReader.open(dir);
|
||||
IndexReader[] sequentialSubReaders = open.getSequentialSubReaders();
|
||||
for (IndexReader indexReader : sequentialSubReaders) {
|
||||
Terms terms = indexReader.terms("body");
|
||||
TermsEnum iterator = terms.iterator(null);
|
||||
IdentityHashMap<DocsEnum, Boolean> enums = new IdentityHashMap<DocsEnum, Boolean>();
|
||||
MatchNoBits bits = new Bits.MatchNoBits(open.maxDoc());
|
||||
while ((iterator.next()) != null) {
|
||||
DocsEnum docs = iterator.docs(random.nextBoolean() ? bits : new Bits.MatchNoBits(open.maxDoc()), null, random.nextBoolean());
|
||||
enums.put(docs, true);
|
||||
new ReaderUtil.Gather(open) {
|
||||
@Override
|
||||
protected void add(int base, AtomicIndexReader r) throws IOException {
|
||||
Terms terms = r.terms("body");
|
||||
TermsEnum iterator = terms.iterator(null);
|
||||
IdentityHashMap<DocsEnum, Boolean> enums = new IdentityHashMap<DocsEnum, Boolean>();
|
||||
MatchNoBits bits = new Bits.MatchNoBits(r.maxDoc());
|
||||
while ((iterator.next()) != null) {
|
||||
DocsEnum docs = iterator.docs(random.nextBoolean() ? bits : new Bits.MatchNoBits(r.maxDoc()), null, random.nextBoolean());
|
||||
enums.put(docs, true);
|
||||
}
|
||||
|
||||
assertEquals(terms.getUniqueTermCount(), enums.size());
|
||||
}
|
||||
|
||||
assertEquals(terms.getUniqueTermCount(), enums.size());
|
||||
}
|
||||
}.run();
|
||||
IOUtils.close(writer, open, dir);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue