mirror of https://github.com/apache/lucene.git
LUCENE-5858: remove conditionals around codec features
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5858@1621828 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
704b3fb091
commit
b33100c590
|
@ -37,4 +37,20 @@ public class TestLucene40DocValuesFormat extends BaseDocValuesFormatTestCase {
|
|||
return false;
|
||||
}
|
||||
|
||||
// this codec doesnt support missing (its the same as empty string)
|
||||
@Override
|
||||
protected boolean codecSupportsDocsWithField() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean codecSupportsSortedSet() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean codecSupportsSortedNumeric() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,4 +36,15 @@ public class TestLucene42DocValuesFormat extends BaseCompressingDocValuesFormatT
|
|||
protected boolean codecAcceptsHugeBinaryValues(String field) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// this codec doesnt support missing (its the same as empty string)
|
||||
@Override
|
||||
protected boolean codecSupportsDocsWithField() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean codecSupportsSortedNumeric() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,4 +31,9 @@ public class TestLucene45DocValuesFormat extends BaseCompressingDocValuesFormatT
|
|||
protected Codec getCodec() {
|
||||
return codec;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean codecSupportsSortedNumeric() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -378,7 +378,6 @@ public class TestDocValuesIndexing extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public void testTooLargeTermSortedSetBytes() throws IOException {
|
||||
assumeTrue("codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
|
||||
Directory directory = newDirectory();
|
||||
|
|
|
@ -1037,14 +1037,10 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
doc.add(new BinaryDocValuesField("binarydv", new BytesRef("500")));
|
||||
doc.add(new NumericDocValuesField("numericdv", 500));
|
||||
doc.add(new SortedDocValuesField("sorteddv", new BytesRef("500")));
|
||||
if (defaultCodecSupportsSortedSet()) {
|
||||
doc.add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("one")));
|
||||
doc.add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("two")));
|
||||
}
|
||||
if (defaultCodecSupportsSortedNumeric()) {
|
||||
doc.add(new SortedNumericDocValuesField("sortednumericdv", 4));
|
||||
doc.add(new SortedNumericDocValuesField("sortednumericdv", 3));
|
||||
}
|
||||
doc.add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("one")));
|
||||
doc.add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("two")));
|
||||
doc.add(new SortedNumericDocValuesField("sortednumericdv", 4));
|
||||
doc.add(new SortedNumericDocValuesField("sortednumericdv", 3));
|
||||
w.addDocument(doc);
|
||||
doc = new Document();
|
||||
doc.add(newStringField(random, "id", "501", Field.Store.NO));
|
||||
|
@ -1052,14 +1048,10 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
doc.add(new BinaryDocValuesField("binarydv", new BytesRef("501")));
|
||||
doc.add(new NumericDocValuesField("numericdv", 501));
|
||||
doc.add(new SortedDocValuesField("sorteddv", new BytesRef("501")));
|
||||
if (defaultCodecSupportsSortedSet()) {
|
||||
doc.add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("two")));
|
||||
doc.add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("three")));
|
||||
}
|
||||
if (defaultCodecSupportsSortedNumeric()) {
|
||||
doc.add(new SortedNumericDocValuesField("sortednumericdv", 6));
|
||||
doc.add(new SortedNumericDocValuesField("sortednumericdv", 1));
|
||||
}
|
||||
doc.add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("two")));
|
||||
doc.add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("three")));
|
||||
doc.add(new SortedNumericDocValuesField("sortednumericdv", 6));
|
||||
doc.add(new SortedNumericDocValuesField("sortednumericdv", 1));
|
||||
w.addDocument(doc);
|
||||
w.deleteDocuments(new Term("id", "500"));
|
||||
w.close();
|
||||
|
@ -1108,9 +1100,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
doc.add(binaryDVField);
|
||||
doc.add(numericDVField);
|
||||
doc.add(sortedDVField);
|
||||
if (defaultCodecSupportsSortedSet()) {
|
||||
doc.add(sortedSetDVField);
|
||||
}
|
||||
doc.add(sortedSetDVField);
|
||||
for(int i=0;i<100;i++) {
|
||||
idField.setStringValue(Integer.toString(i));
|
||||
binaryDVField.setBytesValue(new BytesRef(idField.stringValue()));
|
||||
|
@ -2893,11 +2883,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
assertNotNull(id1);
|
||||
|
||||
String id2 = sis.info(0).info.getId();
|
||||
if (defaultCodecSupportsSegmentIds()) {
|
||||
assertNotNull(id2);
|
||||
} else {
|
||||
assertNull(id2);
|
||||
}
|
||||
assertNotNull(id2);
|
||||
|
||||
// Make sure CheckIndex includes id output:
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
|
||||
|
@ -2912,12 +2898,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
// Commit id is always stored:
|
||||
assertTrue("missing id=" + id1 + " in:\n" + s, s.contains("id=" + id1));
|
||||
|
||||
// Per-segment id may or may not be stored depending on the codec:
|
||||
if (defaultCodecSupportsSegmentIds()) {
|
||||
assertTrue("missing id=" + id2 + " in:\n" + s, s.contains("id=" + id2));
|
||||
} else {
|
||||
assertTrue("missing id=null in:\n" + s, s.contains("id=null"));
|
||||
}
|
||||
assertTrue("missing id=" + id2 + " in:\n" + s, s.contains("id=" + id2));
|
||||
d.close();
|
||||
|
||||
Set<String> ids = new HashSet<>();
|
||||
|
|
|
@ -156,14 +156,10 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
|
|||
doc.add(new NumericDocValuesField("numericdv", 5));
|
||||
doc.add(new BinaryDocValuesField("binarydv", new BytesRef("hello")));
|
||||
doc.add(new SortedDocValuesField("sorteddv", new BytesRef("world")));
|
||||
if (defaultCodecSupportsSortedSet()) {
|
||||
doc.add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("hellllo")));
|
||||
doc.add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("again")));
|
||||
}
|
||||
if (defaultCodecSupportsSortedNumeric()) {
|
||||
doc.add(new SortedNumericDocValuesField("sortednumericdv", 10));
|
||||
doc.add(new SortedNumericDocValuesField("sortednumericdv", 5));
|
||||
}
|
||||
doc.add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("hellllo")));
|
||||
doc.add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("again")));
|
||||
doc.add(new SortedNumericDocValuesField("sortednumericdv", 10));
|
||||
doc.add(new SortedNumericDocValuesField("sortednumericdv", 5));
|
||||
|
||||
doc.add(newField(r, "content7", "aaa bbb ccc ddd", DocCopyIterator.custom4));
|
||||
|
||||
|
@ -2054,10 +2050,9 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
|
|||
shouldFail.set(true);
|
||||
boolean doClose = false;
|
||||
try {
|
||||
boolean defaultCodecSupportsFieldUpdates = defaultCodecSupportsFieldUpdates();
|
||||
for(int i=0;i<numDocs;i++) {
|
||||
if (random().nextInt(10) == 7) {
|
||||
boolean fieldUpdate = defaultCodecSupportsFieldUpdates && random().nextBoolean();
|
||||
boolean fieldUpdate = random().nextBoolean();
|
||||
int docid = docBase + i;
|
||||
if (fieldUpdate) {
|
||||
long value = iter;
|
||||
|
|
|
@ -106,14 +106,10 @@ public class TestIndexWriterExceptions2 extends LuceneTestCase {
|
|||
doc.add(new NumericDocValuesField("dv", i));
|
||||
doc.add(new BinaryDocValuesField("dv2", new BytesRef(Integer.toString(i))));
|
||||
doc.add(new SortedDocValuesField("dv3", new BytesRef(Integer.toString(i))));
|
||||
if (defaultCodecSupportsSortedSet()) {
|
||||
doc.add(new SortedSetDocValuesField("dv4", new BytesRef(Integer.toString(i))));
|
||||
doc.add(new SortedSetDocValuesField("dv4", new BytesRef(Integer.toString(i-1))));
|
||||
}
|
||||
if (defaultCodecSupportsSortedNumeric()) {
|
||||
doc.add(new SortedNumericDocValuesField("dv5", i));
|
||||
doc.add(new SortedNumericDocValuesField("dv5", i-1));
|
||||
}
|
||||
doc.add(new SortedSetDocValuesField("dv4", new BytesRef(Integer.toString(i))));
|
||||
doc.add(new SortedSetDocValuesField("dv4", new BytesRef(Integer.toString(i-1))));
|
||||
doc.add(new SortedNumericDocValuesField("dv5", i));
|
||||
doc.add(new SortedNumericDocValuesField("dv5", i-1));
|
||||
doc.add(newTextField("text1", TestUtil.randomAnalysisString(random(), 20, true), Field.Store.NO));
|
||||
// ensure we store something
|
||||
doc.add(new StoredField("stored1", "foo"));
|
||||
|
@ -133,9 +129,9 @@ public class TestIndexWriterExceptions2 extends LuceneTestCase {
|
|||
int thingToDo = random().nextInt(4);
|
||||
if (thingToDo == 0) {
|
||||
iw.deleteDocuments(new Term("id", Integer.toString(i)));
|
||||
} else if (thingToDo == 1 && defaultCodecSupportsFieldUpdates()) {
|
||||
} else if (thingToDo == 1) {
|
||||
iw.updateNumericDocValue(new Term("id", Integer.toString(i)), "dv", i+1L);
|
||||
} else if (thingToDo == 2 && defaultCodecSupportsFieldUpdates()) {
|
||||
} else if (thingToDo == 2) {
|
||||
iw.updateBinaryDocValue(new Term("id", Integer.toString(i)), "dv2", new BytesRef(Integer.toString(i+1)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -127,14 +127,10 @@ public class TestIndexWriterOutOfMemory extends LuceneTestCase {
|
|||
doc.add(new NumericDocValuesField("dv", i));
|
||||
doc.add(new BinaryDocValuesField("dv2", new BytesRef(Integer.toString(i))));
|
||||
doc.add(new SortedDocValuesField("dv3", new BytesRef(Integer.toString(i))));
|
||||
if (defaultCodecSupportsSortedSet()) {
|
||||
doc.add(new SortedSetDocValuesField("dv4", new BytesRef(Integer.toString(i))));
|
||||
doc.add(new SortedSetDocValuesField("dv4", new BytesRef(Integer.toString(i-1))));
|
||||
}
|
||||
if (defaultCodecSupportsSortedNumeric()) {
|
||||
doc.add(new SortedNumericDocValuesField("dv5", i));
|
||||
doc.add(new SortedNumericDocValuesField("dv5", i-1));
|
||||
}
|
||||
doc.add(new SortedSetDocValuesField("dv4", new BytesRef(Integer.toString(i))));
|
||||
doc.add(new SortedSetDocValuesField("dv4", new BytesRef(Integer.toString(i-1))));
|
||||
doc.add(new SortedNumericDocValuesField("dv5", i));
|
||||
doc.add(new SortedNumericDocValuesField("dv5", i-1));
|
||||
doc.add(newTextField("text1", TestUtil.randomAnalysisString(random(), 20, true), Field.Store.NO));
|
||||
// ensure we store something
|
||||
doc.add(new StoredField("stored1", "foo"));
|
||||
|
@ -154,9 +150,9 @@ public class TestIndexWriterOutOfMemory extends LuceneTestCase {
|
|||
int thingToDo = random().nextInt(4);
|
||||
if (thingToDo == 0) {
|
||||
iw.deleteDocuments(new Term("id", Integer.toString(i)));
|
||||
} else if (thingToDo == 1 && defaultCodecSupportsFieldUpdates()) {
|
||||
} else if (thingToDo == 1) {
|
||||
iw.updateNumericDocValue(new Term("id", Integer.toString(i)), "dv", i+1L);
|
||||
} else if (thingToDo == 2 && defaultCodecSupportsFieldUpdates()) {
|
||||
} else if (thingToDo == 2) {
|
||||
iw.updateBinaryDocValue(new Term("id", Integer.toString(i)), "dv2", new BytesRef(Integer.toString(i+1)));
|
||||
}
|
||||
} catch (OutOfMemoryError e) {
|
||||
|
|
|
@ -120,7 +120,7 @@ public class TestMultiDocValues extends LuceneTestCase {
|
|||
for (int i = 0; i < numDocs; i++) {
|
||||
BytesRef ref = new BytesRef(TestUtil.randomUnicodeString(random()));
|
||||
field.setBytesValue(ref);
|
||||
if (defaultCodecSupportsDocsWithField() && random().nextInt(7) == 0) {
|
||||
if (random().nextInt(7) == 0) {
|
||||
iw.addDocument(new Document());
|
||||
}
|
||||
iw.addDocument(doc);
|
||||
|
@ -193,7 +193,6 @@ public class TestMultiDocValues extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public void testSortedSet() throws Exception {
|
||||
assumeTrue("codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
Directory dir = newDirectory();
|
||||
|
||||
IndexWriterConfig iwc = newIndexWriterConfig(random(), null);
|
||||
|
@ -256,7 +255,6 @@ public class TestMultiDocValues extends LuceneTestCase {
|
|||
|
||||
// tries to make more dups than testSortedSet
|
||||
public void testSortedSetWithDups() throws Exception {
|
||||
assumeTrue("codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
Directory dir = newDirectory();
|
||||
|
||||
IndexWriterConfig iwc = newIndexWriterConfig(random(), null);
|
||||
|
@ -318,7 +316,6 @@ public class TestMultiDocValues extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public void testSortedNumeric() throws Exception {
|
||||
assumeTrue("codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
Directory dir = newDirectory();
|
||||
|
||||
IndexWriterConfig iwc = newIndexWriterConfig(random(), null);
|
||||
|
@ -370,7 +367,6 @@ public class TestMultiDocValues extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public void testDocsWithField() throws Exception {
|
||||
assumeTrue("codec does not support docsWithField", defaultCodecSupportsDocsWithField());
|
||||
Directory dir = newDirectory();
|
||||
|
||||
IndexWriterConfig iwc = newIndexWriterConfig(random(), null);
|
||||
|
|
|
@ -37,7 +37,6 @@ import java.util.List;
|
|||
*/
|
||||
public class TestFieldCacheTermsFilter extends LuceneTestCase {
|
||||
public void testMissingTerms() throws Exception {
|
||||
assumeTrue("requires support for missing values", defaultCodecSupportsMissingDocValues());
|
||||
String fieldName = "field1";
|
||||
Directory rd = newDirectory();
|
||||
RandomIndexWriter w = new RandomIndexWriter(random(), rd);
|
||||
|
|
|
@ -133,10 +133,7 @@ public class TestSortRandom extends LuceneTestCase {
|
|||
final boolean sortMissingLast;
|
||||
final boolean missingIsNull;
|
||||
sf = new SortField("stringdv", type, reverse);
|
||||
// Can only use sort missing if the DVFormat
|
||||
// supports docsWithField:
|
||||
sortMissingLast = defaultCodecSupportsDocsWithField() && random().nextBoolean();
|
||||
missingIsNull = defaultCodecSupportsDocsWithField();
|
||||
sortMissingLast = random().nextBoolean();
|
||||
|
||||
if (sortMissingLast) {
|
||||
sf.setMissingValue(SortField.STRING_LAST);
|
||||
|
@ -206,9 +203,6 @@ public class TestSortRandom extends LuceneTestCase {
|
|||
System.out.println(" expected:");
|
||||
for(int idx=0;idx<expected.size();idx++) {
|
||||
BytesRef br = expected.get(idx);
|
||||
if (br == null && missingIsNull == false) {
|
||||
br = new BytesRef();
|
||||
}
|
||||
System.out.println(" " + idx + ": " + (br == null ? "<missing>" : br.utf8ToString()));
|
||||
if (idx == hitCount-1) {
|
||||
break;
|
||||
|
@ -228,20 +222,8 @@ public class TestSortRandom extends LuceneTestCase {
|
|||
for(int hitIDX=0;hitIDX<hits.scoreDocs.length;hitIDX++) {
|
||||
final FieldDoc fd = (FieldDoc) hits.scoreDocs[hitIDX];
|
||||
BytesRef br = expected.get(hitIDX);
|
||||
if (br == null && missingIsNull == false) {
|
||||
br = new BytesRef();
|
||||
}
|
||||
|
||||
// Normally, the old codecs (that don't support
|
||||
// docsWithField via doc values) will always return
|
||||
// an empty BytesRef for the missing case; however,
|
||||
// if all docs in a given segment were missing, in
|
||||
// that case it will return null! So we must map
|
||||
// null here, too:
|
||||
BytesRef br2 = (BytesRef) fd.fields[0];
|
||||
if (br2 == null && missingIsNull == false) {
|
||||
br2 = new BytesRef();
|
||||
}
|
||||
|
||||
assertEquals(br, br2);
|
||||
}
|
||||
|
|
|
@ -401,8 +401,6 @@ public class TestDrillSideways extends FacetTestCase {
|
|||
|
||||
public void testRandom() throws Exception {
|
||||
|
||||
boolean canUseDV = defaultCodecSupportsSortedSet();
|
||||
|
||||
while (aChance == 0.0) {
|
||||
aChance = random().nextDouble();
|
||||
}
|
||||
|
@ -490,7 +488,7 @@ public class TestDrillSideways extends FacetTestCase {
|
|||
config.setMultiValued("dim"+i, true);
|
||||
}
|
||||
|
||||
boolean doUseDV = canUseDV && random().nextBoolean();
|
||||
boolean doUseDV = random().nextBoolean();
|
||||
|
||||
for(Doc rawDoc : docs) {
|
||||
Document doc = new Document();
|
||||
|
|
|
@ -824,7 +824,6 @@ public class TestRangeFacetCounts extends FacetTestCase {
|
|||
|
||||
// LUCENE-5178
|
||||
public void testMissingValues() throws Exception {
|
||||
assumeTrue("codec does not support docsWithField", defaultCodecSupportsDocsWithField());
|
||||
Directory d = newDirectory();
|
||||
RandomIndexWriter w = new RandomIndexWriter(random(), d);
|
||||
Document doc = new Document();
|
||||
|
|
|
@ -49,7 +49,6 @@ public class TestSortedSetDocValuesFacets extends FacetTestCase {
|
|||
// randomly uses SortedSetDV
|
||||
|
||||
public void testBasic() throws Exception {
|
||||
assumeTrue("Test requires SortedSetDV support", defaultCodecSupportsSortedSet());
|
||||
Directory dir = newDirectory();
|
||||
|
||||
FacetsConfig config = new FacetsConfig();
|
||||
|
@ -99,7 +98,6 @@ public class TestSortedSetDocValuesFacets extends FacetTestCase {
|
|||
// LUCENE-5090
|
||||
@SuppressWarnings("unused")
|
||||
public void testStaleState() throws Exception {
|
||||
assumeTrue("Test requires SortedSetDV support", defaultCodecSupportsSortedSet());
|
||||
Directory dir = newDirectory();
|
||||
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
|
||||
|
@ -142,7 +140,6 @@ public class TestSortedSetDocValuesFacets extends FacetTestCase {
|
|||
|
||||
// LUCENE-5333
|
||||
public void testSparseFacets() throws Exception {
|
||||
assumeTrue("Test requires SortedSetDV support", defaultCodecSupportsSortedSet());
|
||||
Directory dir = newDirectory();
|
||||
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
|
||||
|
@ -196,7 +193,6 @@ public class TestSortedSetDocValuesFacets extends FacetTestCase {
|
|||
}
|
||||
|
||||
public void testSomeSegmentsMissing() throws Exception {
|
||||
assumeTrue("Test requires SortedSetDV support", defaultCodecSupportsSortedSet());
|
||||
Directory dir = newDirectory();
|
||||
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
|
||||
|
@ -236,7 +232,6 @@ public class TestSortedSetDocValuesFacets extends FacetTestCase {
|
|||
}
|
||||
|
||||
public void testSlowCompositeReaderWrapper() throws Exception {
|
||||
assumeTrue("Test requires SortedSetDV support", defaultCodecSupportsSortedSet());
|
||||
Directory dir = newDirectory();
|
||||
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
|
||||
|
@ -272,7 +267,6 @@ public class TestSortedSetDocValuesFacets extends FacetTestCase {
|
|||
|
||||
|
||||
public void testRandom() throws Exception {
|
||||
assumeTrue("Test requires SortedSetDV support", defaultCodecSupportsSortedSet());
|
||||
String[] tokens = getRandomTokens(10);
|
||||
Directory indexDir = newDirectory();
|
||||
Directory taxoDir = newDirectory();
|
||||
|
|
|
@ -182,14 +182,10 @@ public abstract class SorterTestBase extends LuceneTestCase {
|
|||
doc.add(norms);
|
||||
doc.add(new BinaryDocValuesField(BINARY_DV_FIELD, new BytesRef(Integer.toString(id))));
|
||||
doc.add(new SortedDocValuesField(SORTED_DV_FIELD, new BytesRef(Integer.toString(id))));
|
||||
if (defaultCodecSupportsSortedSet()) {
|
||||
doc.add(new SortedSetDocValuesField(SORTED_SET_DV_FIELD, new BytesRef(Integer.toString(id))));
|
||||
doc.add(new SortedSetDocValuesField(SORTED_SET_DV_FIELD, new BytesRef(Integer.toString(id + 1))));
|
||||
}
|
||||
if (defaultCodecSupportsSortedNumeric()) {
|
||||
doc.add(new SortedNumericDocValuesField(SORTED_NUMERIC_DV_FIELD, id));
|
||||
doc.add(new SortedNumericDocValuesField(SORTED_NUMERIC_DV_FIELD, id + 1));
|
||||
}
|
||||
doc.add(new SortedSetDocValuesField(SORTED_SET_DV_FIELD, new BytesRef(Integer.toString(id))));
|
||||
doc.add(new SortedSetDocValuesField(SORTED_SET_DV_FIELD, new BytesRef(Integer.toString(id + 1))));
|
||||
doc.add(new SortedNumericDocValuesField(SORTED_NUMERIC_DV_FIELD, id));
|
||||
doc.add(new SortedNumericDocValuesField(SORTED_NUMERIC_DV_FIELD, id + 1));
|
||||
doc.add(new Field(TERM_VECTORS_FIELD, Integer.toString(id), TERM_VECTORS_TYPE));
|
||||
return doc;
|
||||
}
|
||||
|
@ -381,7 +377,6 @@ public abstract class SorterTestBase extends LuceneTestCase {
|
|||
|
||||
@Test
|
||||
public void testSortedSetDocValuesField() throws Exception {
|
||||
assumeTrue("default codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
SortedSetDocValues dv = reader.getSortedSetDocValues(SORTED_SET_DV_FIELD);
|
||||
int maxDoc = reader.maxDoc();
|
||||
for (int i = 0; i < maxDoc; i++) {
|
||||
|
@ -397,7 +392,6 @@ public abstract class SorterTestBase extends LuceneTestCase {
|
|||
|
||||
@Test
|
||||
public void testSortedNumericDocValuesField() throws Exception {
|
||||
assumeTrue("default codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
SortedNumericDocValues dv = reader.getSortedNumericDocValues(SORTED_NUMERIC_DV_FIELD);
|
||||
int maxDoc = reader.maxDoc();
|
||||
for (int i = 0; i < maxDoc; i++) {
|
||||
|
|
|
@ -135,13 +135,11 @@ public class TestSortingMergePolicy extends LuceneTestCase {
|
|||
iw1.w.addDocument(doc);
|
||||
iw2.w.addDocument(doc);
|
||||
|
||||
if (defaultCodecSupportsFieldUpdates()) {
|
||||
// update NDV of docs belonging to one term (covers many documents)
|
||||
final long value = random().nextLong();
|
||||
final String term = RandomPicks.randomFrom(random(), terms);
|
||||
iw1.w.updateNumericDocValue(new Term("s", term), "ndv", value);
|
||||
iw2.w.updateNumericDocValue(new Term("s", term), "ndv", value);
|
||||
}
|
||||
// update NDV of docs belonging to one term (covers many documents)
|
||||
final long value = random().nextLong();
|
||||
final String term = RandomPicks.randomFrom(random(), terms);
|
||||
iw1.w.updateNumericDocValue(new Term("s", term), "ndv", value);
|
||||
iw2.w.updateNumericDocValue(new Term("s", term), "ndv", value);
|
||||
|
||||
iw1.forceMerge(1);
|
||||
iw2.forceMerge(1);
|
||||
|
|
|
@ -430,10 +430,8 @@ public class TestFieldCache extends LuceneTestCase {
|
|||
doc.add(new BinaryDocValuesField("binary", new BytesRef("binary value")));
|
||||
doc.add(new SortedDocValuesField("sorted", new BytesRef("sorted value")));
|
||||
doc.add(new NumericDocValuesField("numeric", 42));
|
||||
if (defaultCodecSupportsSortedSet()) {
|
||||
doc.add(new SortedSetDocValuesField("sortedset", new BytesRef("sortedset value1")));
|
||||
doc.add(new SortedSetDocValuesField("sortedset", new BytesRef("sortedset value2")));
|
||||
}
|
||||
doc.add(new SortedSetDocValuesField("sortedset", new BytesRef("sortedset value1")));
|
||||
doc.add(new SortedSetDocValuesField("sortedset", new BytesRef("sortedset value2")));
|
||||
iw.addDocument(doc);
|
||||
DirectoryReader ir = iw.getReader();
|
||||
iw.close();
|
||||
|
@ -525,37 +523,35 @@ public class TestFieldCache extends LuceneTestCase {
|
|||
assertTrue(bits.get(0));
|
||||
|
||||
// SortedSet type: can be retrieved via getDocTermOrds()
|
||||
if (defaultCodecSupportsSortedSet()) {
|
||||
try {
|
||||
FieldCache.DEFAULT.getNumerics(ar, "sortedset", FieldCache.NUMERIC_UTILS_INT_PARSER, false);
|
||||
fail();
|
||||
} catch (IllegalStateException expected) {}
|
||||
try {
|
||||
FieldCache.DEFAULT.getNumerics(ar, "sortedset", FieldCache.NUMERIC_UTILS_INT_PARSER, false);
|
||||
fail();
|
||||
} catch (IllegalStateException expected) {}
|
||||
|
||||
try {
|
||||
FieldCache.DEFAULT.getTerms(ar, "sortedset", true);
|
||||
fail();
|
||||
} catch (IllegalStateException expected) {}
|
||||
try {
|
||||
FieldCache.DEFAULT.getTerms(ar, "sortedset", true);
|
||||
fail();
|
||||
} catch (IllegalStateException expected) {}
|
||||
|
||||
try {
|
||||
FieldCache.DEFAULT.getTermsIndex(ar, "sortedset");
|
||||
fail();
|
||||
} catch (IllegalStateException expected) {}
|
||||
|
||||
try {
|
||||
new DocTermOrds(ar, null, "sortedset");
|
||||
fail();
|
||||
} catch (IllegalStateException expected) {}
|
||||
try {
|
||||
FieldCache.DEFAULT.getTermsIndex(ar, "sortedset");
|
||||
fail();
|
||||
} catch (IllegalStateException expected) {}
|
||||
|
||||
sortedSet = FieldCache.DEFAULT.getDocTermOrds(ar, "sortedset", null);
|
||||
sortedSet.setDocument(0);
|
||||
assertEquals(0, sortedSet.nextOrd());
|
||||
assertEquals(1, sortedSet.nextOrd());
|
||||
assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
|
||||
assertEquals(2, sortedSet.getValueCount());
|
||||
try {
|
||||
new DocTermOrds(ar, null, "sortedset");
|
||||
fail();
|
||||
} catch (IllegalStateException expected) {}
|
||||
|
||||
bits = FieldCache.DEFAULT.getDocsWithField(ar, "sortedset");
|
||||
assertTrue(bits.get(0));
|
||||
}
|
||||
sortedSet = FieldCache.DEFAULT.getDocTermOrds(ar, "sortedset", null);
|
||||
sortedSet.setDocument(0);
|
||||
assertEquals(0, sortedSet.nextOrd());
|
||||
assertEquals(1, sortedSet.nextOrd());
|
||||
assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
|
||||
assertEquals(2, sortedSet.getValueCount());
|
||||
|
||||
bits = FieldCache.DEFAULT.getDocsWithField(ar, "sortedset");
|
||||
assertTrue(bits.get(0));
|
||||
|
||||
ir.close();
|
||||
dir.close();
|
||||
|
|
|
@ -99,7 +99,6 @@ public class TestFieldCacheVsDocValues extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public void testSortedSetFixedLengthVsUninvertedField() throws Exception {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
int numIterations = atLeast(1);
|
||||
for (int i = 0; i < numIterations; i++) {
|
||||
int fixedLength = TestUtil.nextInt(random(), 1, 10);
|
||||
|
@ -108,7 +107,6 @@ public class TestFieldCacheVsDocValues extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public void testSortedSetVariableLengthVsUninvertedField() throws Exception {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
int numIterations = atLeast(1);
|
||||
for (int i = 0; i < numIterations; i++) {
|
||||
doTestSortedSetVsUninvertedField(1, 10);
|
||||
|
@ -403,7 +401,6 @@ public class TestFieldCacheVsDocValues extends LuceneTestCase {
|
|||
}
|
||||
|
||||
private void doTestMissingVsFieldCache(LongProducer longs) throws Exception {
|
||||
assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField());
|
||||
Directory dir = newDirectory();
|
||||
IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, conf);
|
||||
|
|
|
@ -78,13 +78,13 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
doc.add(new BinaryDocValuesField("bdv", new BytesRef(TestUtil.randomSimpleString(random()))));
|
||||
doc.add(new SortedDocValuesField("sdv", new BytesRef(TestUtil.randomSimpleString(random(), 2))));
|
||||
}
|
||||
if (defaultCodecSupportsSortedSet()) {
|
||||
if (codecSupportsSortedSet()) {
|
||||
final int numValues = random().nextInt(5);
|
||||
for (int i = 0; i < numValues; ++i) {
|
||||
doc.add(new SortedSetDocValuesField("ssdv", new BytesRef(TestUtil.randomSimpleString(random(), 2))));
|
||||
}
|
||||
}
|
||||
if (defaultCodecSupportsSortedNumeric()) {
|
||||
if (codecSupportsSortedNumeric()) {
|
||||
final int numValues = random().nextInt(5);
|
||||
for (int i = 0; i < numValues; ++i) {
|
||||
doc.add(new SortedNumericDocValuesField("sndv", TestUtil.nextLong(random(), Long.MIN_VALUE, Long.MAX_VALUE)));
|
||||
|
@ -711,7 +711,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
iwriter.close();
|
||||
|
||||
SortedDocValues dv = getOnlySegmentReader(ireader).getSortedDocValues("field");
|
||||
if (defaultCodecSupportsDocsWithField()) {
|
||||
if (codecSupportsDocsWithField()) {
|
||||
assertEquals(-1, dv.getOrd(0));
|
||||
assertEquals(0, dv.getValueCount());
|
||||
} else {
|
||||
|
@ -768,7 +768,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
SortedDocValues dv = ireader.leaves().get(0).reader().getSortedDocValues("dv");
|
||||
BytesRef scratch = dv.lookupOrd(dv.getOrd(0));
|
||||
assertEquals(new BytesRef("hello world 2"), scratch);
|
||||
if (defaultCodecSupportsDocsWithField()) {
|
||||
if (codecSupportsDocsWithField()) {
|
||||
assertEquals(-1, dv.getOrd(1));
|
||||
}
|
||||
scratch = dv.get(1);
|
||||
|
@ -1056,7 +1056,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
public void testRandomSortedBytes() throws IOException {
|
||||
Directory dir = newDirectory();
|
||||
IndexWriterConfig cfg = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
if (!defaultCodecSupportsDocsWithField()) {
|
||||
if (!codecSupportsDocsWithField()) {
|
||||
// if the codec doesnt support missing, we expect missing to be mapped to byte[]
|
||||
// by the impersonator, but we have to give it a chance to merge them to this
|
||||
cfg.setMergePolicy(newLogMergePolicy());
|
||||
|
@ -1085,14 +1085,14 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
doc.add(newTextField("id", "noValue", Field.Store.YES));
|
||||
w.addDocument(doc);
|
||||
}
|
||||
if (!defaultCodecSupportsDocsWithField()) {
|
||||
if (!codecSupportsDocsWithField()) {
|
||||
BytesRef bytesRef = new BytesRef();
|
||||
hash.add(bytesRef); // add empty value for the gaps
|
||||
}
|
||||
if (rarely()) {
|
||||
w.commit();
|
||||
}
|
||||
if (!defaultCodecSupportsDocsWithField()) {
|
||||
if (!codecSupportsDocsWithField()) {
|
||||
// if the codec doesnt support missing, we expect missing to be mapped to byte[]
|
||||
// by the impersonator, but we have to give it a chance to merge them to this
|
||||
w.forceMerge(1);
|
||||
|
@ -1472,7 +1472,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetOneValue() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
Directory directory = newDirectory();
|
||||
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
|
||||
|
||||
|
@ -1497,7 +1497,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetTwoFields() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
Directory directory = newDirectory();
|
||||
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
|
||||
|
||||
|
@ -1532,7 +1532,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetTwoDocumentsMerged() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
Directory directory = newDirectory();
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
IndexWriterConfig iwconfig = newIndexWriterConfig(analyzer);
|
||||
|
@ -1574,7 +1574,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetTwoValues() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
Directory directory = newDirectory();
|
||||
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
|
||||
|
||||
|
@ -1604,7 +1604,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetTwoValuesUnordered() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
Directory directory = newDirectory();
|
||||
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
|
||||
|
||||
|
@ -1634,7 +1634,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetThreeValuesTwoDocs() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
Directory directory = newDirectory();
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
IndexWriterConfig iwconfig = newIndexWriterConfig(analyzer);
|
||||
|
@ -1683,7 +1683,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetTwoDocumentsLastMissing() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
Directory directory = newDirectory();
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
IndexWriterConfig iwconfig = newIndexWriterConfig(analyzer);
|
||||
|
@ -1715,7 +1715,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetTwoDocumentsLastMissingMerge() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
Directory directory = newDirectory();
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
IndexWriterConfig iwconfig = newIndexWriterConfig(analyzer);
|
||||
|
@ -1749,7 +1749,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetTwoDocumentsFirstMissing() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
Directory directory = newDirectory();
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
IndexWriterConfig iwconfig = newIndexWriterConfig(analyzer);
|
||||
|
@ -1782,7 +1782,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetTwoDocumentsFirstMissingMerge() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
Directory directory = newDirectory();
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
IndexWriterConfig iwconfig = newIndexWriterConfig(analyzer);
|
||||
|
@ -1816,7 +1816,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetMergeAwayAllValues() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
Directory directory = newDirectory();
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
IndexWriterConfig iwconfig = newIndexWriterConfig(analyzer);
|
||||
|
@ -1845,7 +1845,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetTermsEnum() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
Directory directory = newDirectory();
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
IndexWriterConfig iwconfig = newIndexWriterConfig(analyzer);
|
||||
|
@ -2006,7 +2006,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetFixedLengthVsStoredFields() throws Exception {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
int numIterations = atLeast(1);
|
||||
for (int i = 0; i < numIterations; i++) {
|
||||
int fixedLength = TestUtil.nextInt(random(), 1, 10);
|
||||
|
@ -2015,7 +2015,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedNumericsSingleValuedVsStoredFields() throws Exception {
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", codecSupportsSortedNumeric());
|
||||
int numIterations = atLeast(1);
|
||||
for (int i = 0; i < numIterations; i++) {
|
||||
doTestSortedNumericsVsStoredFields(
|
||||
|
@ -2036,7 +2036,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedNumericsSingleValuedMissingVsStoredFields() throws Exception {
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", codecSupportsSortedNumeric());
|
||||
int numIterations = atLeast(1);
|
||||
for (int i = 0; i < numIterations; i++) {
|
||||
doTestSortedNumericsVsStoredFields(
|
||||
|
@ -2057,7 +2057,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedNumericsMultipleValuesVsStoredFields() throws Exception {
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", codecSupportsSortedNumeric());
|
||||
int numIterations = atLeast(1);
|
||||
for (int i = 0; i < numIterations; i++) {
|
||||
doTestSortedNumericsVsStoredFields(
|
||||
|
@ -2078,7 +2078,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetVariableLengthVsStoredFields() throws Exception {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
int numIterations = atLeast(1);
|
||||
for (int i = 0; i < numIterations; i++) {
|
||||
doTestSortedSetVsStoredFields(atLeast(300), 1, 10, 16);
|
||||
|
@ -2086,7 +2086,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetFixedLengthSingleValuedVsStoredFields() throws Exception {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
int numIterations = atLeast(1);
|
||||
for (int i = 0; i < numIterations; i++) {
|
||||
int fixedLength = TestUtil.nextInt(random(), 1, 10);
|
||||
|
@ -2095,7 +2095,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedSetVariableLengthSingleValuedVsStoredFields() throws Exception {
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
int numIterations = atLeast(1);
|
||||
for (int i = 0; i < numIterations; i++) {
|
||||
doTestSortedSetVsStoredFields(atLeast(300), 1, 10, 1);
|
||||
|
@ -2137,7 +2137,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testTwoNumbersOneMissing() throws IOException {
|
||||
assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField());
|
||||
assumeTrue("Codec does not support getDocsWithField", codecSupportsDocsWithField());
|
||||
Directory directory = newDirectory();
|
||||
IndexWriterConfig conf = newIndexWriterConfig(null);
|
||||
conf.setMergePolicy(newLogMergePolicy());
|
||||
|
@ -2166,7 +2166,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testTwoNumbersOneMissingWithMerging() throws IOException {
|
||||
assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField());
|
||||
assumeTrue("Codec does not support getDocsWithField", codecSupportsDocsWithField());
|
||||
Directory directory = newDirectory();
|
||||
IndexWriterConfig conf = newIndexWriterConfig(null);
|
||||
conf.setMergePolicy(newLogMergePolicy());
|
||||
|
@ -2196,7 +2196,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testThreeNumbersOneMissingWithMerging() throws IOException {
|
||||
assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField());
|
||||
assumeTrue("Codec does not support getDocsWithField", codecSupportsDocsWithField());
|
||||
Directory directory = newDirectory();
|
||||
IndexWriterConfig conf = newIndexWriterConfig(null);
|
||||
conf.setMergePolicy(newLogMergePolicy());
|
||||
|
@ -2232,7 +2232,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testTwoBytesOneMissing() throws IOException {
|
||||
assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField());
|
||||
assumeTrue("Codec does not support getDocsWithField", codecSupportsDocsWithField());
|
||||
Directory directory = newDirectory();
|
||||
IndexWriterConfig conf = newIndexWriterConfig(null);
|
||||
conf.setMergePolicy(newLogMergePolicy());
|
||||
|
@ -2263,7 +2263,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testTwoBytesOneMissingWithMerging() throws IOException {
|
||||
assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField());
|
||||
assumeTrue("Codec does not support getDocsWithField", codecSupportsDocsWithField());
|
||||
Directory directory = newDirectory();
|
||||
IndexWriterConfig conf = newIndexWriterConfig(null);
|
||||
conf.setMergePolicy(newLogMergePolicy());
|
||||
|
@ -2295,7 +2295,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testThreeBytesOneMissingWithMerging() throws IOException {
|
||||
assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField());
|
||||
assumeTrue("Codec does not support getDocsWithField", codecSupportsDocsWithField());
|
||||
Directory directory = newDirectory();
|
||||
IndexWriterConfig conf = newIndexWriterConfig(null);
|
||||
conf.setMergePolicy(newLogMergePolicy());
|
||||
|
@ -2424,9 +2424,9 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
|
||||
/** Tests dv against stored fields with threads (all types + missing) */
|
||||
public void testThreads2() throws Exception {
|
||||
assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField());
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
assumeTrue("Codec does not support getDocsWithField", codecSupportsDocsWithField());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", codecSupportsSortedNumeric());
|
||||
Directory dir = newDirectory();
|
||||
IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, conf);
|
||||
|
@ -2596,9 +2596,9 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testThreads3() throws Exception {
|
||||
assumeTrue("Codec does not support getDocsWithField", defaultCodecSupportsDocsWithField());
|
||||
assumeTrue("Codec does not support SORTED_SET", defaultCodecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
assumeTrue("Codec does not support getDocsWithField", codecSupportsDocsWithField());
|
||||
assumeTrue("Codec does not support SORTED_SET", codecSupportsSortedSet());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", codecSupportsSortedNumeric());
|
||||
Directory dir = newFSDirectory(createTempDir());
|
||||
IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, conf);
|
||||
|
@ -2700,7 +2700,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testOneSortedNumber() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", codecSupportsSortedNumeric());
|
||||
Directory directory = newDirectory();
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random(), directory);
|
||||
Document doc = new Document();
|
||||
|
@ -2721,7 +2721,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testOneSortedNumberOneMissing() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", codecSupportsSortedNumeric());
|
||||
Directory directory = newDirectory();
|
||||
IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(null));
|
||||
Document doc = new Document();
|
||||
|
@ -2750,7 +2750,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testTwoSortedNumber() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", codecSupportsSortedNumeric());
|
||||
Directory directory = newDirectory();
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random(), directory);
|
||||
Document doc = new Document();
|
||||
|
@ -2773,7 +2773,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testTwoSortedNumberOneMissing() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", codecSupportsSortedNumeric());
|
||||
Directory directory = newDirectory();
|
||||
IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(null));
|
||||
Document doc = new Document();
|
||||
|
@ -2804,7 +2804,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedNumberMerge() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", codecSupportsSortedNumeric());
|
||||
Directory directory = newDirectory();
|
||||
IndexWriterConfig iwc = new IndexWriterConfig(null);
|
||||
iwc.setMergePolicy(newLogMergePolicy());
|
||||
|
@ -2835,7 +2835,7 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
}
|
||||
|
||||
public void testSortedNumberMergeAwayAllValues() throws IOException {
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", defaultCodecSupportsSortedNumeric());
|
||||
assumeTrue("Codec does not support SORTED_NUMERIC", codecSupportsSortedNumeric());
|
||||
Directory directory = newDirectory();
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
IndexWriterConfig iwconfig = newIndexWriterConfig(analyzer);
|
||||
|
@ -2867,4 +2867,20 @@ public abstract class BaseDocValuesFormatTestCase extends BaseIndexFileFormatTes
|
|||
protected boolean codecAcceptsHugeBinaryValues(String field) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns true if the codec "supports" docsWithField
|
||||
* (other codecs return MatchAllBits, because you couldnt write missing values before) */
|
||||
protected boolean codecSupportsDocsWithField() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns true if the default codec supports SORTED_SET docvalues */
|
||||
protected boolean codecSupportsSortedSet() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns true if the default codec supports SORTED_NUMERIC docvalues */
|
||||
protected boolean codecSupportsSortedNumeric() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1673,61 +1673,6 @@ public abstract class LuceneTestCase extends Assert {
|
|||
throw new IOException("Cannot find resource: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns true if the default codec supports single valued docvalues with missing values */
|
||||
public static boolean defaultCodecSupportsMissingDocValues() {
|
||||
String name = Codec.getDefault().getName();
|
||||
if (name.equals("Lucene3x") ||
|
||||
name.equals("Lucene40") || name.equals("Appending") ||
|
||||
name.equals("Lucene41") ||
|
||||
name.equals("Lucene42")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns true if the default codec supports SORTED_SET docvalues */
|
||||
public static boolean defaultCodecSupportsSortedSet() {
|
||||
String name = Codec.getDefault().getName();
|
||||
if (name.equals("Lucene40") || name.equals("Lucene41")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns true if the default codec supports SORTED_NUMERIC docvalues */
|
||||
public static boolean defaultCodecSupportsSortedNumeric() {
|
||||
String name = Codec.getDefault().getName();
|
||||
if (name.equals("Lucene40") || name.equals("Lucene41") || name.equals("Lucene42") || name.equals("Lucene45") || name.equals("Lucene46")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns true if the codec "supports" docsWithField
|
||||
* (other codecs return MatchAllBits, because you couldnt write missing values before) */
|
||||
public static boolean defaultCodecSupportsDocsWithField() {
|
||||
String name = Codec.getDefault().getName();
|
||||
if (name.equals("Lucene40") || name.equals("Lucene41") || name.equals("Lucene42")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns true if the codec "supports" field updates. */
|
||||
public static boolean defaultCodecSupportsFieldUpdates() {
|
||||
String name = Codec.getDefault().getName();
|
||||
if (name.equals("Lucene40") || name.equals("Lucene41") || name.equals("Lucene42") || name.equals("Lucene45")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns true if the codec "supports" writing segment and commit ids. */
|
||||
public static boolean defaultCodecSupportsSegmentIds() {
|
||||
SegmentInfoFormat siFormat = Codec.getDefault().segmentInfoFormat();
|
||||
return siFormat instanceof SimpleTextSegmentInfoFormat || siFormat instanceof Lucene46SegmentInfoFormat;
|
||||
}
|
||||
|
||||
public void assertReaderEquals(String info, IndexReader leftReader, IndexReader rightReader) throws IOException {
|
||||
assertReaderStatisticsEquals(info, leftReader, rightReader);
|
||||
|
|
|
@ -125,7 +125,7 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
|
|||
SolrParams params = null;
|
||||
|
||||
final String intsort = "int" + (random().nextBoolean() ? "" : "_dv");
|
||||
final String intmissingsort = defaultCodecSupportsMissingDocValues() ? intsort : "int";
|
||||
final String intmissingsort = intsort;
|
||||
|
||||
// trivial base case: ensure cursorMark against an empty index doesn't blow up
|
||||
cursorMark = CURSOR_MARK_START;
|
||||
|
@ -633,26 +633,15 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
|
|||
* </p>
|
||||
* <ul>
|
||||
* <li><code>_version_</code> is removed</li>
|
||||
* <li>
|
||||
* <code>*_dv_last</code>, <code>*_dv_first</code> and <code>*_dv</code>
|
||||
* fields are removed if the codec doesn't support missing DocValues
|
||||
* </li>
|
||||
* </ul>
|
||||
* @see #defaultCodecSupportsMissingDocValues
|
||||
*/
|
||||
public static List<String> pruneAndDeterministicallySort(Collection<String> raw) {
|
||||
|
||||
final boolean prune_dv = ! defaultCodecSupportsMissingDocValues();
|
||||
|
||||
ArrayList<String> names = new ArrayList<>(37);
|
||||
for (String f : raw) {
|
||||
if (f.equals("_version_")) {
|
||||
continue;
|
||||
}
|
||||
if (prune_dv && (f.endsWith("_dv_last") || f.endsWith("_dv_first"))
|
||||
|| f.endsWith("_dv")) {
|
||||
continue;
|
||||
}
|
||||
names.add(f);
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ public class DistribCursorPagingTest extends AbstractFullDistribZkTestBase {
|
|||
QueryResponse rsp = null;
|
||||
|
||||
final String intsort = "int" + (random().nextBoolean() ? "" : "_dv");
|
||||
final String intmissingsort = defaultCodecSupportsMissingDocValues() ? intsort : "int";
|
||||
final String intmissingsort = intsort;
|
||||
|
||||
// trivial base case: ensure cursorMark against an empty index doesn't blow up
|
||||
cursorMark = CURSOR_MARK_START;
|
||||
|
|
Loading…
Reference in New Issue