LUCENE-10182: No longer check dvGen. (#350)

`dvGen` doesn't need to be checked for schema consistency since it is always
-1. Furthermore, this change changes the `assertSame` that takes an object to
make it take an enum instead, since it uses instance equality checks which are
generally incorrect for objects.
This commit is contained in:
Adrien Grand 2021-10-06 11:49:13 +02:00 committed by GitHub
parent 674b66dd16
commit feac4cd09e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 9 deletions

View File

@ -676,7 +676,7 @@ final class IndexingChain implements Accountable {
false,
s.indexOptions,
s.docValuesType,
s.dvGen,
-1,
s.attributes,
s.pointDimensionCount,
s.pointIndexDimensionCount,
@ -816,7 +816,7 @@ final class IndexingChain implements Accountable {
verifyUnIndexedFieldType(fieldName, fieldType);
}
if (fieldType.docValuesType() != DocValuesType.NONE) {
schema.setDocValues(fieldType.docValuesType(), -1);
schema.setDocValues(fieldType.docValuesType());
}
if (fieldType.pointDimensionCount() != 0) {
schema.setPoints(
@ -1321,7 +1321,6 @@ final class IndexingChain implements Accountable {
private boolean omitNorms = false;
private boolean storeTermVector = false;
private IndexOptions indexOptions = IndexOptions.NONE;
private long dvGen = -1;
private DocValuesType docValuesType = DocValuesType.NONE;
private int pointDimensionCount = 0;
private int pointIndexDimensionCount = 0;
@ -1348,7 +1347,7 @@ final class IndexingChain implements Accountable {
}
}
private void assertSame(String label, Object expected, Object given) {
private <T extends Enum<?>> void assertSame(String label, T expected, T given) {
if (expected != given) {
raiseNotSame(label, expected, given);
}
@ -1387,13 +1386,11 @@ final class IndexingChain implements Accountable {
}
}
void setDocValues(DocValuesType newDocValuesType, long newDvGen) {
void setDocValues(DocValuesType newDocValuesType) {
if (docValuesType == DocValuesType.NONE) {
this.docValuesType = newDocValuesType;
this.dvGen = newDvGen;
} else {
assertSame("doc values type", docValuesType, newDocValuesType);
assertSame("doc values generation", dvGen, newDvGen);
}
}
@ -1424,7 +1421,6 @@ final class IndexingChain implements Accountable {
omitNorms = false;
storeTermVector = false;
indexOptions = IndexOptions.NONE;
dvGen = -1;
docValuesType = DocValuesType.NONE;
pointDimensionCount = 0;
pointIndexDimensionCount = 0;
@ -1438,7 +1434,6 @@ final class IndexingChain implements Accountable {
assertSame("omit norms", fi.omitsNorms(), omitNorms);
assertSame("store term vector", fi.hasVectors(), storeTermVector);
assertSame("doc values type", fi.getDocValuesType(), docValuesType);
assertSame("doc values generation", fi.getDocValuesGen(), dvGen);
assertSame(
"vector similarity function", fi.getVectorSimilarityFunction(), vectorSimilarityFunction);
assertSame("vector dimension", fi.getVectorDimension(), vectorDimension);