LUCENE-9883: Turn on ecj missingEnumCaseDespiteDefault setting (#56)

This commit is contained in:
zacharymorn 2021-03-30 23:50:52 -07:00 committed by GitHub
parent 32e891c60f
commit 79fcd99f4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 227 additions and 2 deletions

View File

@ -56,7 +56,7 @@ org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=enabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled

View File

@ -278,6 +278,8 @@ Other
* LUCENE-9822: Add assertion to PFOR exception encoding, documenting the BLOCK_SIZE assumption. (Greg Miller)
* LUCENE-9883: Turn on ecj missingEnumCaseDespiteDefault setting. (Zach Chen)
======================= Lucene 8.9.0 =======================
API Changes

View File

@ -73,6 +73,7 @@ enum WordCase {
return seenUpper ? MIXED : LOWER;
case UPPER:
return !seenLower ? UPPER : TITLE;
case NEUTRAL:
default:
return seenLower ? LOWER : seenUpper ? UPPER : NEUTRAL;
}

View File

@ -54,6 +54,8 @@ enum WordContext {
return dictionary.compoundMiddle;
case COMPOUND_END:
return dictionary.compoundEnd;
case COMPOUND_RULE_END:
case SIMPLE_WORD:
default:
return Dictionary.FLAG_UNSET;
}

View File

@ -311,6 +311,7 @@ public final class JapaneseTokenizer extends Tokenizer {
extendedMode = true;
outputCompounds = !discardCompoundToken;
break;
case NORMAL:
default:
searchMode = false;
extendedMode = false;

View File

@ -365,7 +365,36 @@ public final class KoreanTokenizer extends Tokenizer {
case XSV:
spacePenalty = 3000;
break;
case IC:
case MAG:
case MAJ:
case MM:
case NA:
case NNB:
case NNBC:
case NNG:
case NNP:
case NP:
case NR:
case SC:
case SE:
case SF:
case SH:
case SL:
case SN:
case SP:
case SSC:
case SSO:
case SY:
case UNA:
case UNKNOWN:
case VA:
case VCN:
case VSV:
case VV:
case VX:
case XPN:
case XR:
default:
break;
}

View File

@ -977,6 +977,8 @@ final class Lucene70DocValuesProducer extends DocValuesProducer {
switch (status) {
case FOUND:
return Math.toIntExact(termsEnum.ord());
case NOT_FOUND:
case END:
default:
return Math.toIntExact(-1L - termsEnum.ord());
}
@ -1017,6 +1019,8 @@ final class Lucene70DocValuesProducer extends DocValuesProducer {
switch (status) {
case FOUND:
return termsEnum.ord();
case NOT_FOUND:
case END:
default:
return -1L - termsEnum.ord();
}

View File

@ -277,6 +277,11 @@ public class Lucene70SegmentInfoFormat extends SegmentInfoFormat {
}
missingValue = Float.intBitsToFloat(input.readInt());
break;
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING_VAL:
case SCORE:
default:
throw new AssertionError("unhandled sortType=" + sortType);
}

View File

@ -1113,6 +1113,8 @@ final class Lucene80DocValuesProducer extends DocValuesProducer {
switch (status) {
case FOUND:
return Math.toIntExact(termsEnum.ord());
case NOT_FOUND:
case END:
default:
return Math.toIntExact(-1L - termsEnum.ord());
}
@ -1153,6 +1155,8 @@ final class Lucene80DocValuesProducer extends DocValuesProducer {
switch (status) {
case FOUND:
return termsEnum.ord();
case NOT_FOUND:
case END:
default:
return -1L - termsEnum.ord();
}

View File

@ -129,6 +129,10 @@ public class Lucene70RWSegmentInfoFormat extends Lucene70SegmentInfoFormat {
throw new IllegalStateException("Unexpected SortedNumericSortField " + sortField);
}
break;
case DOC:
case REWRITEABLE:
case STRING_VAL:
case SCORE:
default:
throw new IllegalStateException("Unexpected sort type: " + sortField.getType());
}
@ -207,6 +211,11 @@ public class Lucene70RWSegmentInfoFormat extends Lucene70SegmentInfoFormat {
output.writeByte((byte) 1);
output.writeInt(Float.floatToIntBits(((Float) missingValue).floatValue()));
break;
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING_VAL:
case SCORE:
default:
throw new IllegalStateException("Unexpected sort type: " + sortField.getType());
}

View File

@ -52,6 +52,8 @@ public class TestIndexWriterOnOldIndex extends LuceneTestCase {
Version.LATEST.major,
SegmentInfos.readLatestCommit(tmpDir).getIndexCreatedVersionMajor());
break;
case APPEND:
case CREATE_OR_APPEND:
default:
assertEquals(
7

View File

@ -1108,6 +1108,8 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
switch (status) {
case FOUND:
return Math.toIntExact(termsEnum.ord());
case NOT_FOUND:
case END:
default:
return Math.toIntExact(-1L - termsEnum.ord());
}
@ -1148,6 +1150,8 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
switch (status) {
case FOUND:
return termsEnum.ord();
case NOT_FOUND:
case END:
default:
return -1L - termsEnum.ord();
}

View File

@ -359,6 +359,7 @@ final class LatLonPointDistanceQuery extends Query {
case CELL_OUTSIDE_QUERY:
// none of the points match, clear all documents
return Relation.CELL_INSIDE_QUERY;
case CELL_CROSSES_QUERY:
default:
return relation;
}

View File

@ -3241,6 +3241,7 @@ public final class CheckIndex implements Closeable {
checkDVIterator(fi, maxDoc, dvReader::getNumeric);
checkNumericDocValues(fi.name, dvReader.getNumeric(fi), dvReader.getNumeric(fi));
break;
case NONE:
default:
throw new AssertionError();
}

View File

@ -484,6 +484,10 @@ final class DocumentsWriterDeleteQueue implements Accountable, Closeable {
case BINARY:
bufferedUpdates.addBinaryUpdate((BinaryDocValuesUpdate) update, docIDUpto);
break;
case NONE:
case SORTED:
case SORTED_SET:
case SORTED_NUMERIC:
default:
throw new IllegalArgumentException(
update.type + " DocValues updates not supported yet!");

View File

@ -1652,6 +1652,10 @@ public class IndexWriter
case BINARY:
return new BinaryDocValuesFieldUpdates(
nextGen, k, rld.info.info.maxDoc());
case NONE:
case SORTED:
case SORTED_NUMERIC:
case SORTED_SET:
default:
throw new AssertionError("type: " + update.type + " is not supported");
}
@ -1666,6 +1670,10 @@ public class IndexWriter
docValuesFieldUpdates.add(
leafDocId, ((BinaryDocValuesUpdate) update).getValue());
break;
case NONE:
case SORTED:
case SORTED_SET:
case SORTED_NUMERIC:
default:
throw new AssertionError("type: " + update.type + " is not supported");
}
@ -1982,6 +1990,10 @@ public class IndexWriter
case BINARY:
dvUpdates[i] = new BinaryDocValuesUpdate(term, f.name(), f.binaryValue());
break;
case NONE:
case SORTED:
case SORTED_NUMERIC:
case SORTED_SET:
default:
throw new IllegalArgumentException(
"can only update NUMERIC or BINARY fields: field=" + f.name() + ", type=" + dvType);
@ -2348,6 +2360,11 @@ public class IndexWriter
case COMMIT:
spec = mergePolicy.findFullFlushMerges(trigger, segmentInfos, this);
break;
case EXPLICIT:
case FULL_FLUSH:
case MERGE_FINISHED:
case SEGMENT_FLUSH:
case CLOSING:
default:
spec = mergePolicy.findMerges(trigger, segmentInfos, this);
}
@ -4206,6 +4223,10 @@ public class IndexWriter
new BinaryDocValuesFieldUpdates(
updates.delGen, updates.field, merge.info.info.maxDoc());
break;
case NONE:
case SORTED:
case SORTED_SET:
case SORTED_NUMERIC:
default:
throw new AssertionError();
}

View File

@ -909,6 +909,7 @@ final class IndexingChain implements Accountable {
((SortedSetDocValuesWriter) fp.docValuesWriter).addValue(docID, field.binaryValue());
break;
case NONE:
default:
throw new AssertionError("unrecognized DocValues.Type: " + dvType);
}

View File

@ -67,6 +67,7 @@ public class SimpleMergedSegmentWarmer implements IndexReaderWarmer {
case SORTED_SET:
reader.getSortedSetDocValues(info.name);
break;
case NONE:
default:
assert false; // unknown dv type
}

View File

@ -135,6 +135,7 @@ public abstract class VectorValues extends DocIdSetIterator {
return squareDistance(v1, v2);
case DOT_PRODUCT_HNSW:
return dotProduct(v1, v2);
case NONE:
default:
throw new IllegalStateException("Incomparable search strategy: " + this);
}
@ -146,6 +147,7 @@ public abstract class VectorValues extends DocIdSetIterator {
case EUCLIDEAN_HNSW:
case DOT_PRODUCT_HNSW:
return true;
case NONE:
default:
return false;
}

View File

@ -212,6 +212,8 @@ public class BooleanQuery extends Query implements Iterable<BooleanClause> {
}
break;
}
case FILTER:
case MUST_NOT:
default:
{
newQuery.add(clause);
@ -454,6 +456,8 @@ public class BooleanQuery extends Query implements Iterable<BooleanClause> {
case MUST_NOT:
builder.add(clause);
break;
case MUST:
case SHOULD:
default:
// ignore
break;

View File

@ -278,6 +278,7 @@ public abstract class PointRangeQuery extends Query {
case CELL_OUTSIDE_QUERY:
// none of the points match, clear all documents
return Relation.CELL_INSIDE_QUERY;
case CELL_CROSSES_QUERY:
default:
return relation;
}

View File

@ -188,6 +188,11 @@ public class SortField {
case DOUBLE:
sf.setMissingValue(NumericUtils.sortableLongToDouble(in.readLong()));
break;
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING_VAL:
case SCORE:
default:
throw new IllegalArgumentException("Cannot deserialize sort of type " + sf.type);
}
@ -241,6 +246,11 @@ public class SortField {
case DOUBLE:
out.writeLong(NumericUtils.doubleToSortableLong((double) missingValue));
break;
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING_VAL:
case SCORE:
default:
throw new IllegalArgumentException("Cannot serialize SortField of type " + type);
}
@ -583,6 +593,11 @@ public class SortField {
(Float) missingValue,
reverse,
reader -> DocValues.getNumeric(reader, field));
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING_VAL:
case SCORE:
default:
return null;
}

View File

@ -87,6 +87,14 @@ public class SortedNumericSelector {
return NumericUtils.sortableDoubleBits(in.longValue());
}
};
case INT:
case LONG:
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING:
case STRING_VAL:
case SCORE:
default:
return view;
}

View File

@ -124,6 +124,12 @@ public class SortedNumericSortField extends SortField {
case DOUBLE:
sf.setMissingValue(NumericUtils.sortableLongToDouble(in.readLong()));
break;
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING_VAL:
case SCORE:
case STRING:
default:
throw new AssertionError();
}
@ -170,6 +176,12 @@ public class SortedNumericSortField extends SortField {
case DOUBLE:
out.writeLong(NumericUtils.doubleToSortableLong((double) missingValue));
break;
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING_VAL:
case SCORE:
case STRING:
default:
throw new AssertionError();
}
@ -291,6 +303,12 @@ public class SortedNumericSortField extends SortField {
};
}
};
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING_VAL:
case SCORE:
case STRING:
default:
throw new AssertionError();
}
@ -316,6 +334,12 @@ public class SortedNumericSortField extends SortField {
case FLOAT:
return new IndexSorter.FloatSorter(
Provider.NAME, (Float) missingValue, reverse, this::getValue);
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING_VAL:
case STRING:
case SCORE:
default:
throw new AssertionError();
}

View File

@ -344,6 +344,9 @@ public abstract class BufferedIndexInput extends IndexInput implements RandomAcc
switch (context.context) {
case MERGE:
return MERGE_BUFFER_SIZE;
case DEFAULT:
case FLUSH:
case READ:
default:
return BUFFER_SIZE;
}

View File

@ -1030,6 +1030,14 @@ public class RegExp {
case REGEXP_AUTOMATON:
set.add(s);
break;
case REGEXP_ANYCHAR:
case REGEXP_ANYSTRING:
case REGEXP_CHAR:
case REGEXP_CHAR_RANGE:
case REGEXP_EMPTY:
case REGEXP_INTERVAL:
case REGEXP_PRE_CLASS:
case REGEXP_STRING:
default:
}
}

View File

@ -199,6 +199,11 @@ public class TestDoubleValuesSource extends LuceneTestCase {
case SCORE:
mutated[i] = DoubleValuesSource.SCORES.getSortField(reverse);
break;
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING:
case STRING_VAL:
default:
mutated[i] = original[i];
}

View File

@ -164,6 +164,14 @@ public class TestLongValuesSource extends LuceneTestCase {
case LONG:
mutated[i] = LongValuesSource.fromLongField(s.getField()).getSortField(reverse);
break;
case CUSTOM:
case DOUBLE:
case FLOAT:
case DOC:
case REWRITEABLE:
case STRING:
case STRING_VAL:
case SCORE:
default:
mutated[i] = original[i];
}

View File

@ -159,6 +159,11 @@ public class TestExpressionSorts extends LuceneTestCase {
return DoubleValuesSource.fromDoubleField(field.getField());
case SCORE:
return DoubleValuesSource.SCORES;
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING:
case STRING_VAL:
default:
throw new UnsupportedOperationException();
}

View File

@ -578,6 +578,10 @@ public class TestAllGroupHeadsCollector extends LuceneTestCase {
case SORTED:
valuesField = new SortedDocValuesField(groupField, new BytesRef(value));
break;
case NONE:
case NUMERIC:
case SORTED_SET:
case SORTED_NUMERIC:
default:
fail("unhandled type");
}

View File

@ -278,6 +278,7 @@ public class MatchRegionRetriever {
// depending on the use case (OffsetsFromValues, for example).
return new OffsetsFromTokens(field, analyzer);
case NONE:
default:
return (matchesIterator, doc) -> {
throw new IOException(

View File

@ -43,6 +43,9 @@ interface GenericTermsCollector extends Collector {
return wrap(new TermsCollector.MV(mvFunction));
case Avg:
return new MV.Avg(mvFunction);
case Max:
case Min:
case Total:
default:
return new MV(mvFunction, mode);
}
@ -113,6 +116,9 @@ interface GenericTermsCollector extends Collector {
return wrap(new TermsCollector.SV(svFunction));
case Avg:
return new SV.Avg(svFunction);
case Max:
case Min:
case Total:
default:
return new SV(svFunction, mode);
}

View File

@ -75,6 +75,10 @@ abstract class TermsWithScoreCollector<DV> extends DocValuesTermsCollector<DV>
switch (scoreMode) {
case Avg:
return new MV.Avg(sortedSetDocValues(field));
case Max:
case Min:
case None:
case Total:
default:
return new MV(sortedSetDocValues(field), scoreMode);
}
@ -82,6 +86,10 @@ abstract class TermsWithScoreCollector<DV> extends DocValuesTermsCollector<DV>
switch (scoreMode) {
case Avg:
return new SV.Avg(sortedDocValues(field));
case Max:
case Min:
case None:
case Total:
default:
return new SV(sortedDocValues(field), scoreMode);
}
@ -137,6 +145,8 @@ abstract class TermsWithScoreCollector<DV> extends DocValuesTermsCollector<DV>
scoreSums[ord] = current;
}
break;
case None:
case Avg:
default:
throw new AssertionError("unexpected: " + scoreMode);
}
@ -230,6 +240,8 @@ abstract class TermsWithScoreCollector<DV> extends DocValuesTermsCollector<DV>
case Max:
scoreSums[termID] = Math.max(scoreSums[termID], scorer.score());
break;
case Avg:
case None:
default:
throw new AssertionError("unexpected: " + scoreMode);
}

View File

@ -74,6 +74,11 @@ public class ToParentBlockJoinSortField extends SortField {
case INT:
// ok
break;
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING_VAL:
case SCORE:
default:
throw new UnsupportedOperationException("Sort type " + type + " is not supported");
}
@ -118,6 +123,11 @@ public class ToParentBlockJoinSortField extends SortField {
return getLongComparator(numHits, sortPos);
case INT:
return getIntComparator(numHits, sortPos);
case CUSTOM:
case DOC:
case REWRITEABLE:
case STRING_VAL:
case SCORE:
default:
throw new UnsupportedOperationException("Sort type " + getType() + " is not supported");
}

View File

@ -1130,6 +1130,7 @@ public final class DocumentsPanelProvider implements DocumentsTabOperator {
case DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS:
sb.append("dfpo");
break;
case NONE:
default:
sb.append("----");
}
@ -1212,6 +1213,7 @@ public final class DocumentsPanelProvider implements DocumentsTabOperator {
case SORTED_SET:
sb.append("srtset");
break;
case NONE:
default:
sb.append("??????");
}

View File

@ -65,6 +65,7 @@ final class DocValuesAdapter {
return createSortedDocValues(docid, field, DocValuesType.SORTED);
case SORTED_SET:
return createSortedSetDocValues(docid, field, DocValuesType.SORTED_SET);
case NONE:
default:
return Optional.empty();
}

View File

@ -450,6 +450,7 @@ public final class SearchImpl extends LukeModel implements Search {
case SORTED_SET:
return Collections.singletonList(new SortedSetSortField(name, false));
case BINARY:
default:
return Collections.singletonList(new SortField(name, SortField.Type.DOC));
}

View File

@ -606,6 +606,7 @@ public class MemoryIndex {
}
info.binaryProducer.dvBytesValuesSet.add((BytesRef) docValuesValue);
break;
case NONE:
default:
throw new UnsupportedOperationException("unknown doc values type [" + docValuesType + "]");
}

View File

@ -63,6 +63,8 @@ public class TestDocValuesFieldSources extends LuceneTestCase {
case SORTED_NUMERIC:
f = new SortedNumericDocValuesField("dv", 0);
break;
case NONE:
case SORTED_SET:
default:
throw new AssertionError();
}
@ -90,6 +92,8 @@ public class TestDocValuesFieldSources extends LuceneTestCase {
vals[i] = (long) random().nextInt((int) PackedInts.maxValue(bitsPerValue));
f.setLongValue((Long) vals[i]);
break;
case NONE:
case SORTED_SET:
default:
throw new AssertionError();
}
@ -119,6 +123,8 @@ public class TestDocValuesFieldSources extends LuceneTestCase {
? new MultiValuedLongFieldSource("dv", Type.MIN)
: new MultiValuedLongFieldSource("dv", Type.MAX);
break;
case NONE:
case SORTED_SET:
default:
throw new AssertionError();
}
@ -153,6 +159,8 @@ public class TestDocValuesFieldSources extends LuceneTestCase {
case SORTED_NUMERIC:
assertEquals(((Number) expected).longValue(), values.longVal(i));
break;
case NONE:
case SORTED_SET:
default:
throw new AssertionError();
}

View File

@ -368,6 +368,7 @@ public class BlendedInfixSuggester extends AnalyzingInfixSuggester {
coefficient = 1. / Math.pow((position + 1.0), exponent);
break;
case CUSTOM:
default:
coefficient = 1;
}

View File

@ -1403,6 +1403,9 @@ public final class TestUtil {
case SORTED:
field2 = new SortedDocValuesField(field1.name(), field1.binaryValue());
break;
case NONE:
case SORTED_SET:
case SORTED_NUMERIC:
default:
throw new IllegalStateException("unknown Type: " + dvType);
}