mirror of https://github.com/apache/lucene.git
beef up tests for docvalues merging
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1615168 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cb84bf6888
commit
b9c0ca78d4
|
@ -1337,10 +1337,9 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
int id = random().nextInt(numDocs);
|
||||
writer.deleteDocuments(new Term("id", Integer.toString(id)));
|
||||
}
|
||||
writer.shutdown();
|
||||
|
||||
// compare
|
||||
DirectoryReader ir = DirectoryReader.open(dir);
|
||||
DirectoryReader ir = writer.getReader();
|
||||
for (AtomicReaderContext context : ir.leaves()) {
|
||||
AtomicReader r = context.reader();
|
||||
BinaryDocValues docValues = r.getBinaryDocValues("dv");
|
||||
|
@ -1351,6 +1350,21 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
}
|
||||
ir.close();
|
||||
|
||||
// compare again
|
||||
writer.forceMerge(1);
|
||||
ir = writer.getReader();
|
||||
for (AtomicReaderContext context : ir.leaves()) {
|
||||
AtomicReader r = context.reader();
|
||||
BinaryDocValues docValues = r.getBinaryDocValues("dv");
|
||||
for (int i = 0; i < r.maxDoc(); i++) {
|
||||
BytesRef binaryValue = r.document(i).getBinaryValue("stored");
|
||||
BytesRef scratch = docValues.get(i);
|
||||
assertEquals(binaryValue, scratch);
|
||||
}
|
||||
}
|
||||
ir.close();
|
||||
writer.shutdown();
|
||||
dir.close();
|
||||
}
|
||||
|
||||
|
@ -1407,10 +1421,9 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
int id = random().nextInt(numDocs);
|
||||
writer.deleteDocuments(new Term("id", Integer.toString(id)));
|
||||
}
|
||||
writer.shutdown();
|
||||
|
||||
// compare
|
||||
DirectoryReader ir = DirectoryReader.open(dir);
|
||||
DirectoryReader ir = writer.getReader();
|
||||
for (AtomicReaderContext context : ir.leaves()) {
|
||||
AtomicReader r = context.reader();
|
||||
BinaryDocValues docValues = r.getSortedDocValues("dv");
|
||||
|
@ -1421,6 +1434,21 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
}
|
||||
ir.close();
|
||||
writer.forceMerge(1);
|
||||
|
||||
// compare again
|
||||
ir = writer.getReader();
|
||||
for (AtomicReaderContext context : ir.leaves()) {
|
||||
AtomicReader r = context.reader();
|
||||
BinaryDocValues docValues = r.getSortedDocValues("dv");
|
||||
for (int i = 0; i < r.maxDoc(); i++) {
|
||||
BytesRef binaryValue = r.document(i).getBinaryValue("stored");
|
||||
BytesRef scratch = docValues.get(i);
|
||||
assertEquals(binaryValue, scratch);
|
||||
}
|
||||
}
|
||||
ir.close();
|
||||
writer.shutdown();
|
||||
dir.close();
|
||||
}
|
||||
|
||||
|
@ -1879,7 +1907,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
|
||||
private void doTestSortedSetVsStoredFields(int minLength, int maxLength, int maxValuesPerDoc) throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||
IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, conf);
|
||||
|
||||
// index some docs
|
||||
|
@ -1925,10 +1953,9 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
int id = random().nextInt(numDocs);
|
||||
writer.deleteDocuments(new Term("id", Integer.toString(id)));
|
||||
}
|
||||
writer.shutdown();
|
||||
|
||||
// compare
|
||||
DirectoryReader ir = DirectoryReader.open(dir);
|
||||
DirectoryReader ir = writer.getReader();
|
||||
for (AtomicReaderContext context : ir.leaves()) {
|
||||
AtomicReader r = context.reader();
|
||||
SortedSetDocValues docValues = r.getSortedSetDocValues("dv");
|
||||
|
@ -1948,6 +1975,30 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
}
|
||||
ir.close();
|
||||
writer.forceMerge(1);
|
||||
|
||||
// compare again
|
||||
ir = writer.getReader();
|
||||
for (AtomicReaderContext context : ir.leaves()) {
|
||||
AtomicReader r = context.reader();
|
||||
SortedSetDocValues docValues = r.getSortedSetDocValues("dv");
|
||||
for (int i = 0; i < r.maxDoc(); i++) {
|
||||
String stringValues[] = r.document(i).getValues("stored");
|
||||
if (docValues != null) {
|
||||
docValues.setDocument(i);
|
||||
}
|
||||
for (int j = 0; j < stringValues.length; j++) {
|
||||
assert docValues != null;
|
||||
long ord = docValues.nextOrd();
|
||||
assert ord != NO_MORE_ORDS;
|
||||
BytesRef scratch = docValues.lookupOrd(ord);
|
||||
assertEquals(stringValues[j], scratch.utf8ToString());
|
||||
}
|
||||
assert docValues == null || docValues.nextOrd() == NO_MORE_ORDS;
|
||||
}
|
||||
}
|
||||
ir.close();
|
||||
writer.shutdown();
|
||||
dir.close();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue