mirror of https://github.com/apache/lucene.git
LUCENE-2858: fix tests
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene2858@1237378 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
40ee62e573
commit
bc95fc57e6
|
@ -284,11 +284,13 @@ public class TestPostingsOffsets extends LuceneTestCase {
|
||||||
doc.add(new Field("content", new CannedAnalyzer.CannedTokenizer(tokens.toArray(new Token[tokens.size()])), ft));
|
doc.add(new Field("content", new CannedAnalyzer.CannedTokenizer(tokens.toArray(new Token[tokens.size()])), ft));
|
||||||
w.addDocument(doc);
|
w.addDocument(doc);
|
||||||
}
|
}
|
||||||
final IndexReader r = w.getReader();
|
final DirectoryReader r = w.getReader();
|
||||||
w.close();
|
w.close();
|
||||||
|
|
||||||
final String[] terms = new String[] {"a", "b", "c", "d"};
|
final String[] terms = new String[] {"a", "b", "c", "d"};
|
||||||
for(IndexReader sub : r.getSequentialSubReaders()) {
|
for(IndexReader reader : r.getSequentialSubReaders()) {
|
||||||
|
// TODO: improve this
|
||||||
|
AtomicIndexReader sub = (AtomicIndexReader) reader;
|
||||||
//System.out.println("\nsub=" + sub);
|
//System.out.println("\nsub=" + sub);
|
||||||
final TermsEnum termsEnum = sub.fields().terms("content").iterator(null);
|
final TermsEnum termsEnum = sub.fields().terms("content").iterator(null);
|
||||||
DocsEnum docs = null;
|
DocsEnum docs = null;
|
||||||
|
|
|
@ -53,8 +53,8 @@ public class TestSegmentMerger extends LuceneTestCase {
|
||||||
SegmentInfo info1 = DocHelper.writeDoc(random, merge1Dir, doc1);
|
SegmentInfo info1 = DocHelper.writeDoc(random, merge1Dir, doc1);
|
||||||
DocHelper.setupDoc(doc2);
|
DocHelper.setupDoc(doc2);
|
||||||
SegmentInfo info2 = DocHelper.writeDoc(random, merge2Dir, doc2);
|
SegmentInfo info2 = DocHelper.writeDoc(random, merge2Dir, doc2);
|
||||||
reader1 = new SegmentReader(info1, IndexReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
|
reader1 = new SegmentReader(info1, DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
|
||||||
reader2 = new SegmentReader(info2, IndexReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
|
reader2 = new SegmentReader(info2, DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,7 +87,7 @@ public class TestSegmentMerger extends LuceneTestCase {
|
||||||
//Should be able to open a new SegmentReader against the new directory
|
//Should be able to open a new SegmentReader against the new directory
|
||||||
SegmentReader mergedReader = new SegmentReader(new SegmentInfo(mergedSegment, docsMerged, mergedDir, false,
|
SegmentReader mergedReader = new SegmentReader(new SegmentInfo(mergedSegment, docsMerged, mergedDir, false,
|
||||||
codec, fieldInfos),
|
codec, fieldInfos),
|
||||||
IndexReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
|
DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR, newIOContext(random));
|
||||||
assertTrue(mergedReader != null);
|
assertTrue(mergedReader != null);
|
||||||
assertTrue(mergedReader.numDocs() == 2);
|
assertTrue(mergedReader.numDocs() == 2);
|
||||||
Document newDoc1 = mergedReader.document(0);
|
Document newDoc1 = mergedReader.document(0);
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class TestStressIndexing2 extends LuceneTestCase {
|
||||||
|
|
||||||
// TODO: verify equals using IW.getReader
|
// TODO: verify equals using IW.getReader
|
||||||
DocsAndWriter dw = indexRandomIWReader(5, 3, 100, dir);
|
DocsAndWriter dw = indexRandomIWReader(5, 3, 100, dir);
|
||||||
IndexReader reader = dw.writer.getReader();
|
DirectoryReader reader = dw.writer.getReader();
|
||||||
dw.writer.commit();
|
dw.writer.commit();
|
||||||
verifyEquals(random, reader, dir, "id");
|
verifyEquals(random, reader, dir, "id");
|
||||||
reader.close();
|
reader.close();
|
||||||
|
@ -265,24 +265,25 @@ public class TestStressIndexing2 extends LuceneTestCase {
|
||||||
w.close();
|
w.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void verifyEquals(Random r, IndexReader r1, Directory dir2, String idField) throws Throwable {
|
public static void verifyEquals(Random r, DirectoryReader r1, Directory dir2, String idField) throws Throwable {
|
||||||
IndexReader r2 = IndexReader.open(dir2);
|
DirectoryReader r2 = IndexReader.open(dir2);
|
||||||
verifyEquals(r1, r2, idField);
|
verifyEquals(r1, r2, idField);
|
||||||
r2.close();
|
r2.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void verifyEquals(Directory dir1, Directory dir2, String idField) throws Throwable {
|
public static void verifyEquals(Directory dir1, Directory dir2, String idField) throws Throwable {
|
||||||
IndexReader r1 = IndexReader.open(dir1);
|
DirectoryReader r1 = IndexReader.open(dir1);
|
||||||
IndexReader r2 = IndexReader.open(dir2);
|
DirectoryReader r2 = IndexReader.open(dir2);
|
||||||
verifyEquals(r1, r2, idField);
|
verifyEquals(r1, r2, idField);
|
||||||
r1.close();
|
r1.close();
|
||||||
r2.close();
|
r2.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printDocs(IndexReader r) throws Throwable {
|
private static void printDocs(DirectoryReader r) throws Throwable {
|
||||||
IndexReader[] subs = r.getSequentialSubReaders();
|
IndexReader[] subs = r.getSequentialSubReaders();
|
||||||
for(IndexReader sub : subs) {
|
for(IndexReader sub : subs) {
|
||||||
Bits liveDocs = sub.getLiveDocs();
|
// TODO: improve this
|
||||||
|
Bits liveDocs = ((AtomicIndexReader)sub).getLiveDocs();
|
||||||
System.out.println(" " + ((SegmentReader) sub).getSegmentInfo());
|
System.out.println(" " + ((SegmentReader) sub).getSegmentInfo());
|
||||||
for(int docID=0;docID<sub.maxDoc();docID++) {
|
for(int docID=0;docID<sub.maxDoc();docID++) {
|
||||||
Document doc = sub.document(docID);
|
Document doc = sub.document(docID);
|
||||||
|
@ -296,7 +297,7 @@ public class TestStressIndexing2 extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void verifyEquals(IndexReader r1, IndexReader r2, String idField) throws Throwable {
|
public static void verifyEquals(DirectoryReader r1, DirectoryReader r2, String idField) throws Throwable {
|
||||||
if (VERBOSE) {
|
if (VERBOSE) {
|
||||||
System.out.println("\nr1 docs:");
|
System.out.println("\nr1 docs:");
|
||||||
printDocs(r1);
|
printDocs(r1);
|
||||||
|
|
Loading…
Reference in New Issue