make this assert more robust

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1596346 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2014-05-20 18:17:30 +00:00
parent 2224de1147
commit 1e524542e1
1 changed files with 21 additions and 2 deletions

View File

@ -23,6 +23,7 @@ import java.util.Locale;
import java.util.Random;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.MultiDocValues;
import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.index.SortedSetDocValues;
import org.apache.lucene.index.Term;
@ -955,9 +956,27 @@ public class TestFaceting extends SolrTestCaseJ4 {
SortedDocValues singleton1 = DocValues.unwrapSingleton(dv1);
SortedDocValues singleton2 = DocValues.unwrapSingleton(dv2);
if (singleton1 == null || singleton2 == null) {
assertSame(dv1, dv2);
// actually a multi-valued field
if (dv1 instanceof MultiDocValues.MultiSortedSetDocValues) {
// if we produced more than one segment, ensure the core ordinal map is the same object
assertTrue(dv2 instanceof MultiDocValues.MultiSortedSetDocValues);
assertSame(((MultiDocValues.MultiSortedSetDocValues) dv1).mapping,
((MultiDocValues.MultiSortedSetDocValues) dv2).mapping);
} else {
// otherwise, same atomic instance
assertSame(dv1, dv2);
}
} else {
assertSame(singleton1, singleton2);
// just wrapping a field that is actually single-valued
if (singleton1 instanceof MultiDocValues.MultiSortedDocValues) {
// if we produced more than one segment, ensure the core ordinal map is the same object
assertTrue(singleton2 instanceof MultiDocValues.MultiSortedDocValues);
assertSame(((MultiDocValues.MultiSortedDocValues) singleton1).mapping,
((MultiDocValues.MultiSortedDocValues) singleton2).mapping);
} else {
// otherwise, same atomic instance
assertSame(singleton1, singleton2);
}
}
}
}