LUCENE-5689: FieldInfo.setDocValuesGen should not be public

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1596553 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2014-05-21 12:23:28 +00:00
parent 71d836b713
commit d1e607f5df
10 changed files with 19 additions and 14 deletions

View File

@ -125,8 +125,7 @@ public class SimpleTextFieldInfosReader extends FieldInfosReader {
} }
infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector, infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector,
omitNorms, storePayloads, indexOptions, docValuesType, normsType, Collections.unmodifiableMap(atts)); omitNorms, storePayloads, indexOptions, docValuesType, normsType, dvGen, Collections.unmodifiableMap(atts));
infos[i].setDocValuesGen(dvGen);
} }
SimpleTextUtil.checkFooter(input); SimpleTextUtil.checkFooter(input);

View File

@ -104,7 +104,7 @@ class Lucene40FieldInfosReader extends FieldInfosReader {
attributes.put(LEGACY_NORM_TYPE_KEY, oldNormsType.name()); attributes.put(LEGACY_NORM_TYPE_KEY, oldNormsType.name());
} }
infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector, infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector,
omitNorms, storePayloads, indexOptions, oldValuesType.mapping, oldNormsType.mapping, Collections.unmodifiableMap(attributes)); omitNorms, storePayloads, indexOptions, oldValuesType.mapping, oldNormsType.mapping, -1, Collections.unmodifiableMap(attributes));
} }
CodecUtil.checkEOF(input); CodecUtil.checkEOF(input);

View File

@ -89,7 +89,7 @@ final class Lucene42FieldInfosReader extends FieldInfosReader {
final DocValuesType normsType = getDocValuesType(input, (byte) ((val >>> 4) & 0x0F)); final DocValuesType normsType = getDocValuesType(input, (byte) ((val >>> 4) & 0x0F));
final Map<String,String> attributes = input.readStringStringMap(); final Map<String,String> attributes = input.readStringStringMap();
infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector, infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector,
omitNorms, storePayloads, indexOptions, docValuesType, normsType, Collections.unmodifiableMap(attributes)); omitNorms, storePayloads, indexOptions, docValuesType, normsType, -1, Collections.unmodifiableMap(attributes));
} }
CodecUtil.checkEOF(input); CodecUtil.checkEOF(input);

View File

@ -89,8 +89,7 @@ final class Lucene46FieldInfosReader extends FieldInfosReader {
final long dvGen = input.readLong(); final long dvGen = input.readLong();
final Map<String,String> attributes = input.readStringStringMap(); final Map<String,String> attributes = input.readStringStringMap();
infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector, infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector,
omitNorms, storePayloads, indexOptions, docValuesType, normsType, Collections.unmodifiableMap(attributes)); omitNorms, storePayloads, indexOptions, docValuesType, normsType, dvGen, Collections.unmodifiableMap(attributes));
infos[i].setDocValuesGen(dvGen);
} }
if (codecVersion >= Lucene46FieldInfosFormat.FORMAT_CHECKSUM) { if (codecVersion >= Lucene46FieldInfosFormat.FORMAT_CHECKSUM) {

View File

@ -47,7 +47,7 @@ public final class FieldInfo {
private Map<String,String> attributes; private Map<String,String> attributes;
private long dvGen = -1; // the DocValues generation of this field private long dvGen;
/** /**
* Controls how much information is stored in the postings lists. * Controls how much information is stored in the postings lists.
@ -121,7 +121,7 @@ public final class FieldInfo {
*/ */
public FieldInfo(String name, boolean indexed, int number, boolean storeTermVector, boolean omitNorms, public FieldInfo(String name, boolean indexed, int number, boolean storeTermVector, boolean omitNorms,
boolean storePayloads, IndexOptions indexOptions, DocValuesType docValues, DocValuesType normsType, boolean storePayloads, IndexOptions indexOptions, DocValuesType docValues, DocValuesType normsType,
Map<String,String> attributes) { long dvGen, Map<String,String> attributes) {
this.name = name; this.name = name;
this.indexed = indexed; this.indexed = indexed;
this.number = number; this.number = number;
@ -139,6 +139,7 @@ public final class FieldInfo {
this.indexOptions = null; this.indexOptions = null;
this.normType = null; this.normType = null;
} }
this.dvGen = dvGen;
this.attributes = attributes; this.attributes = attributes;
assert checkConsistency(); assert checkConsistency();
} }
@ -158,6 +159,10 @@ public final class FieldInfo {
// Cannot store payloads unless positions are indexed: // Cannot store payloads unless positions are indexed:
assert indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 || !this.storePayloads; assert indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 || !this.storePayloads;
} }
if (dvGen != -1) {
assert docValueType != null;
}
return true; return true;
} }
@ -221,8 +226,9 @@ public final class FieldInfo {
} }
/** Sets the docValues generation of this field. */ /** Sets the docValues generation of this field. */
public void setDocValuesGen(long dvGen) { void setDocValuesGen(long dvGen) {
this.dvGen = dvGen; this.dvGen = dvGen;
assert checkConsistency();
} }
/** /**

View File

@ -302,7 +302,7 @@ public class FieldInfos implements Iterable<FieldInfo> {
// before then we'll get the same name and number, // before then we'll get the same name and number,
// else we'll allocate a new one: // else we'll allocate a new one:
final int fieldNumber = globalFieldNumbers.addOrGet(name, preferredFieldNumber, docValues); final int fieldNumber = globalFieldNumbers.addOrGet(name, preferredFieldNumber, docValues);
fi = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector, omitNorms, storePayloads, indexOptions, docValues, normType, null); fi = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector, omitNorms, storePayloads, indexOptions, docValues, normType, -1, null);
assert !byName.containsKey(fi.name); assert !byName.containsKey(fi.name);
assert globalFieldNumbers.containsConsistent(Integer.valueOf(fi.number), fi.name, fi.getDocValuesType()); assert globalFieldNumbers.containsConsistent(Integer.valueOf(fi.number), fi.name, fi.getDocValuesType());
byName.put(fi.name, fi); byName.put(fi.name, fi);

View File

@ -448,7 +448,7 @@ public class MemoryIndex {
if (!fieldInfos.containsKey(fieldName)) { if (!fieldInfos.containsKey(fieldName)) {
fieldInfos.put(fieldName, fieldInfos.put(fieldName,
new FieldInfo(fieldName, true, fieldInfos.size(), false, false, false, this.storeOffsets ? IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS : IndexOptions.DOCS_AND_FREQS_AND_POSITIONS , null, null, null)); new FieldInfo(fieldName, true, fieldInfos.size(), false, false, false, this.storeOffsets ? IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS : IndexOptions.DOCS_AND_FREQS_AND_POSITIONS , null, null, -1, null));
} }
TermToBytesRefAttribute termAtt = stream.getAttribute(TermToBytesRefAttribute.class); TermToBytesRefAttribute termAtt = stream.getAttribute(TermToBytesRefAttribute.class);
PositionIncrementAttribute posIncrAttribute = stream.addAttribute(PositionIncrementAttribute.class); PositionIncrementAttribute posIncrAttribute = stream.addAttribute(PositionIncrementAttribute.class);

View File

@ -215,7 +215,7 @@ public class UninvertingReader extends FilterAtomicReader {
} }
} }
filteredInfos.add(new FieldInfo(fi.name, fi.isIndexed(), fi.number, fi.hasVectors(), fi.omitsNorms(), filteredInfos.add(new FieldInfo(fi.name, fi.isIndexed(), fi.number, fi.hasVectors(), fi.omitsNorms(),
fi.hasPayloads(), fi.getIndexOptions(), type, fi.getNormType(), null)); fi.hasPayloads(), fi.getIndexOptions(), type, fi.getNormType(), -1, null));
} }
fieldInfos = new FieldInfos(filteredInfos.toArray(new FieldInfo[filteredInfos.size()])); fieldInfos = new FieldInfos(filteredInfos.toArray(new FieldInfo[filteredInfos.size()]));
} }

View File

@ -357,7 +357,7 @@ public abstract class BasePostingsFormatTestCase extends BaseIndexFileFormatTest
fieldInfoArray[fieldUpto] = new FieldInfo(field, true, fieldUpto, false, false, true, fieldInfoArray[fieldUpto] = new FieldInfo(field, true, fieldUpto, false, false, true,
IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS, IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS,
null, DocValuesType.NUMERIC, null); null, DocValuesType.NUMERIC, -1, null);
fieldUpto++; fieldUpto++;
SortedMap<BytesRef,Long> postings = new TreeMap<>(); SortedMap<BytesRef,Long> postings = new TreeMap<>();
@ -680,6 +680,7 @@ public abstract class BasePostingsFormatTestCase extends BaseIndexFileFormatTest
indexOptions, indexOptions,
null, null,
DocValuesType.NUMERIC, DocValuesType.NUMERIC,
-1,
null); null);
} }

View File

@ -65,7 +65,7 @@ public class Insanity {
for (FieldInfo fi : in.getFieldInfos()) { for (FieldInfo fi : in.getFieldInfos()) {
if (fi.name.equals(insaneField)) { if (fi.name.equals(insaneField)) {
filteredInfos.add(new FieldInfo(fi.name, fi.isIndexed(), fi.number, fi.hasVectors(), fi.omitsNorms(), filteredInfos.add(new FieldInfo(fi.name, fi.isIndexed(), fi.number, fi.hasVectors(), fi.omitsNorms(),
fi.hasPayloads(), fi.getIndexOptions(), null, fi.getNormType(), null)); fi.hasPayloads(), fi.getIndexOptions(), null, fi.getNormType(), -1, null));
} else { } else {
filteredInfos.add(fi); filteredInfos.add(fi);
} }