mirror of
https://github.com/apache/lucene.git
synced 2025-03-04 15:29:28 +00:00
LUCENE-4055: make sure FI state is consistent after init/each change
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4055@1340189 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
12f88eec3f
commit
74d52d1110
@ -79,18 +79,33 @@ public final class FieldInfo {
|
|||||||
} else { // for non-indexed fields, leave defaults
|
} else { // for non-indexed fields, leave defaults
|
||||||
this.storeTermVector = false;
|
this.storeTermVector = false;
|
||||||
this.storePayloads = false;
|
this.storePayloads = false;
|
||||||
// nocommit these trip ... which is spooky... means
|
|
||||||
// the FI we are cloning was in a bad state...
|
|
||||||
//assert !storeTermVector;
|
|
||||||
//assert !storePayloads;
|
|
||||||
//assert !omitNorms;
|
|
||||||
//assert normsType == null;
|
|
||||||
this.omitNorms = false;
|
this.omitNorms = false;
|
||||||
this.indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
|
this.indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
|
||||||
this.normType = null;
|
this.normType = null;
|
||||||
}
|
}
|
||||||
|
assert checkConsistency();
|
||||||
assert indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 || !storePayloads;
|
assert indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 || !storePayloads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkConsistency() {
|
||||||
|
// nocommit more checks here
|
||||||
|
if (!indexed) {
|
||||||
|
assert !storeTermVector;
|
||||||
|
assert !storePayloads;
|
||||||
|
assert !omitNorms;
|
||||||
|
assert normType == null;
|
||||||
|
assert indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
|
||||||
|
} else {
|
||||||
|
assert omitNorms || normsType != null;
|
||||||
|
assert indexOptions != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cannot store payloads unless positions are indexed:
|
||||||
|
assert indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 || !this.storePayloads;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FieldInfo clone() {
|
public FieldInfo clone() {
|
||||||
@ -124,10 +139,12 @@ public final class FieldInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert this.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 || !this.storePayloads;
|
assert this.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 || !this.storePayloads;
|
||||||
|
assert checkConsistency();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDocValuesType(DocValues.Type type) {
|
void setDocValuesType(DocValues.Type type) {
|
||||||
docValueType = type;
|
docValueType = type;
|
||||||
|
assert checkConsistency();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return IndexOptions for the field */
|
/** @return IndexOptions for the field */
|
||||||
@ -158,16 +175,19 @@ public final class FieldInfo {
|
|||||||
|
|
||||||
void setStoreTermVectors() {
|
void setStoreTermVectors() {
|
||||||
storeTermVector = true;
|
storeTermVector = true;
|
||||||
|
assert checkConsistency();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStorePayloads() {
|
void setStorePayloads() {
|
||||||
if (indexed && indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
|
if (indexed && indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
|
||||||
storePayloads = true;
|
storePayloads = true;
|
||||||
}
|
}
|
||||||
|
assert checkConsistency();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNormValueType(Type type) {
|
void setNormValueType(Type type) {
|
||||||
normType = type;
|
normType = type;
|
||||||
|
assert checkConsistency();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,5 +224,4 @@ public final class FieldInfo {
|
|||||||
public boolean hasVectors() {
|
public boolean hasVectors() {
|
||||||
return storeTermVector;
|
return storeTermVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user