Skip to content

Apache Lucene open-source search software

LUCENE-4055: clear up nocommits

Robert Muir09b10efe3fb9
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java
index 6e523545cf9..999d1b17c1c 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsReader.java
@@ -135,7 +135,7 @@ public class BlockTermsReader extends FieldsProducer {
assert numTerms >= 0;
final long termsStartPointer = in.readVLong();
final FieldInfo fieldInfo = fieldInfos.fieldInfo(field);
- final long sumTotalTermFreq = fieldInfo.indexOptions == IndexOptions.DOCS_ONLY ? -1 : in.readVLong();
+ final long sumTotalTermFreq = fieldInfo.getIndexOptions() == IndexOptions.DOCS_ONLY ? -1 : in.readVLong();
final long sumDocFreq = in.readVLong();
final int docCount = in.readVInt();
assert !fields.containsKey(fieldInfo.name);
@@ -699,13 +699,13 @@ public class BlockTermsReader extends FieldsProducer {
@Override
public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse, boolean needsOffsets) throws IOException {
- if (fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
+ if (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
// Positions were not indexed:
return null;
}
if (needsOffsets &&
- fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) < 0) {
+ fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) < 0) {
// Offsets were not indexed:
return null;
}
@@ -860,7 +860,7 @@ public class BlockTermsReader extends FieldsProducer {
// just skipN here:
state.docFreq = freqReader.readVInt();
//System.out.println(" dF=" + state.docFreq);
- if (fieldInfo.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (fieldInfo.getIndexOptions() != IndexOptions.DOCS_ONLY) {
state.totalTermFreq = state.docFreq + freqReader.readVLong();
//System.out.println(" totTF=" + state.totalTermFreq);
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsWriter.java
index 93426445581..a270ef60740 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/BlockTermsWriter.java
@@ -130,7 +130,7 @@ public class BlockTermsWriter extends FieldsConsumer {
out.writeVInt(field.fieldInfo.number);
out.writeVLong(field.numTerms);
out.writeVLong(field.termsStartPointer);
- if (field.fieldInfo.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (field.fieldInfo.getIndexOptions() != IndexOptions.DOCS_ONLY) {
out.writeVLong(field.sumTotalTermFreq);
}
out.writeVLong(field.sumDocFreq);
@@ -302,7 +302,7 @@ public class BlockTermsWriter extends FieldsConsumer {
final TermStats stats = pendingTerms[termCount].stats;
assert stats != null;
bytesWriter.writeVInt(stats.docFreq);
- if (fieldInfo.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (fieldInfo.getIndexOptions() != IndexOptions.DOCS_ONLY) {
bytesWriter.writeVLong(stats.totalTermFreq-stats.docFreq);
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java
index e6c289166e5..7b2df3788ed 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java
@@ -147,7 +147,7 @@ public class BlockTreeTermsReader extends FieldsProducer {
rootCode.length = numBytes;
final FieldInfo fieldInfo = fieldInfos.fieldInfo(field);
assert fieldInfo != null: "field=" + field;
- final long sumTotalTermFreq = fieldInfo.indexOptions == IndexOptions.DOCS_ONLY ? -1 : in.readVLong();
+ final long sumTotalTermFreq = fieldInfo.getIndexOptions() == IndexOptions.DOCS_ONLY ? -1 : in.readVLong();
final long sumDocFreq = in.readVLong();
final int docCount = in.readVInt();
final long indexStartFP = indexDivisor != -1 ? indexIn.readVLong() : 0;
@@ -732,7 +732,7 @@ public class BlockTreeTermsReader extends FieldsProducer {
// just skipN here:
termState.docFreq = statsReader.readVInt();
//if (DEBUG) System.out.println(" dF=" + state.docFreq);
- if (fieldInfo.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (fieldInfo.getIndexOptions() != IndexOptions.DOCS_ONLY) {
termState.totalTermFreq = termState.docFreq + statsReader.readVLong();
//if (DEBUG) System.out.println(" totTF=" + state.totalTermFreq);
}
@@ -897,13 +897,13 @@ public class BlockTreeTermsReader extends FieldsProducer {
@Override
public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, DocsAndPositionsEnum reuse, boolean needsOffsets) throws IOException {
- if (fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
+ if (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
// Positions were not indexed:
return null;
}
if (needsOffsets &&
- fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) < 0) {
+ fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) < 0) {
// Offsets were not indexed:
return null;
}
@@ -2129,13 +2129,13 @@ public class BlockTreeTermsReader extends FieldsProducer {
@Override
public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, DocsAndPositionsEnum reuse, boolean needsOffsets) throws IOException {
- if (fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
+ if (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
// Positions were not indexed:
return null;
}
if (needsOffsets &&
- fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) < 0) {
+ fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) < 0) {
// Offsets were not indexed:
return null;
}
@@ -2546,7 +2546,7 @@ public class BlockTreeTermsReader extends FieldsProducer {
// just skipN here:
state.docFreq = statsReader.readVInt();
//if (DEBUG) System.out.println(" dF=" + state.docFreq);
- if (fieldInfo.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (fieldInfo.getIndexOptions() != IndexOptions.DOCS_ONLY) {
state.totalTermFreq = state.docFreq + statsReader.readVLong();
//if (DEBUG) System.out.println(" totTF=" + state.totalTermFreq);
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsWriter.java
index 6433b56b3ac..0fdde4de9f4 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsWriter.java
@@ -724,7 +724,7 @@ public class BlockTreeTermsWriter extends FieldsConsumer {
// Write term stats, to separate byte[] blob:
bytesWriter2.writeVInt(term.stats.docFreq);
- if (fieldInfo.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (fieldInfo.getIndexOptions() != IndexOptions.DOCS_ONLY) {
assert term.stats.totalTermFreq >= term.stats.docFreq;
bytesWriter2.writeVLong(term.stats.totalTermFreq - term.stats.docFreq);
}
@@ -750,7 +750,7 @@ public class BlockTreeTermsWriter extends FieldsConsumer {
// Write term stats, to separate byte[] blob:
bytesWriter2.writeVInt(term.stats.docFreq);
- if (fieldInfo.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (fieldInfo.getIndexOptions() != IndexOptions.DOCS_ONLY) {
assert term.stats.totalTermFreq >= term.stats.docFreq;
bytesWriter2.writeVLong(term.stats.totalTermFreq - term.stats.docFreq);
}
@@ -930,7 +930,7 @@ public class BlockTreeTermsWriter extends FieldsConsumer {
assert rootCode != null: "field=" + field.fieldInfo.name + " numTerms=" + field.numTerms;
out.writeVInt(rootCode.length);
out.writeBytes(rootCode.bytes, rootCode.offset, rootCode.length);
- if (field.fieldInfo.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (field.fieldInfo.getIndexOptions() != IndexOptions.DOCS_ONLY) {
out.writeVLong(field.sumTotalTermFreq);
}
out.writeVLong(field.sumDocFreq);
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/PostingsConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/PostingsConsumer.java
index c8c4f8b24f2..aa884955ab1 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/PostingsConsumer.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/PostingsConsumer.java
@@ -70,7 +70,8 @@ public abstract class PostingsConsumer {
int df = 0;
long totTF = 0;
- if (mergeState.fieldInfo.indexOptions == IndexOptions.DOCS_ONLY) {
+ IndexOptions indexOptions = mergeState.fieldInfo.getIndexOptions();
+ if (indexOptions == IndexOptions.DOCS_ONLY) {
while(true) {
final int doc = postings.nextDoc();
if (doc == DocIdSetIterator.NO_MORE_DOCS) {
@@ -82,7 +83,7 @@ public abstract class PostingsConsumer {
df++;
}
totTF = -1;
- } else if (mergeState.fieldInfo.indexOptions == IndexOptions.DOCS_AND_FREQS) {
+ } else if (indexOptions == IndexOptions.DOCS_AND_FREQS) {
while(true) {
final int doc = postings.nextDoc();
if (doc == DocIdSetIterator.NO_MORE_DOCS) {
@@ -95,7 +96,7 @@ public abstract class PostingsConsumer {
df++;
totTF += freq;
}
- } else if (mergeState.fieldInfo.indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
+ } else if (indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
final DocsAndPositionsEnum postingsEnum = (DocsAndPositionsEnum) postings;
while(true) {
final int doc = postingsEnum.nextDoc();
@@ -120,7 +121,7 @@ public abstract class PostingsConsumer {
df++;
}
} else {
- assert mergeState.fieldInfo.indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
+ assert indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
final DocsAndPositionsEnum postingsEnum = (DocsAndPositionsEnum) postings;
while(true) {
final int doc = postingsEnum.nextDoc();
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/TermsConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/TermsConsumer.java
index 14d10238c59..3d887f3c813 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/TermsConsumer.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/TermsConsumer.java
@@ -81,7 +81,8 @@ public abstract class TermsConsumer {
long sumDFsinceLastAbortCheck = 0;
FixedBitSet visitedDocs = new FixedBitSet(mergeState.mergedDocCount);
- if (mergeState.fieldInfo.indexOptions == IndexOptions.DOCS_ONLY) {
+ IndexOptions indexOptions = mergeState.fieldInfo.getIndexOptions();
+ if (indexOptions == IndexOptions.DOCS_ONLY) {
if (docsEnum == null) {
docsEnum = new MappingMultiDocsEnum();
}
@@ -109,7 +110,7 @@ public abstract class TermsConsumer {
}
}
}
- } else if (mergeState.fieldInfo.indexOptions == IndexOptions.DOCS_AND_FREQS) {
+ } else if (indexOptions == IndexOptions.DOCS_AND_FREQS) {
if (docsAndFreqsEnum == null) {
docsAndFreqsEnum = new MappingMultiDocsEnum();
}
@@ -136,7 +137,7 @@ public abstract class TermsConsumer {
}
}
}
- } else if (mergeState.fieldInfo.indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
+ } else if (indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
if (postingsEnum == null) {
postingsEnum = new MappingMultiDocsAndPositionsEnum();
}
@@ -170,7 +171,7 @@ public abstract class TermsConsumer {
}
}
} else {
- assert mergeState.fieldInfo.indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
+ assert indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
if (postingsEnum == null) {
postingsEnum = new MappingMultiDocsAndPositionsEnum();
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFieldInfosReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFieldInfosReader.java
index 7fd028c1607..fb775c9d239 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFieldInfosReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFieldInfosReader.java
@@ -59,10 +59,6 @@ class Lucene3xFieldInfosReader extends FieldInfosReader {
public FieldInfos read(Directory directory, String segmentName, IOContext iocontext) throws IOException {
final String fileName = IndexFileNames.segmentFileName(segmentName, "", FIELD_INFOS_EXTENSION);
IndexInput input = directory.openInput(fileName, iocontext);
-
- boolean hasVectors = false;
- boolean hasFreq = false;
- boolean hasProx = false;
try {
final int format = input.readVInt();
@@ -104,9 +100,6 @@ class Lucene3xFieldInfosReader extends FieldInfosReader {
if (indexOptions != IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
storePayloads = false;
}
- hasVectors |= storeTermVector;
- hasProx |= isIndexed && indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
- hasFreq |= isIndexed && indexOptions != IndexOptions.DOCS_ONLY;
infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector,
omitNorms, storePayloads, indexOptions, null, isIndexed && !omitNorms? Type.FIXED_INTS_8 : null);
}
@@ -114,7 +107,7 @@ class Lucene3xFieldInfosReader extends FieldInfosReader {
if (input.getFilePointer() != input.length()) {
throw new CorruptIndexException("did not read all bytes from file \"" + fileName + "\": read " + input.getFilePointer() + " vs size " + input.length() + " (resource: " + input + ")");
}
- return new ReadOnlyFieldInfos(infos, hasFreq, hasProx, hasVectors);
+ return new ReadOnlyFieldInfos(infos);
} finally {
input.close();
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFields.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFields.java
index 621fe44f481..52cfb11388c 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFields.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xFields.java
@@ -96,10 +96,10 @@ class Lucene3xFields extends FieldsProducer {
freqStream = dir.openInput(IndexFileNames.segmentFileName(info.name, "", Lucene3xPostingsFormat.FREQ_EXTENSION), context);
boolean anyProx = false;
for (FieldInfo fi : fieldInfos) {
- if (fi.isIndexed) {
+ if (fi.isIndexed()) {
fields.put(fi.name, fi);
preTerms.put(fi.name, new PreTerms(fi));
- if (fi.indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
+ if (fi.getIndexOptions() == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
anyProx = true;
}
}
@@ -952,7 +952,7 @@ class Lucene3xFields extends FieldsProducer {
@Override
public DocsEnum docs(Bits liveDocs, DocsEnum reuse, boolean needsFreqs) throws IOException {
PreDocsEnum docsEnum;
- if (needsFreqs && fieldInfo.indexOptions == IndexOptions.DOCS_ONLY) {
+ if (needsFreqs && fieldInfo.getIndexOptions() == IndexOptions.DOCS_ONLY) {
return null;
} else if (reuse == null || !(reuse instanceof PreDocsEnum)) {
docsEnum = new PreDocsEnum();
@@ -973,7 +973,7 @@ class Lucene3xFields extends FieldsProducer {
}
PreDocsAndPositionsEnum docsPosEnum;
- if (fieldInfo.indexOptions != IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
+ if (fieldInfo.getIndexOptions() != IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
return null;
} else if (reuse == null || !(reuse instanceof PreDocsAndPositionsEnum)) {
docsPosEnum = new PreDocsAndPositionsEnum();
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/SegmentTermDocs.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/SegmentTermDocs.java
index 4eb3b69d7a2..0ba87059511 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/SegmentTermDocs.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/SegmentTermDocs.java
@@ -89,8 +89,8 @@ class SegmentTermDocs {
void seek(TermInfo ti, Term term) throws IOException {
count = 0;
FieldInfo fi = fieldInfos.fieldInfo(term.field());
- this.indexOptions = (fi != null) ? fi.indexOptions : IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
- currentFieldStoresPayloads = (fi != null) ? fi.storePayloads : false;
+ this.indexOptions = (fi != null) ? fi.getIndexOptions() : IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
+ currentFieldStoresPayloads = (fi != null) ? fi.hasPayloads() : false;
if (ti == null) {
df = 0;
} else {
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java
index 0832b13a8e9..d659ef61cda 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java
@@ -49,10 +49,6 @@ public class Lucene40FieldInfosReader extends FieldInfosReader {
public FieldInfos read(Directory directory, String segmentName, IOContext iocontext) throws IOException {
final String fileName = IndexFileNames.segmentFileName(segmentName, "", Lucene40FieldInfosWriter.FIELD_INFOS_EXTENSION);
IndexInput input = directory.openInput(fileName, iocontext);
-
- boolean hasVectors = false;
- boolean hasFreq = false;
- boolean hasProx = false;
try {
final int format = input.readVInt();
@@ -92,9 +88,6 @@ public class Lucene40FieldInfosReader extends FieldInfosReader {
if (indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
storePayloads = false;
}
- hasVectors |= storeTermVector;
- hasProx |= isIndexed && indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
- hasFreq |= isIndexed && indexOptions != IndexOptions.DOCS_ONLY;
// DV Types are packed in one byte
byte val = input.readByte();
final DocValues.Type docValuesType = getDocValuesType((byte) (val & 0x0F));
@@ -107,7 +100,7 @@ public class Lucene40FieldInfosReader extends FieldInfosReader {
throw new CorruptIndexException("did not read all bytes from file \"" + fileName + "\": read " + input.getFilePointer() + " vs size " + input.length() + " (resource: " + input + ")");
}
- return new ReadOnlyFieldInfos(infos, hasFreq, hasProx, hasVectors);
+ return new ReadOnlyFieldInfos(infos);
} finally {
input.close();
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.java
index c3383fa8713..4df940676c4 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosWriter.java
@@ -61,17 +61,18 @@ public class Lucene40FieldInfosWriter extends FieldInfosWriter {
output.writeVInt(FORMAT_CURRENT);
output.writeVInt(infos.size());
for (FieldInfo fi : infos) {
- assert fi.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 || !fi.storePayloads;
+ IndexOptions indexOptions = fi.getIndexOptions();
+ assert indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 || !fi.hasPayloads();
byte bits = 0x0;
- if (fi.isIndexed) bits |= IS_INDEXED;
- if (fi.storeTermVector) bits |= STORE_TERMVECTOR;
- if (fi.omitNorms) bits |= OMIT_NORMS;
- if (fi.storePayloads) bits |= STORE_PAYLOADS;
- if (fi.indexOptions == IndexOptions.DOCS_ONLY) {
+ if (fi.isIndexed()) bits |= IS_INDEXED;
+ if (fi.hasVectors()) bits |= STORE_TERMVECTOR;
+ if (fi.omitsNorms()) bits |= OMIT_NORMS;
+ if (fi.hasPayloads()) bits |= STORE_PAYLOADS;
+ if (indexOptions == IndexOptions.DOCS_ONLY) {
bits |= OMIT_TERM_FREQ_AND_POSITIONS;
- } else if (fi.indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) {
+ } else if (indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) {
bits |= STORE_OFFSETS_IN_POSTINGS;
- } else if (fi.indexOptions == IndexOptions.DOCS_AND_FREQS) {
+ } else if (indexOptions == IndexOptions.DOCS_AND_FREQS) {
bits |= OMIT_POSITIONS;
}
output.writeString(fi.name);
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java
index 0eb36aeff96..808e6593c4f 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsReader.java
@@ -200,7 +200,7 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
// undefined
}
- if (fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
+ if (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
if (isFirstTerm) {
termState.proxOffset = termState.bytesReader.readVLong();
} else {
@@ -212,7 +212,7 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
@Override
public DocsEnum docs(FieldInfo fieldInfo, BlockTermState termState, Bits liveDocs, DocsEnum reuse, boolean needsFreqs) throws IOException {
- if (needsFreqs && fieldInfo.indexOptions == IndexOptions.DOCS_ONLY) {
+ if (needsFreqs && fieldInfo.getIndexOptions() == IndexOptions.DOCS_ONLY) {
return null;
} else if (canReuse(reuse, liveDocs)) {
// if (DEBUG) System.out.println("SPR.docs ts=" + termState);
@@ -248,13 +248,13 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
DocsAndPositionsEnum reuse, boolean needsOffsets)
throws IOException {
- boolean hasOffsets = fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
+ boolean hasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
if (needsOffsets && !hasOffsets) {
return null; // not available
}
// TODO: refactor
- if (fieldInfo.storePayloads || hasOffsets) {
+ if (fieldInfo.hasPayloads() || hasOffsets) {
SegmentFullPositionsEnum docsEnum;
if (reuse == null || !(reuse instanceof SegmentFullPositionsEnum)) {
docsEnum = new SegmentFullPositionsEnum(freqIn, proxIn);
@@ -326,9 +326,9 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
DocsEnum reset(FieldInfo fieldInfo, StandardTermState termState) throws IOException {
- indexOmitsTF = fieldInfo.indexOptions == IndexOptions.DOCS_ONLY;
- storePayloads = fieldInfo.storePayloads;
- storeOffsets = fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
+ indexOmitsTF = fieldInfo.getIndexOptions() == IndexOptions.DOCS_ONLY;
+ storePayloads = fieldInfo.hasPayloads();
+ storeOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
freqOffset = termState.freqOffset;
skipOffset = termState.skipOffset;
@@ -701,8 +701,8 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
}
public SegmentDocsAndPositionsEnum reset(FieldInfo fieldInfo, StandardTermState termState, Bits liveDocs) throws IOException {
- assert fieldInfo.indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
- assert !fieldInfo.storePayloads;
+ assert fieldInfo.getIndexOptions() == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
+ assert !fieldInfo.hasPayloads();
this.liveDocs = liveDocs;
@@ -914,9 +914,9 @@ public class Lucene40PostingsReader extends PostingsReaderBase {
}
public SegmentFullPositionsEnum reset(FieldInfo fieldInfo, StandardTermState termState, Bits liveDocs) throws IOException {
- storeOffsets = fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
- storePayloads = fieldInfo.storePayloads;
- assert fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
+ storeOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
+ storePayloads = fieldInfo.hasPayloads();
+ assert fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
assert storePayloads || storeOffsets;
if (payload == null) {
payload = new BytesRef();
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsWriter.java
index 4fa5f2bbf4e..a63fbbf5601 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsWriter.java
@@ -164,10 +164,10 @@ public final class Lucene40PostingsWriter extends PostingsWriterBase {
}
*/
this.fieldInfo = fieldInfo;
- indexOptions = fieldInfo.indexOptions;
+ indexOptions = fieldInfo.getIndexOptions();
storeOffsets = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
- storePayloads = fieldInfo.storePayloads;
+ storePayloads = fieldInfo.hasPayloads();
//System.out.println(" set init blockFreqStart=" + freqStart);
//System.out.println(" set init blockProxStart=" + proxStart);
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java
index 8badc9ba7e3..2082e585908 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java
@@ -133,7 +133,7 @@ public class MemoryPostingsFormat extends PostingsFormat {
lastDocID = docID;
docCount++;
- if (field.indexOptions == IndexOptions.DOCS_ONLY) {
+ if (field.getIndexOptions() == IndexOptions.DOCS_ONLY) {
buffer.writeVInt(delta);
} else if (termDocFreq == 1) {
buffer.writeVInt((delta<<1) | 1);
@@ -149,7 +149,7 @@ public class MemoryPostingsFormat extends PostingsFormat {
@Override
public void addPosition(int pos, BytesRef payload, int startOffset, int endOffset) throws IOException {
- assert payload == null || field.storePayloads;
+ assert payload == null || field.hasPayloads();
//System.out.println(" addPos pos=" + pos + " payload=" + payload);
@@ -159,7 +159,7 @@ public class MemoryPostingsFormat extends PostingsFormat {
int payloadLen = 0;
- if (field.storePayloads) {
+ if (field.hasPayloads()) {
payloadLen = payload == null ? 0 : payload.length;
if (payloadLen != lastPayloadLen) {
lastPayloadLen = payloadLen;
@@ -172,7 +172,7 @@ public class MemoryPostingsFormat extends PostingsFormat {
buffer.writeVInt(delta);
}
- if (field.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0) {
+ if (field.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0) {
// don't use startOffset - lastEndOffset, because this creates lots of negative vints for synonyms,
// and the numbers aren't that much smaller anyways.
int offsetDelta = startOffset - lastOffset;
@@ -229,7 +229,7 @@ public class MemoryPostingsFormat extends PostingsFormat {
assert buffer2.getFilePointer() == 0;
buffer2.writeVInt(stats.docFreq);
- if (field.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (field.getIndexOptions() != IndexOptions.DOCS_ONLY) {
buffer2.writeVLong(stats.totalTermFreq-stats.docFreq);
}
int pos = (int) buffer2.getFilePointer();
@@ -260,7 +260,7 @@ public class MemoryPostingsFormat extends PostingsFormat {
if (termCount > 0) {
out.writeVInt(termCount);
out.writeVInt(field.number);
- if (field.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (field.getIndexOptions() != IndexOptions.DOCS_ONLY) {
out.writeVLong(sumTotalTermFreq);
}
out.writeVLong(sumDocFreq);
@@ -648,7 +648,7 @@ public class MemoryPostingsFormat extends PostingsFormat {
if (!didDecode) {
buffer.reset(current.output.bytes, 0, current.output.length);
docFreq = buffer.readVInt();
- if (field.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (field.getIndexOptions() != IndexOptions.DOCS_ONLY) {
totalTermFreq = docFreq + buffer.readVLong();
} else {
totalTermFreq = -1;
@@ -697,14 +697,14 @@ public class MemoryPostingsFormat extends PostingsFormat {
decodeMetaData();
FSTDocsEnum docsEnum;
- if (needsFreqs && field.indexOptions == IndexOptions.DOCS_ONLY) {
+ if (needsFreqs && field.getIndexOptions() == IndexOptions.DOCS_ONLY) {
return null;
} else if (reuse == null || !(reuse instanceof FSTDocsEnum)) {
- docsEnum = new FSTDocsEnum(field.indexOptions, field.storePayloads);
+ docsEnum = new FSTDocsEnum(field.getIndexOptions(), field.hasPayloads());
} else {
docsEnum = (FSTDocsEnum) reuse;
- if (!docsEnum.canReuse(field.indexOptions, field.storePayloads)) {
- docsEnum = new FSTDocsEnum(field.indexOptions, field.storePayloads);
+ if (!docsEnum.canReuse(field.getIndexOptions(), field.hasPayloads())) {
+ docsEnum = new FSTDocsEnum(field.getIndexOptions(), field.hasPayloads());
}
}
return docsEnum.reset(current.output, liveDocs, docFreq);
@@ -713,22 +713,22 @@ public class MemoryPostingsFormat extends PostingsFormat {
@Override
public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse, boolean needsOffsets) throws IOException {
- boolean hasOffsets = field.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
+ boolean hasOffsets = field.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
if (needsOffsets && !hasOffsets) {
return null; // not available
}
- if (field.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
+ if (field.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
return null;
}
decodeMetaData();
FSTDocsAndPositionsEnum docsAndPositionsEnum;
if (reuse == null || !(reuse instanceof FSTDocsAndPositionsEnum)) {
- docsAndPositionsEnum = new FSTDocsAndPositionsEnum(field.storePayloads, hasOffsets);
+ docsAndPositionsEnum = new FSTDocsAndPositionsEnum(field.hasPayloads(), hasOffsets);
} else {
docsAndPositionsEnum = (FSTDocsAndPositionsEnum) reuse;
- if (!docsAndPositionsEnum.canReuse(field.storePayloads, hasOffsets)) {
- docsAndPositionsEnum = new FSTDocsAndPositionsEnum(field.storePayloads, hasOffsets);
+ if (!docsAndPositionsEnum.canReuse(field.hasPayloads(), hasOffsets)) {
+ docsAndPositionsEnum = new FSTDocsAndPositionsEnum(field.hasPayloads(), hasOffsets);
}
}
//System.out.println("D&P reset this=" + this);
@@ -797,7 +797,7 @@ public class MemoryPostingsFormat extends PostingsFormat {
this.termCount = termCount;
final int fieldNumber = in.readVInt();
field = fieldInfos.fieldInfo(fieldNumber);
- if (field.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (field.getIndexOptions() != IndexOptions.DOCS_ONLY) {
sumTotalTermFreq = in.readVLong();
} else {
sumTotalTermFreq = -1;
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsReader.java
index 18bd58867f0..e6da9f71f7b 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsReader.java
@@ -148,7 +148,7 @@ public class PulsingPostingsReader extends PostingsReaderBase {
PulsingTermState termState = (PulsingTermState) _termState;
// if we have positions, its total TF, otherwise its computed based on docFreq.
- long count = fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 ? termState.totalTermFreq : termState.docFreq;
+ long count = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 ? termState.totalTermFreq : termState.docFreq;
//System.out.println(" count=" + count + " threshold=" + maxPositions);
if (count <= maxPositions) {
@@ -179,7 +179,7 @@ public class PulsingPostingsReader extends PostingsReaderBase {
@Override
public DocsEnum docs(FieldInfo field, BlockTermState _termState, Bits liveDocs, DocsEnum reuse, boolean needsFreqs) throws IOException {
- if (needsFreqs && field.indexOptions == IndexOptions.DOCS_ONLY) {
+ if (needsFreqs && field.getIndexOptions() == IndexOptions.DOCS_ONLY) {
return null;
}
PulsingTermState termState = (PulsingTermState) _termState;
@@ -217,9 +217,9 @@ public class PulsingPostingsReader extends PostingsReaderBase {
@Override
public DocsAndPositionsEnum docsAndPositions(FieldInfo field, BlockTermState _termState, Bits liveDocs, DocsAndPositionsEnum reuse,
boolean needsOffsets) throws IOException {
- if (field.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
+ if (field.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
return null;
- } else if (needsOffsets && field.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) < 0) {
+ } else if (needsOffsets && field.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) < 0) {
return null;
}
@@ -270,9 +270,9 @@ public class PulsingPostingsReader extends PostingsReaderBase {
private int payloadLength;
public PulsingDocsEnum(FieldInfo fieldInfo) {
- indexOptions = fieldInfo.indexOptions;
- storePayloads = fieldInfo.storePayloads;
- storeOffsets = fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
+ indexOptions = fieldInfo.getIndexOptions();
+ storePayloads = fieldInfo.hasPayloads();
+ storeOffsets = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
}
public PulsingDocsEnum reset(Bits liveDocs, PulsingTermState termState) {
@@ -296,7 +296,7 @@ public class PulsingPostingsReader extends PostingsReaderBase {
}
boolean canReuse(FieldInfo fieldInfo) {
- return indexOptions == fieldInfo.indexOptions && storePayloads == fieldInfo.storePayloads;
+ return indexOptions == fieldInfo.getIndexOptions() && storePayloads == fieldInfo.hasPayloads();
}
@Override
@@ -400,13 +400,13 @@ public class PulsingPostingsReader extends PostingsReaderBase {
private boolean payloadRetrieved;
public PulsingDocsAndPositionsEnum(FieldInfo fieldInfo) {
- indexOptions = fieldInfo.indexOptions;
- storePayloads = fieldInfo.storePayloads;
- storeOffsets = fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
+ indexOptions = fieldInfo.getIndexOptions();
+ storePayloads = fieldInfo.hasPayloads();
+ storeOffsets = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
}
boolean canReuse(FieldInfo fieldInfo) {
- return indexOptions == fieldInfo.indexOptions && storePayloads == fieldInfo.storePayloads;
+ return indexOptions == fieldInfo.getIndexOptions() && storePayloads == fieldInfo.hasPayloads();
}
public PulsingDocsAndPositionsEnum reset(Bits liveDocs, PulsingTermState termState) {
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsWriter.java
index f9f73d44047..80d92653daa 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/pulsing/PulsingPostingsWriter.java
@@ -124,9 +124,9 @@ public final class PulsingPostingsWriter extends PostingsWriterBase {
// our parent calls setField whenever the field changes
@Override
public void setField(FieldInfo fieldInfo) {
- this.indexOptions = fieldInfo.indexOptions;
+ this.indexOptions = fieldInfo.getIndexOptions();
if (DEBUG) System.out.println("PW field=" + fieldInfo.name + " indexOptions=" + indexOptions);
- storePayloads = fieldInfo.storePayloads;
+ storePayloads = fieldInfo.hasPayloads();
wrappedPostingsWriter.setField(fieldInfo);
//DEBUG = BlockTreeTermsWriter.DEBUG;
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsReader.java
index 533fd2f3b22..7ce3b5d0c97 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsReader.java
@@ -241,13 +241,13 @@ public class SepPostingsReader extends PostingsReaderBase {
//System.out.println(" docFreq=" + termState.docFreq);
termState.docIndex.read(termState.bytesReader, isFirstTerm);
//System.out.println(" docIndex=" + termState.docIndex);
- if (fieldInfo.indexOptions != IndexOptions.DOCS_ONLY) {
+ if (fieldInfo.getIndexOptions() != IndexOptions.DOCS_ONLY) {
termState.freqIndex.read(termState.bytesReader, isFirstTerm);
- if (fieldInfo.indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
+ if (fieldInfo.getIndexOptions() == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
//System.out.println(" freqIndex=" + termState.freqIndex);
termState.posIndex.read(termState.bytesReader, isFirstTerm);
//System.out.println(" posIndex=" + termState.posIndex);
- if (fieldInfo.storePayloads) {
+ if (fieldInfo.hasPayloads()) {
if (isFirstTerm) {
termState.payloadFP = termState.bytesReader.readVLong();
} else {
@@ -273,7 +273,7 @@ public class SepPostingsReader extends PostingsReaderBase {
@Override
public DocsEnum docs(FieldInfo fieldInfo, BlockTermState _termState, Bits liveDocs, DocsEnum reuse, boolean needsFreqs) throws IOException {
- if (needsFreqs && fieldInfo.indexOptions == IndexOptions.DOCS_ONLY) {
+ if (needsFreqs && fieldInfo.getIndexOptions() == IndexOptions.DOCS_ONLY) {
return null;
}
final SepTermState termState = (SepTermState) _termState;
@@ -298,7 +298,7 @@ public class SepPostingsReader extends PostingsReaderBase {
DocsAndPositionsEnum reuse, boolean needsOffsets)
throws IOException {
- if (fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
+ if (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
return null;
}
@@ -306,7 +306,7 @@ public class SepPostingsReader extends PostingsReaderBase {
return null;
}
- assert fieldInfo.indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
+ assert fieldInfo.getIndexOptions() == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
final SepTermState termState = (SepTermState) _termState;
SepDocsAndPositionsEnum postingsEnum;
if (reuse == null || !(reuse instanceof SepDocsAndPositionsEnum)) {
@@ -371,9 +371,9 @@ public class SepPostingsReader extends PostingsReaderBase {
SepDocsEnum init(FieldInfo fieldInfo, SepTermState termState, Bits liveDocs) throws IOException {
this.liveDocs = liveDocs;
- this.indexOptions = fieldInfo.indexOptions;
+ this.indexOptions = fieldInfo.getIndexOptions();
omitTF = indexOptions == IndexOptions.DOCS_ONLY;
- storePayloads = fieldInfo.storePayloads;
+ storePayloads = fieldInfo.hasPayloads();
// TODO: can't we only do this if consumer
// skipped consuming the previous docs?
@@ -536,7 +536,7 @@ public class SepPostingsReader extends PostingsReaderBase {
SepDocsAndPositionsEnum init(FieldInfo fieldInfo, SepTermState termState, Bits liveDocs) throws IOException {
this.liveDocs = liveDocs;
- storePayloads = fieldInfo.storePayloads;
+ storePayloads = fieldInfo.hasPayloads();
//System.out.println("Sep D&P init");
// TODO: can't we only do this if consumer
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsWriter.java
index 62e9a2f7cc0..4a20c10dd5d 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/sep/SepPostingsWriter.java
@@ -187,12 +187,12 @@ public final class SepPostingsWriter extends PostingsWriterBase {
@Override
public void setField(FieldInfo fieldInfo) {
this.fieldInfo = fieldInfo;
- this.indexOptions = fieldInfo.indexOptions;
+ this.indexOptions = fieldInfo.getIndexOptions();
if (indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0) {
throw new UnsupportedOperationException("this codec cannot index offsets");
}
skipListWriter.setIndexOptions(indexOptions);
- storePayloads = indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS && fieldInfo.storePayloads;
+ storePayloads = indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS && fieldInfo.hasPayloads();
}
/** Adds a new doc in this term. If this returns null
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldInfosReader.java b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldInfosReader.java
index cad3c111921..838c8859329 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldInfosReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldInfosReader.java
@@ -52,10 +52,6 @@ public class SimpleTextFieldInfosReader extends FieldInfosReader {
IndexInput input = directory.openInput(fileName, iocontext);
BytesRef scratch = new BytesRef();
- boolean hasVectors = false;
- boolean hasFreq = false;
- boolean hasProx = false;
-
try {
SimpleTextUtil.readLine(input, scratch);
@@ -103,11 +99,7 @@ public class SimpleTextFieldInfosReader extends FieldInfosReader {
SimpleTextUtil.readLine(input, scratch);
assert StringHelper.startsWith(scratch, INDEXOPTIONS);
IndexOptions indexOptions = IndexOptions.valueOf(readString(INDEXOPTIONS.length, scratch));
-
- hasVectors |= storeTermVector;
- hasProx |= isIndexed && indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
- hasFreq |= isIndexed && indexOptions != IndexOptions.DOCS_ONLY;
-
+
infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector,
omitNorms, storePayloads, indexOptions, docValuesType, normsType);
}
@@ -116,7 +108,7 @@ public class SimpleTextFieldInfosReader extends FieldInfosReader {
throw new CorruptIndexException("did not read all bytes from file \"" + fileName + "\": read " + input.getFilePointer() + " vs size " + input.length() + " (resource: " + input + ")");
}
- return new ReadOnlyFieldInfos(infos, hasFreq, hasProx, hasVectors);
+ return new ReadOnlyFieldInfos(infos);
} finally {
input.close();
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldInfosWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldInfosWriter.java
index b731031c53c..ad83e7c7db4 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldInfosWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldInfosWriter.java
@@ -64,7 +64,7 @@ public class SimpleTextFieldInfosWriter extends FieldInfosWriter {
SimpleTextUtil.writeNewline(out);
for (FieldInfo fi : infos) {
- assert fi.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 || !fi.storePayloads;
+ assert fi.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0 || !fi.hasPayloads();
SimpleTextUtil.write(out, NAME);
SimpleTextUtil.write(out, fi.name, scratch);
@@ -75,19 +75,19 @@ public class SimpleTextFieldInfosWriter extends FieldInfosWriter {
SimpleTextUtil.writeNewline(out);
SimpleTextUtil.write(out, ISINDEXED);
- SimpleTextUtil.write(out, Boolean.toString(fi.isIndexed), scratch);
+ SimpleTextUtil.write(out, Boolean.toString(fi.isIndexed()), scratch);
SimpleTextUtil.writeNewline(out);
SimpleTextUtil.write(out, STORETV);
- SimpleTextUtil.write(out, Boolean.toString(fi.storeTermVector), scratch);
+ SimpleTextUtil.write(out, Boolean.toString(fi.hasVectors()), scratch);
SimpleTextUtil.writeNewline(out);
SimpleTextUtil.write(out, PAYLOADS);
- SimpleTextUtil.write(out, Boolean.toString(fi.storePayloads), scratch);
+ SimpleTextUtil.write(out, Boolean.toString(fi.hasPayloads()), scratch);
SimpleTextUtil.writeNewline(out);
SimpleTextUtil.write(out, NORMS);
- SimpleTextUtil.write(out, Boolean.toString(!fi.omitNorms), scratch);
+ SimpleTextUtil.write(out, Boolean.toString(!fi.omitsNorms()), scratch);
SimpleTextUtil.writeNewline(out);
SimpleTextUtil.write(out, NORMS_TYPE);
@@ -99,7 +99,7 @@ public class SimpleTextFieldInfosWriter extends FieldInfosWriter {
SimpleTextUtil.writeNewline(out);
SimpleTextUtil.write(out, INDEXOPTIONS);
- SimpleTextUtil.write(out, fi.indexOptions.toString(), scratch);
+ SimpleTextUtil.write(out, fi.getIndexOptions().toString(), scratch);
SimpleTextUtil.writeNewline(out);
}
} finally {
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java
index c3b252df204..e50ceeada16 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java
@@ -514,7 +514,7 @@ class SimpleTextFieldsReader extends FieldsProducer {
public SimpleTextTerms(String field, long termsStart) throws IOException {
this.termsStart = termsStart;
- indexOptions = fieldInfos.fieldInfo(field).indexOptions;
+ indexOptions = fieldInfos.fieldInfo(field).getIndexOptions();
loadTerms();
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsWriter.java
index 0a53da00701..cab11954b47 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsWriter.java
@@ -107,7 +107,7 @@ class SimpleTextFieldsWriter extends FieldsConsumer {
private int lastEndOffset = -1;
public SimpleTextPostingsWriter(FieldInfo field) {
- this.indexOptions = field.indexOptions;
+ this.indexOptions = field.getIndexOptions();
writePositions = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
writeOffsets = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
//System.out.println("writeOffsets=" + writeOffsets);
diff --git a/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java b/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java
index 94376928cf6..bd2ede879a8 100644
--- a/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java
+++ b/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java
@@ -63,11 +63,10 @@ public class DocumentStoredFieldVisitor extends StoredFieldVisitor {
@Override
public void stringField(FieldInfo fieldInfo, String value) throws IOException {
final FieldType ft = new FieldType(TextField.TYPE_STORED);
- ft.setStoreTermVectors(fieldInfo.storeTermVector);
- ft.setStoreTermVectors(fieldInfo.storeTermVector);
- ft.setIndexed(fieldInfo.isIndexed);
- ft.setOmitNorms(fieldInfo.omitNorms);
- ft.setIndexOptions(fieldInfo.indexOptions);
+ ft.setStoreTermVectors(fieldInfo.hasVectors());
+ ft.setIndexed(fieldInfo.isIndexed());
+ ft.setOmitNorms(fieldInfo.omitsNorms());
+ ft.setIndexOptions(fieldInfo.getIndexOptions());
doc.add(new Field(fieldInfo.name, value, ft));
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java b/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java
index 413e2ede1b0..108afc724f4 100644
--- a/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java
+++ b/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java
@@ -194,9 +194,7 @@ public abstract class AtomicReader extends IndexReader {
/**
* Get the {@link FieldInfos} describing all fields in
- * this reader. NOTE: do not make any changes to the
- * returned FieldInfos!
- *
+ * this reader.
* @lucene.experimental
*/
public abstract FieldInfos getFieldInfos();
diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
index 6d5d69bd8bc..2d354421da0 100644
--- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
+++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
@@ -741,7 +741,7 @@ public class CheckIndex {
if (fi == null) {
throw new RuntimeException("fieldsEnum inconsistent with fieldInfos, no fieldInfos for: " + field);
}
- if (!fi.isIndexed) {
+ if (!fi.isIndexed()) {
throw new RuntimeException("fieldsEnum inconsistent with fieldInfos, isIndexed == false for: " + field);
}
@@ -1406,7 +1406,7 @@ public class CheckIndex {
// Make sure FieldInfo thinks this field is vector'd:
final FieldInfo fieldInfo = fieldInfos.fieldInfo(field);
- if (!fieldInfo.storeTermVector) {
+ if (!fieldInfo.hasVectors()) {
throw new RuntimeException("docID=" + j + " has term vectors for field=" + field + " but FieldInfo has storeTermVector=false");
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java
index 2e4618b8a6d..b94e2fbf175 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java
@@ -31,16 +31,16 @@ public final class FieldInfo {
public final String name;
public final int number;
- public boolean isIndexed;
+ private boolean indexed;
private DocValues.Type docValueType;
// True if any document indexed term vectors
- public boolean storeTermVector;
+ private boolean storeTermVector;
private DocValues.Type normType;
- public boolean omitNorms; // omit norms associated with indexed fields
- public IndexOptions indexOptions;
- public boolean storePayloads; // whether this field stores payloads together with term positions
+ private boolean omitNorms; // omit norms associated with indexed fields
+ private IndexOptions indexOptions;
+ private boolean storePayloads; // whether this field stores payloads together with term positions
/**
* Controls how much information is stored in the postings lists.
@@ -64,13 +64,13 @@ public final class FieldInfo {
/**
* @lucene.experimental
*/
- public FieldInfo(String name, boolean isIndexed, int number, boolean storeTermVector,
+ public FieldInfo(String name, boolean indexed, int number, boolean storeTermVector,
boolean omitNorms, boolean storePayloads, IndexOptions indexOptions, DocValues.Type docValues, DocValues.Type normsType) {
this.name = name;
- this.isIndexed = isIndexed;
+ this.indexed = indexed;
this.number = number;
this.docValueType = docValues;
- if (isIndexed) {
+ if (indexed) {
this.storeTermVector = storeTermVector;
this.storePayloads = storePayloads;
this.omitNorms = omitNorms;
@@ -88,17 +88,17 @@ public final class FieldInfo {
@Override
public FieldInfo clone() {
- return new FieldInfo(name, isIndexed, number, storeTermVector,
+ return new FieldInfo(name, indexed, number, storeTermVector,
omitNorms, storePayloads, indexOptions, docValueType, normType);
}
// should only be called by FieldInfos#addOrUpdate
- void update(boolean isIndexed, boolean storeTermVector, boolean omitNorms, boolean storePayloads, IndexOptions indexOptions) {
+ void update(boolean indexed, boolean storeTermVector, boolean omitNorms, boolean storePayloads, IndexOptions indexOptions) {
- if (this.isIndexed != isIndexed) {
- this.isIndexed = true; // once indexed, always index
+ if (this.indexed != indexed) {
+ this.indexed = true; // once indexed, always index
}
- if (isIndexed) { // if updated field data is not for indexing, leave the updates out
+ if (indexed) { // if updated field data is not for indexing, leave the updates out
if (this.storeTermVector != storeTermVector) {
this.storeTermVector = true; // once vector, always vector
}
@@ -128,6 +128,11 @@ public final class FieldInfo {
}
}
+ /** @return IndexOptions for the field */
+ public IndexOptions getIndexOptions() {
+ return indexOptions;
+ }
+
/**
* @return true if this field has any docValues.
*/
@@ -149,11 +154,15 @@ public final class FieldInfo {
return normType;
}
- public void setStoreTermVectors() {
+ void setStoreTermVectors() {
storeTermVector = true;
}
+
+ void setStorePayloads() {
+ storePayloads = true;
+ }
- public void setNormValueType(Type type, boolean force) {
+ void setNormValueType(Type type, boolean force) {
if (normType == null || force) {
normType = type;
} else if (type != normType) {
@@ -164,7 +173,7 @@ public final class FieldInfo {
/**
* @return true if norms are explicitly omitted for this field
*/
- public boolean omitNorms() {
+ public boolean omitsNorms() {
return omitNorms;
}
@@ -172,7 +181,28 @@ public final class FieldInfo {
* @return true if this field actually has any norms.
*/
public boolean hasNorms() {
- return isIndexed && !omitNorms && normType != null;
+ return indexed && !omitNorms && normType != null;
+ }
+
+ /**
+ * @return true if this field is indexed.
+ */
+ public boolean isIndexed() {
+ return indexed;
+ }
+
+ /**
+ * @return true if any payloads exist for this field.
+ */
+ public boolean hasPayloads() {
+ return storePayloads;
+ }
+
+ /**
+ * @return true if any term vectors exist for this field.
+ */
+ public boolean hasVectors() {
+ return storeTermVector;
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
index 4a07857ad2e..900aef0c850 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
@@ -19,6 +19,8 @@ package org.apache.lucene.index;
import java.util.Iterator;
+import org.apache.lucene.index.FieldInfo.IndexOptions;
+
/**
* Collection of {@link FieldInfo}s (accessible by number or by name).
* @lucene.experimental
@@ -49,28 +51,58 @@ public abstract class FieldInfos implements Cloneable,Iterable<FieldInfo> {
public abstract int size();
/** Returns true if any fields have positions */
- // nocommit
- public abstract boolean hasProx();
+ public boolean hasProx() {
+ for (FieldInfo fi : this) {
+ if (fi.isIndexed() && fi.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
+ return true;
+ }
+ }
+ return false;
+ }
/** Returns true if any fields have freqs */
- // nocommit
- public abstract boolean hasFreq();
+ public boolean hasFreq() {
+ for (FieldInfo fi : this) {
+ if (fi.isIndexed() && fi.getIndexOptions() != IndexOptions.DOCS_ONLY) {
+ return true;
+ }
+ }
+ return false;
+ }
/**
* @return true if at least one field has any vectors
*/
- // nocommit
- public abstract boolean hasVectors();
+ public boolean hasVectors() {
+ for (FieldInfo fi : this) {
+ if (fi.hasVectors()) {
+ return true;
+ }
+ }
+ return false;
+ }
/**
* @return true if at least one field has any norms
*/
- // nocommit
- public abstract boolean hasNorms();
+ public boolean hasNorms() {
+ for (FieldInfo fi : this) {
+ if (fi.hasNorms()) {
+ return true;
+ }
+ }
+ return false;
+ }
/**
* @return true if at least one field has docValues
*/
- // nocommit
- public abstract boolean hasDocValues();
+ public boolean hasDocValues() {
+ for (FieldInfo fi : this) {
+ if (fi.hasDocValues()) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriter.java b/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriter.java
index f7c3a2b2863..847ab574d88 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriter.java
@@ -83,8 +83,10 @@ final class FreqProxTermsWriter extends TermsHashConsumer {
// Aggregate the storePayload as seen by the same
// field across multiple threads
- if (fieldInfo.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
- fieldInfo.storePayloads |= fieldWriter.hasPayloads;
+ if (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
+ if (fieldWriter.hasPayloads) {
+ fieldInfo.setStorePayloads();
+ }
}
// If this field has postings then add them to the
diff --git a/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java b/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java
index 25aa837a8cd..efe237d0207 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java
@@ -55,7 +55,7 @@ final class FreqProxTermsWriterPerField extends TermsHashConsumerPerField implem
this.fieldInfo = fieldInfo;
docState = termsHashPerField.docState;
fieldState = termsHashPerField.fieldState;
- setIndexOptions(fieldInfo.indexOptions);
+ setIndexOptions(fieldInfo.getIndexOptions());
}
@Override
@@ -83,7 +83,7 @@ final class FreqProxTermsWriterPerField extends TermsHashConsumerPerField implem
void reset() {
// Record, up front, whether our in-RAM format will be
// with or without term freqs:
- setIndexOptions(fieldInfo.indexOptions);
+ setIndexOptions(fieldInfo.getIndexOptions());
payloadAttribute = null;
}
@@ -330,7 +330,7 @@ final class FreqProxTermsWriterPerField extends TermsHashConsumerPerField implem
// according to this.indexOptions, but then write the
// new segment to the directory according to
// currentFieldIndexOptions:
- final IndexOptions currentFieldIndexOptions = fieldInfo.indexOptions;
+ final IndexOptions currentFieldIndexOptions = fieldInfo.getIndexOptions();
final boolean writeTermFreq = currentFieldIndexOptions.compareTo(IndexOptions.DOCS_AND_FREQS) >= 0;
final boolean writePositions = currentFieldIndexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
diff --git a/lucene/core/src/java/org/apache/lucene/index/MergeState.java b/lucene/core/src/java/org/apache/lucene/index/MergeState.java
index b0839f54299..b42661b397b 100644
--- a/lucene/core/src/java/org/apache/lucene/index/MergeState.java
+++ b/lucene/core/src/java/org/apache/lucene/index/MergeState.java
@@ -40,8 +40,7 @@ public class MergeState {
}
}
- // nocommit...
- public MutableFieldInfos fieldInfos;
+ public FieldInfos fieldInfos;
public List<IndexReaderAndLiveDocs> readers; // Readers & liveDocs being merged
public int[][] docMaps; // Maps docIDs around deletions
public int[] docBase; // New docID base per reader
diff --git a/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java b/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
index 56b95ab3023..718f033d579 100644
--- a/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
+++ b/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
@@ -51,7 +51,7 @@ public class MultiDocValues extends DocValues {
// for norms we drop all norms if one leaf reader has no norms and the field is present
FieldInfos fieldInfos = reader.getFieldInfos();
FieldInfo fieldInfo = fieldInfos.fieldInfo(field);
- return fieldInfo != null && fieldInfo.omitNorms;
+ return fieldInfo != null && fieldInfo.omitsNorms();
}
};
diff --git a/lucene/core/src/java/org/apache/lucene/index/MultiFields.java b/lucene/core/src/java/org/apache/lucene/index/MultiFields.java
index 7ad496ddba8..93d4fe4f2fc 100644
--- a/lucene/core/src/java/org/apache/lucene/index/MultiFields.java
+++ b/lucene/core/src/java/org/apache/lucene/index/MultiFields.java
@@ -248,18 +248,17 @@ public final class MultiFields extends Fields {
public static FieldInfos getMergedFieldInfos(IndexReader reader) {
final List<AtomicReader> subReaders = new ArrayList<AtomicReader>();
ReaderUtil.gatherSubReaders(subReaders, reader);
- // nocommit: this should be read-only
final MutableFieldInfos fieldInfos = new MutableFieldInfos();
for(AtomicReader subReader : subReaders) {
fieldInfos.add(subReader.getFieldInfos());
}
- return fieldInfos;
+ return fieldInfos.asReadOnly();
}
public static Collection<String> getIndexedFields(IndexReader reader) {
final Collection<String> fields = new HashSet<String>();
for(FieldInfo fieldInfo : getMergedFieldInfos(reader)) {
- if (fieldInfo.isIndexed) {
+ if (fieldInfo.isIndexed()) {
fields.add(fieldInfo.name);
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/MutableFieldInfos.java b/lucene/core/src/java/org/apache/lucene/index/MutableFieldInfos.java
index 1cf0dd847bc..164e0aa16c9 100644
--- a/lucene/core/src/java/org/apache/lucene/index/MutableFieldInfos.java
+++ b/lucene/core/src/java/org/apache/lucene/index/MutableFieldInfos.java
@@ -26,8 +26,7 @@ import java.util.TreeMap;
import org.apache.lucene.index.FieldInfo.IndexOptions;
-// nocommit: only public temporarily for FieldsConsumer (until we fix SegmentMerger)
-public final class MutableFieldInfos extends FieldInfos {
+final class MutableFieldInfos extends FieldInfos {
static final class FieldNumberBiMap {
private final Map<Integer,String> numberToName;
@@ -148,26 +147,6 @@ public final class MutableFieldInfos extends FieldInfos {
}
return fis;
}
-
- /** Returns true if any fields have positions */
- public boolean hasProx() {
- for (FieldInfo fi : this) {
- if (fi.isIndexed && fi.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
- return true;
- }
- }
- return false;
- }
-
- /** Returns true if any fields have freqs */
- public boolean hasFreq() {
- for (FieldInfo fi : this) {
- if (fi.isIndexed && fi.indexOptions != IndexOptions.DOCS_ONLY) {
- return true;
- }
- }
- return false;
- }
/**
* Assumes the fields are not storing term vectors.
@@ -280,9 +259,9 @@ public final class MutableFieldInfos extends FieldInfos {
synchronized public FieldInfo add(FieldInfo fi) {
// IMPORTANT - reuse the field number if possible for consistent field numbers across segments
- return addOrUpdateInternal(fi.name, fi.number, fi.isIndexed, fi.storeTermVector,
- fi.omitNorms, fi.storePayloads,
- fi.indexOptions, fi.getDocValuesType(), fi.getNormType());
+ return addOrUpdateInternal(fi.name, fi.number, fi.isIndexed(), fi.hasVectors(),
+ fi.omitsNorms(), fi.hasPayloads(),
+ fi.getIndexOptions(), fi.getDocValuesType(), fi.getNormType());
}
/*
@@ -300,6 +279,7 @@ public final class MutableFieldInfos extends FieldInfos {
return fi;
}
+ @Override
public FieldInfo fieldInfo(String fieldName) {
return byName.get(fieldName);
}
@@ -309,11 +289,13 @@ public final class MutableFieldInfos extends FieldInfos {
* @param fieldNumber
* @return the FieldInfo object or null when the given fieldNumber
* doesn't exist.
- */
+ */
+ @Override
public FieldInfo fieldInfo(int fieldNumber) {
return (fieldNumber >= 0) ? byNumber.get(fieldNumber) : null;
}
+ @Override
public Iterator<FieldInfo> iterator() {
return byNumber.values().iterator();
}
@@ -321,35 +303,12 @@ public final class MutableFieldInfos extends FieldInfos {
/**
* @return number of fields
*/
+ @Override
public int size() {
assert byNumber.size() == byName.size();
return byNumber.size();
}
- /**
- * @return true if at least one field has any vectors
- */
- public boolean hasVectors() {
- for (FieldInfo fi : this) {
- if (fi.storeTermVector) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @return true if at least one field has any norms
- */
- public boolean hasNorms() {
- for (FieldInfo fi : this) {
- if (fi.hasNorms()) {
- return true;
- }
- }
- return false;
- }
-
synchronized final long getVersion() {
return version;
}
@@ -358,29 +317,10 @@ public final class MutableFieldInfos extends FieldInfos {
final ReadOnlyFieldInfos asReadOnly() {
FieldInfo infos[] = new FieldInfo[size()];
int upto = 0;
- boolean hasVectors = false;
- boolean hasProx = false;
- boolean hasFreq = false;
for (FieldInfo info : this) {
infos[upto++] = info.clone();
- hasVectors |= info.storeTermVector;
- hasProx |= info.isIndexed && info.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
- hasFreq |= info.isIndexed && info.indexOptions != IndexOptions.DOCS_ONLY;
}
- return new ReadOnlyFieldInfos(infos, hasFreq, hasProx, hasVectors);
- }
-
- /**
- * @return true if at least one field has docValues
- */
- public boolean hasDocValues() {
- for (FieldInfo fi : this) {
- if (fi.hasDocValues()) {
- return true;
- }
- }
-
- return false;
+ return new ReadOnlyFieldInfos(infos);
}
/**
diff --git a/lucene/core/src/java/org/apache/lucene/index/NormsConsumer.java b/lucene/core/src/java/org/apache/lucene/index/NormsConsumer.java
index faf7c624023..ddbb8f00b42 100644
--- a/lucene/core/src/java/org/apache/lucene/index/NormsConsumer.java
+++ b/lucene/core/src/java/org/apache/lucene/index/NormsConsumer.java
@@ -64,12 +64,12 @@ final class NormsConsumer extends InvertedDocEndConsumer {
final NormsConsumerPerField toWrite = (NormsConsumerPerField) fieldsToFlush.get(fi);
// we must check the final value of omitNorms for the fieldinfo, it could have
// changed for this field since the first time we added it.
- if (!fi.omitNorms) {
+ if (!fi.omitsNorms()) {
if (toWrite != null && toWrite.initialized()) {
anythingFlushed = true;
final Type type = toWrite.flush(state.numDocs);
assert fi.getNormType() == type;
- } else if (fi.isIndexed) {
+ } else if (fi.isIndexed()) {
anythingFlushed = true;
assert fi.getNormType() == null;
fi.setNormValueType(null, false);
diff --git a/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java b/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java
index 366820e5f71..747748ab62f 100644
--- a/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java
+++ b/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java
@@ -47,7 +47,7 @@ final class NormsConsumerPerField extends InvertedDocEndConsumerPerField impleme
@Override
void finish() throws IOException {
- if (fieldInfo.isIndexed && !fieldInfo.omitNorms) {
+ if (fieldInfo.isIndexed() && !fieldInfo.omitsNorms()) {
similarity.computeNorm(fieldState, norm);
if (norm.type() != null) {
diff --git a/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java b/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java
index 82d06f16e95..e4ebdbd6aaa 100644
--- a/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java
+++ b/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java
@@ -48,8 +48,7 @@ import org.apache.lucene.util.Bits;
* undefined behavior</em>.
*/
public final class ParallelAtomicReader extends AtomicReader {
- // nocommit: make this read-only.
- private final MutableFieldInfos fieldInfos = new MutableFieldInfos();
+ private final FieldInfos fieldInfos;
private final ParallelFields fields = new ParallelFields();
private final AtomicReader[] parallelReaders, storedFieldsReaders;
private final Set<AtomicReader> completeReaderSet =
@@ -100,20 +99,23 @@ public final class ParallelAtomicReader extends AtomicReader {
}
}
+ // TODO: make this read-only in a cleaner way?
+ MutableFieldInfos builder = new MutableFieldInfos();
// build FieldInfos and fieldToReader map:
for (final AtomicReader reader : this.parallelReaders) {
final FieldInfos readerFieldInfos = reader.getFieldInfos();
for (FieldInfo fieldInfo : readerFieldInfos) {
// NOTE: first reader having a given field "wins":
if (!fieldToReader.containsKey(fieldInfo.name)) {
- fieldInfos.add(fieldInfo);
+ builder.add(fieldInfo);
fieldToReader.put(fieldInfo.name, reader);
- if (fieldInfo.storeTermVector) {
+ if (fieldInfo.hasVectors()) {
tvFieldToReader.put(fieldInfo.name, reader);
}
}
}
}
+ fieldInfos = builder.asReadOnly();
// build Fields instance
for (final AtomicReader reader : this.parallelReaders) {
diff --git a/lucene/core/src/java/org/apache/lucene/index/ReadOnlyFieldInfos.java b/lucene/core/src/java/org/apache/lucene/index/ReadOnlyFieldInfos.java
index a8b2d9ff751..ba291793483 100644
--- a/lucene/core/src/java/org/apache/lucene/index/ReadOnlyFieldInfos.java
+++ b/lucene/core/src/java/org/apache/lucene/index/ReadOnlyFieldInfos.java
@@ -1,10 +1,14 @@
package org.apache.lucene.index;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.SortedMap;
import java.util.TreeMap;
+import org.apache.lucene.index.FieldInfo.IndexOptions;
+
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -33,12 +37,12 @@ public final class ReadOnlyFieldInfos extends FieldInfos {
private final SortedMap<Integer,FieldInfo> byNumber = new TreeMap<Integer,FieldInfo>();
private final HashMap<String,FieldInfo> byName = new HashMap<String,FieldInfo>();
+ private final Collection<FieldInfo> values; // for an unmodifiable iterator
- public ReadOnlyFieldInfos(FieldInfo[] infos, boolean hasFreq, boolean hasProx, boolean hasVectors) {
- this.hasFreq = hasFreq;
- this.hasProx = hasProx;
- this.hasVectors = hasVectors;
-
+ public ReadOnlyFieldInfos(FieldInfo[] infos) {
+ boolean hasVectors = false;
+ boolean hasProx = false;
+ boolean hasFreq = false;
boolean hasNorms = false;
boolean hasDocValues = false;
@@ -48,41 +52,55 @@ public final class ReadOnlyFieldInfos extends FieldInfos {
assert !byName.containsKey(info.name);
byName.put(info.name, info);
+ hasVectors |= info.hasVectors();
+ hasProx |= info.isIndexed() && info.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
+ hasFreq |= info.isIndexed() && info.getIndexOptions() != IndexOptions.DOCS_ONLY;
hasNorms |= info.hasNorms();
hasDocValues |= info.hasDocValues();
}
+ this.hasVectors = hasVectors;
+ this.hasProx = hasProx;
+ this.hasFreq = hasFreq;
this.hasNorms = hasNorms;
this.hasDocValues = hasDocValues;
+ this.values = Collections.unmodifiableCollection(byNumber.values());
}
+ @Override
public boolean hasFreq() {
return hasFreq;
}
+ @Override
public boolean hasProx() {
return hasProx;
}
+ @Override
public boolean hasVectors() {
return hasVectors;
}
+ @Override
public boolean hasNorms() {
return hasNorms;
}
+ @Override
public boolean hasDocValues() {
return hasDocValues;
}
+ @Override
public int size() {
assert byNumber.size() == byName.size();
return byNumber.size();
}
+ @Override
public Iterator<FieldInfo> iterator() {
- return byNumber.values().iterator();
+ return values.iterator();
}
@Override
@@ -103,7 +121,7 @@ public final class ReadOnlyFieldInfos extends FieldInfos {
for (FieldInfo info : this) {
infos[upto++] = info.clone();
}
- return new ReadOnlyFieldInfos(infos, hasFreq, hasProx, hasVectors);
+ return new ReadOnlyFieldInfos(infos);
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java b/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java
index ad5fc1dd0dd..a6283f9c5c4 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java
@@ -205,7 +205,8 @@ final class SegmentMerger {
final AtomicReader reader = readerAndLiveDocs.reader;
FieldInfos readerFieldInfos = reader.getFieldInfos();
for (FieldInfo fi : readerFieldInfos) {
- FieldInfo merged = mergeState.fieldInfos.add(fi);
+ // nocommit: ugly
+ FieldInfo merged = ((MutableFieldInfos)mergeState.fieldInfos).add(fi);
// update the type promotion mapping for this reader
if (fi.hasDocValues()) {
TypePromoter previous = docValuesTypes.get(merged);
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java b/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java
index 82e8d25396d..c4e7b228fd9 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java
@@ -90,11 +90,9 @@ public class TestCodecs extends LuceneTestCase {
public FieldData(final String name, final MutableFieldInfos fieldInfos, final TermData[] terms, final boolean omitTF, final boolean storePayloads) {
this.omitTF = omitTF;
this.storePayloads = storePayloads;
- fieldInfos.addOrUpdate(name, true);
- fieldInfo = fieldInfos.fieldInfo(name);
// TODO: change this test to use all three
- fieldInfo.indexOptions = omitTF ? IndexOptions.DOCS_ONLY : IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
- fieldInfo.storePayloads = storePayloads;
+ fieldInfos.addOrUpdate(name, true, false, false, storePayloads, omitTF ? IndexOptions.DOCS_ONLY : IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, null, null);
+ fieldInfo = fieldInfos.fieldInfo(name);
this.terms = terms;
for(int i=0;i<terms.length;i++)
terms[i].field = this;
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java b/lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java
index 5b4a5210db1..18ed3280be0 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java
@@ -294,8 +294,8 @@ public class TestConsistentFieldNumbers extends LuceneTestCase {
for (FieldInfo fi : fis) {
Field expected = getField(Integer.parseInt(fi.name));
- assertEquals(expected.fieldType().indexed(), fi.isIndexed);
- assertEquals(expected.fieldType().storeTermVectors(), fi.storeTermVector);
+ assertEquals(expected.fieldType().indexed(), fi.isIndexed());
+ assertEquals(expected.fieldType().storeTermVectors(), fi.hasVectors());
}
}
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java b/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
index a489672ac9b..1dab15a8087 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
@@ -258,12 +258,12 @@ public class TestDirectoryReader extends LuceneTestCase {
for(FieldInfo fieldInfo : fieldInfos) {
final String name = fieldInfo.name;
allFieldNames.add(name);
- if (fieldInfo.isIndexed) {
+ if (fieldInfo.isIndexed()) {
indexedFieldNames.add(name);
} else {
notIndexedFieldNames.add(name);
}
- if (fieldInfo.storeTermVector) {
+ if (fieldInfo.hasVectors()) {
tvFieldNames.add(name);
}
}
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java
index b47067ffdd7..64607b60a69 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestDocumentWriter.java
@@ -96,8 +96,8 @@ public class TestDocumentWriter extends LuceneTestCase {
// test that the norms are not present in the segment if
// omitNorms is true
for (FieldInfo fi : reader.getFieldInfos()) {
- if (fi.isIndexed) {
- assertTrue(fi.omitNorms == (reader.normValues(fi.name) == null));
+ if (fi.isIndexed()) {
+ assertTrue(fi.omitsNorms() == (reader.normValues(fi.name) == null));
}
}
reader.close();
@@ -331,10 +331,10 @@ public class TestDocumentWriter extends LuceneTestCase {
FieldInfos fi = reader.getFieldInfos();
// f1
assertFalse("f1 should have no norms", fi.fieldInfo("f1").hasNorms());
- assertEquals("omitTermFreqAndPositions field bit should not be set for f1", IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, fi.fieldInfo("f1").indexOptions);
+ assertEquals("omitTermFreqAndPositions field bit should not be set for f1", IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, fi.fieldInfo("f1").getIndexOptions());
// f2
assertTrue("f2 should have norms", fi.fieldInfo("f2").hasNorms());
- assertEquals("omitTermFreqAndPositions field bit should be set for f2", IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").indexOptions);
+ assertEquals("omitTermFreqAndPositions field bit should be set for f2", IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").getIndexOptions());
reader.close();
}
}
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java b/lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java
index 6a36c15ad0d..b32cbaa2b9c 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java
@@ -47,7 +47,9 @@ public class TestFieldInfos extends LuceneTestCase {
//Positive test of FieldInfos
assertTrue(testDoc != null);
MutableFieldInfos fieldInfos = new MutableFieldInfos(new MutableFieldInfos.FieldNumberBiMap());
- _TestUtil.add(testDoc, fieldInfos);
+ for (IndexableField field : testDoc) {
+ fieldInfos.addOrUpdate(field.name(), field.fieldType());
+ }
//Since the complement is stored as well in the fields map
assertTrue(fieldInfos.size() == DocHelper.all.size()); //this is all b/c we are using the no-arg constructor
@@ -76,22 +78,22 @@ public class TestFieldInfos extends LuceneTestCase {
assertTrue(fieldInfos.size() == readIn.size());
FieldInfo info = readIn.fieldInfo("textField1");
assertTrue(info != null);
- assertTrue(info.storeTermVector == false);
- assertTrue(info.omitNorms == false);
+ assertTrue(info.hasVectors() == false);
+ assertTrue(info.omitsNorms() == false);
info = readIn.fieldInfo("textField2");
assertTrue(info != null);
- assertTrue(info.omitNorms == false);
+ assertTrue(info.omitsNorms() == false);
info = readIn.fieldInfo("textField3");
assertTrue(info != null);
- assertTrue(info.storeTermVector == false);
- assertTrue(info.omitNorms == true);
+ assertTrue(info.hasVectors() == false);
+ assertTrue(info.omitsNorms() == true);
info = readIn.fieldInfo("omitNorms");
assertTrue(info != null);
- assertTrue(info.storeTermVector == false);
- assertTrue(info.omitNorms == true);
+ assertTrue(info.hasVectors() == false);
+ assertTrue(info.omitsNorms() == true);
dir.close();
}
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java b/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java
index 5703e82c184..1481b5e4db0 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java
@@ -55,7 +55,9 @@ public class TestFieldsReader extends LuceneTestCase {
public static void beforeClass() throws Exception {
fieldInfos = new MutableFieldInfos(new MutableFieldInfos.FieldNumberBiMap());
DocHelper.setupDoc(testDoc);
- _TestUtil.add(testDoc, fieldInfos);
+ for (IndexableField field : testDoc) {
+ fieldInfos.addOrUpdate(field.name(), field.fieldType());
+ }
dir = newDirectory();
IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy());
((LogMergePolicy) conf.getMergePolicy()).setUseCompoundFile(false);
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestNorms.java b/lucene/core/src/test/org/apache/lucene/index/TestNorms.java
index d7c0193a112..5219c65fb18 100755
--- a/lucene/core/src/test/org/apache/lucene/index/TestNorms.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestNorms.java
@@ -129,8 +129,8 @@ public class TestNorms extends LuceneTestCase {
AtomicReader reader = SlowCompositeReaderWrapper.wrap(IndexReader.open(otherDir));
FieldInfos fieldInfos = reader.getFieldInfos();
FieldInfo fieldInfo = fieldInfos.fieldInfo(byteTestField);
- assertFalse(fieldInfo.omitNorms);
- assertTrue(fieldInfo.isIndexed);
+ assertFalse(fieldInfo.omitsNorms());
+ assertTrue(fieldInfo.isIndexed());
if (secondWriteNorm) {
assertTrue(fieldInfo.hasNorms());
} else {
@@ -146,13 +146,13 @@ public class TestNorms extends LuceneTestCase {
DocValues normValues = mergedReader.normValues(byteTestField);
assertNull(normValues);
FieldInfo fi = mergedReader.getFieldInfos().fieldInfo(byteTestField);
- assertFalse(fi.omitNorms);
- assertTrue(fi.isIndexed);
+ assertFalse(fi.omitsNorms());
+ assertTrue(fi.isIndexed());
assertFalse(fi.hasNorms());
} else {
FieldInfo fi = mergedReader.getFieldInfos().fieldInfo(byteTestField);
- assertFalse(fi.omitNorms);
- assertTrue(fi.isIndexed);
+ assertFalse(fi.omitsNorms());
+ assertTrue(fi.isIndexed());
assertTrue(fi.hasNorms());
DocValues normValues = mergedReader.normValues(byteTestField);
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestOmitNorms.java b/lucene/core/src/test/org/apache/lucene/index/TestOmitNorms.java
index f44c88c62cb..0a0fd40dfef 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestOmitNorms.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestOmitNorms.java
@@ -68,8 +68,8 @@ public class TestOmitNorms extends LuceneTestCase {
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
FieldInfos fi = reader.getFieldInfos();
- assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f1").omitNorms);
- assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f2").omitNorms);
+ assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f1").omitsNorms());
+ assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f2").omitsNorms());
reader.close();
ram.close();
@@ -122,8 +122,8 @@ public class TestOmitNorms extends LuceneTestCase {
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
FieldInfos fi = reader.getFieldInfos();
- assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f1").omitNorms);
- assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f2").omitNorms);
+ assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f1").omitsNorms());
+ assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f2").omitsNorms());
reader.close();
ram.close();
@@ -170,8 +170,8 @@ public class TestOmitNorms extends LuceneTestCase {
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
FieldInfos fi = reader.getFieldInfos();
- assertTrue("OmitNorms field bit should not be set.", !fi.fieldInfo("f1").omitNorms);
- assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f2").omitNorms);
+ assertTrue("OmitNorms field bit should not be set.", !fi.fieldInfo("f1").omitsNorms());
+ assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f2").omitsNorms());
reader.close();
ram.close();
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java b/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java
index c3b1cb2298d..6cc2e92eac8 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java
@@ -156,23 +156,23 @@ public class TestOmitPositions extends LuceneTestCase {
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
FieldInfos fi = reader.getFieldInfos();
// docs + docs = docs
- assertEquals(IndexOptions.DOCS_ONLY, fi.fieldInfo("f1").indexOptions);
+ assertEquals(IndexOptions.DOCS_ONLY, fi.fieldInfo("f1").getIndexOptions());
// docs + docs/freqs = docs
- assertEquals(IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").indexOptions);
+ assertEquals(IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").getIndexOptions());
// docs + docs/freqs/pos = docs
- assertEquals(IndexOptions.DOCS_ONLY, fi.fieldInfo("f3").indexOptions);
+ assertEquals(IndexOptions.DOCS_ONLY, fi.fieldInfo("f3").getIndexOptions());
// docs/freqs + docs = docs
- assertEquals(IndexOptions.DOCS_ONLY, fi.fieldInfo("f4").indexOptions);
+ assertEquals(IndexOptions.DOCS_ONLY, fi.fieldInfo("f4").getIndexOptions());
// docs/freqs + docs/freqs = docs/freqs
- assertEquals(IndexOptions.DOCS_AND_FREQS, fi.fieldInfo("f5").indexOptions);
+ assertEquals(IndexOptions.DOCS_AND_FREQS, fi.fieldInfo("f5").getIndexOptions());
// docs/freqs + docs/freqs/pos = docs/freqs
- assertEquals(IndexOptions.DOCS_AND_FREQS, fi.fieldInfo("f6").indexOptions);
+ assertEquals(IndexOptions.DOCS_AND_FREQS, fi.fieldInfo("f6").getIndexOptions());
// docs/freqs/pos + docs = docs
- assertEquals(IndexOptions.DOCS_ONLY, fi.fieldInfo("f7").indexOptions);
+ assertEquals(IndexOptions.DOCS_ONLY, fi.fieldInfo("f7").getIndexOptions());
// docs/freqs/pos + docs/freqs = docs/freqs
- assertEquals(IndexOptions.DOCS_AND_FREQS, fi.fieldInfo("f8").indexOptions);
+ assertEquals(IndexOptions.DOCS_AND_FREQS, fi.fieldInfo("f8").getIndexOptions());
// docs/freqs/pos + docs/freqs/pos = docs/freqs/pos
- assertEquals(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, fi.fieldInfo("f9").indexOptions);
+ assertEquals(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, fi.fieldInfo("f9").getIndexOptions());
reader.close();
ram.close();
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java b/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java
index b90c16747f7..0e71ce900f5 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java
@@ -95,8 +95,8 @@ public class TestOmitTf extends LuceneTestCase {
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
FieldInfos fi = reader.getFieldInfos();
- assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f1").indexOptions);
- assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").indexOptions);
+ assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f1").getIndexOptions());
+ assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").getIndexOptions());
reader.close();
ram.close();
@@ -147,8 +147,8 @@ public class TestOmitTf extends LuceneTestCase {
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
FieldInfos fi = reader.getFieldInfos();
- assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f1").indexOptions);
- assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").indexOptions);
+ assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f1").getIndexOptions());
+ assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").getIndexOptions());
reader.close();
ram.close();
@@ -190,8 +190,8 @@ public class TestOmitTf extends LuceneTestCase {
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
FieldInfos fi = reader.getFieldInfos();
- assertEquals("OmitTermFreqAndPositions field bit should not be set.", IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, fi.fieldInfo("f1").indexOptions);
- assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").indexOptions);
+ assertEquals("OmitTermFreqAndPositions field bit should not be set.", IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, fi.fieldInfo("f1").getIndexOptions());
+ assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").getIndexOptions());
reader.close();
ram.close();
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestPayloads.java b/lucene/core/src/test/org/apache/lucene/index/TestPayloads.java
index 9a74dc49e0a..6b697fb94ac 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestPayloads.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestPayloads.java
@@ -113,9 +113,9 @@ public class TestPayloads extends LuceneTestCase {
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
FieldInfos fi = reader.getFieldInfos();
- assertFalse("Payload field bit should not be set.", fi.fieldInfo("f1").storePayloads);
- assertTrue("Payload field bit should be set.", fi.fieldInfo("f2").storePayloads);
- assertFalse("Payload field bit should not be set.", fi.fieldInfo("f3").storePayloads);
+ assertFalse("Payload field bit should not be set.", fi.fieldInfo("f1").hasPayloads());
+ assertTrue("Payload field bit should be set.", fi.fieldInfo("f2").hasPayloads());
+ assertFalse("Payload field bit should not be set.", fi.fieldInfo("f3").hasPayloads());
reader.close();
// now we add another document which has payloads for field f3 and verify if the SegmentMerger
@@ -140,9 +140,9 @@ public class TestPayloads extends LuceneTestCase {
reader = getOnlySegmentReader(IndexReader.open(ram));
fi = reader.getFieldInfos();
- assertFalse("Payload field bit should not be set.", fi.fieldInfo("f1").storePayloads);
- assertTrue("Payload field bit should be set.", fi.fieldInfo("f2").storePayloads);
- assertTrue("Payload field bit should be set.", fi.fieldInfo("f3").storePayloads);
+ assertFalse("Payload field bit should not be set.", fi.fieldInfo("f1").hasPayloads());
+ assertTrue("Payload field bit should be set.", fi.fieldInfo("f2").hasPayloads());
+ assertTrue("Payload field bit should be set.", fi.fieldInfo("f3").hasPayloads());
reader.close();
ram.close();
}
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java b/lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java
index f9915ac3b55..243ab7b50c3 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java
@@ -108,7 +108,7 @@ public class TestSegmentMerger extends LuceneTestCase {
int tvCount = 0;
for(FieldInfo fieldInfo : mergedReader.getFieldInfos()) {
- if (fieldInfo.storeTermVector) {
+ if (fieldInfo.hasVectors()) {
tvCount++;
}
}
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestSegmentReader.java b/lucene/core/src/test/org/apache/lucene/index/TestSegmentReader.java
index f537ad23e44..8577e93a5dc 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestSegmentReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestSegmentReader.java
@@ -84,14 +84,14 @@ public class TestSegmentReader extends LuceneTestCase {
for(FieldInfo fieldInfo : reader.getFieldInfos()) {
final String name = fieldInfo.name;
allFieldNames.add(name);
- if (fieldInfo.isIndexed) {
+ if (fieldInfo.isIndexed()) {
indexedFieldNames.add(name);
} else {
notIndexedFieldNames.add(name);
}
- if (fieldInfo.storeTermVector) {
+ if (fieldInfo.hasVectors()) {
tvFieldNames.add(name);
- } else if (fieldInfo.isIndexed) {
+ } else if (fieldInfo.isIndexed()) {
noTVFieldNames.add(name);
}
}
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java b/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java
index a34cc8bbb07..03abc20a06d 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java
@@ -48,8 +48,7 @@ public class TestTermVectorsReader extends LuceneTestCase {
private int[][] positions = new int[testTerms.length][];
private Directory dir;
private SegmentInfo seg;
- // nocommit: make a fieldInfos.empty for stuff like this?
- private FieldInfos fieldInfos = new MutableFieldInfos(new MutableFieldInfos.FieldNumberBiMap());
+ private FieldInfos fieldInfos = new ReadOnlyFieldInfos(new FieldInfo[0]);
private static int TERM_FREQ = 3;
private class TestToken implements Comparable<TestToken> {
diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java b/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java
index 67b361e051e..d09eb158dec 100644
--- a/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java
+++ b/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java
@@ -127,7 +127,7 @@ public abstract class BaseFragmentsBuilder implements FragmentsBuilder {
@Override
public void stringField(FieldInfo fieldInfo, String value) throws IOException {
FieldType ft = new FieldType(TextField.TYPE_STORED);
- ft.setStoreTermVectors(fieldInfo.storeTermVector);
+ ft.setStoreTermVectors(fieldInfo.hasVectors());
fields.add(new Field(fieldInfo.name, value, ft));
}
diff --git a/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java b/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
index 43848891424..b06099caeea 100644
--- a/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
+++ b/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
@@ -25,6 +25,8 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
@@ -35,7 +37,7 @@ import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.index.MutableFieldInfos;
+import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.Norm;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.DocsAndPositionsEnum;
@@ -49,6 +51,7 @@ import org.apache.lucene.index.StoredFieldVisitor;
import org.apache.lucene.index.TermState;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.index.FieldInfo.IndexOptions;
import org.apache.lucene.index.memory.MemoryIndexNormDocValues.SingleValueSource;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.IndexSearcher;
@@ -200,7 +203,7 @@ public class MemoryIndex {
private static final boolean DEBUG = false;
- private final MutableFieldInfos fieldInfos;
+ private final MemoryFieldInfos fieldInfos;
/**
* Sorts term entries into ascending order; also works for
@@ -236,8 +239,7 @@ public class MemoryIndex {
*/
protected MemoryIndex(boolean storeOffsets) {
this.stride = storeOffsets ? 3 : 1;
- // nocommit: this can probably have a much simpler implementation
- fieldInfos = new MutableFieldInfos();
+ fieldInfos = new MemoryFieldInfos();
}
/**
@@ -354,7 +356,7 @@ public class MemoryIndex {
int numOverlapTokens = 0;
int pos = -1;
- fieldInfos.addOrUpdate(fieldName, true);
+ fieldInfos.addOrUpdate(fieldName);
TermToBytesRefAttribute termAtt = stream.getAttribute(TermToBytesRefAttribute.class);
PositionIncrementAttribute posIncrAttribute = stream.addAttribute(PositionIncrementAttribute.class);
@@ -557,6 +559,45 @@ public class MemoryIndex {
///////////////////////////////////////////////////////////////////////////////
// Nested classes:
///////////////////////////////////////////////////////////////////////////////
+ private static final class MemoryFieldInfos extends FieldInfos {
+ private final SortedMap<Integer,FieldInfo> byNumber = new TreeMap<Integer,FieldInfo>();
+ private final HashMap<String,FieldInfo> byName = new HashMap<String,FieldInfo>();
+
+ @Override
+ public FieldInfos clone() {
+ return this; // I think this is ok here.
+ }
+
+ @Override
+ public FieldInfo fieldInfo(String fieldName) {
+ return byName.get(fieldName);
+ }
+
+ @Override
+ public FieldInfo fieldInfo(int fieldNumber) {
+ return byNumber.get(fieldNumber);
+ }
+
+ @Override
+ public Iterator<FieldInfo> iterator() {
+ return byNumber.values().iterator();
+ }
+
+ @Override
+ public int size() {
+ return byNumber.size();
+ }
+
+ public void addOrUpdate(String name) {
+ if (!byName.containsKey(name)) {
+ int number = byNumber.isEmpty() ? 0 : byNumber.lastKey() + 1;
+ FieldInfo info = new FieldInfo(name, true, number, false, false, false, IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, null, null);
+ byNumber.put(number, info);
+ byName.put(name, info);
+ }
+ }
+ }
+
/**
* Index data structure for a field; Contains the tokenized term texts and
* their positions.
diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWFieldInfosReader.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWFieldInfosReader.java
index 9d8b56eb86e..fc9c9c310af 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWFieldInfosReader.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWFieldInfosReader.java
@@ -44,10 +44,6 @@ class PreFlexRWFieldInfosReader extends FieldInfosReader {
public FieldInfos read(Directory directory, String segmentName, IOContext iocontext) throws IOException {
final String fileName = IndexFileNames.segmentFileName(segmentName, "", PreFlexRWFieldInfosWriter.FIELD_INFOS_EXTENSION);
IndexInput input = directory.openInput(fileName, iocontext);
-
- boolean hasVectors = false;
- boolean hasFreq = false;
- boolean hasProx = false;
try {
final int format = input.readVInt();
@@ -89,9 +85,6 @@ class PreFlexRWFieldInfosReader extends FieldInfosReader {
if (indexOptions != IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
storePayloads = false;
}
- hasVectors |= storeTermVector;
- hasProx |= isIndexed && indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
- hasFreq |= isIndexed && indexOptions != IndexOptions.DOCS_ONLY;
Type normType = isIndexed && !omitNorms ? Type.FIXED_INTS_8 : null;
if (format == PreFlexRWFieldInfosWriter.FORMAT_PREFLEX_RW && normType != null) {
@@ -106,7 +99,7 @@ class PreFlexRWFieldInfosReader extends FieldInfosReader {
if (input.getFilePointer() != input.length()) {
throw new CorruptIndexException("did not read all bytes from file \"" + fileName + "\": read " + input.getFilePointer() + " vs size " + input.length() + " (resource: " + input + ")");
}
- return new ReadOnlyFieldInfos(infos, hasFreq, hasProx, hasVectors);
+ return new ReadOnlyFieldInfos(infos);
} finally {
input.close();
}
diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWFieldInfosWriter.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWFieldInfosWriter.java
index 84f666ce544..e4c4e8cf80e 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWFieldInfosWriter.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWFieldInfosWriter.java
@@ -62,15 +62,15 @@ class PreFlexRWFieldInfosWriter extends FieldInfosWriter {
output.writeVInt(FORMAT_PREFLEX_RW);
output.writeVInt(infos.size());
for (FieldInfo fi : infos) {
- assert fi.indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS || !fi.storePayloads;
+ assert fi.getIndexOptions() == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS || !fi.hasPayloads();
byte bits = 0x0;
- if (fi.isIndexed) bits |= IS_INDEXED;
- if (fi.storeTermVector) bits |= STORE_TERMVECTOR;
- if (fi.omitNorms) bits |= OMIT_NORMS;
- if (fi.storePayloads) bits |= STORE_PAYLOADS;
- if (fi.indexOptions == IndexOptions.DOCS_ONLY) {
+ if (fi.isIndexed()) bits |= IS_INDEXED;
+ if (fi.hasVectors()) bits |= STORE_TERMVECTOR;
+ if (fi.omitsNorms()) bits |= OMIT_NORMS;
+ if (fi.hasPayloads()) bits |= STORE_PAYLOADS;
+ if (fi.getIndexOptions() == IndexOptions.DOCS_ONLY) {
bits |= OMIT_TERM_FREQ_AND_POSITIONS;
- } else if (fi.indexOptions == IndexOptions.DOCS_AND_FREQS) {
+ } else if (fi.getIndexOptions() == IndexOptions.DOCS_AND_FREQS) {
bits |= OMIT_POSITIONS;
}
output.writeString(fi.name);
@@ -81,7 +81,7 @@ class PreFlexRWFieldInfosWriter extends FieldInfosWriter {
*/
output.writeInt(fi.number);
output.writeByte(bits);
- if (fi.isIndexed && !fi.omitNorms) {
+ if (fi.isIndexed() && !fi.omitsNorms()) {
// to allow null norm types we need to indicate if norms are written
// only in RW case
output.writeByte((byte) (fi.getNormType() == null ? 0 : 1));
diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWFieldsWriter.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWFieldsWriter.java
index 246cd7db4b5..cd4383cd873 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWFieldsWriter.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWFieldsWriter.java
@@ -85,7 +85,7 @@ class PreFlexRWFieldsWriter extends FieldsConsumer {
@Override
public TermsConsumer addField(FieldInfo field) throws IOException {
assert field.number != -1;
- if (field.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0) {
+ if (field.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0) {
throw new UnsupportedOperationException("this codec cannot index offsets");
}
//System.out.println("w field=" + field.name + " storePayload=" + field.storePayloads + " number=" + field.number);
@@ -107,8 +107,8 @@ class PreFlexRWFieldsWriter extends FieldsConsumer {
public PreFlexTermsWriter(FieldInfo fieldInfo) {
this.fieldInfo = fieldInfo;
- omitTF = fieldInfo.indexOptions == IndexOptions.DOCS_ONLY;
- storePayloads = fieldInfo.storePayloads;
+ omitTF = fieldInfo.getIndexOptions() == IndexOptions.DOCS_ONLY;
+ storePayloads = fieldInfo.hasPayloads();
}
private class PostingsWriter extends PostingsConsumer {
diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWNormsConsumer.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWNormsConsumer.java
index fe0817300da..5debc5b125a 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWNormsConsumer.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/lucene3x/PreFlexRWNormsConsumer.java
@@ -209,7 +209,7 @@ class PreFlexRWNormsConsumer extends PerDocConsumer {
}
public void startField(FieldInfo info) throws IOException {
- assert info.omitNorms == false;
+ assert info.omitsNorms() == false;
normCount++;
}
diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/ramonly/RAMOnlyPostingsFormat.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/ramonly/RAMOnlyPostingsFormat.java
index f23d0fc35e1..847fc771562 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/ramonly/RAMOnlyPostingsFormat.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/ramonly/RAMOnlyPostingsFormat.java
@@ -197,7 +197,7 @@ public class RAMOnlyPostingsFormat extends PostingsFormat {
@Override
public TermsConsumer addField(FieldInfo field) {
- if (field.indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0) {
+ if (field.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0) {
throw new UnsupportedOperationException("this codec cannot index offsets");
}
RAMField ramField = new RAMField(field.name);
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/FieldFilterAtomicReader.java b/lucene/test-framework/src/java/org/apache/lucene/index/FieldFilterAtomicReader.java
index da0f452046e..def871b0027 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/index/FieldFilterAtomicReader.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/FieldFilterAtomicReader.java
@@ -18,6 +18,7 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Set;
import org.apache.lucene.index.FilterAtomicReader;
@@ -26,19 +27,19 @@ public final class FieldFilterAtomicReader extends FilterAtomicReader {
private final Set<String> fields;
private final boolean negate;
- // nocommit: make read only
- private final MutableFieldInfos fieldInfos;
+ private final FieldInfos fieldInfos;
public FieldFilterAtomicReader(AtomicReader in, Set<String> fields, boolean negate) {
super(in);
this.fields = fields;
this.negate = negate;
- this.fieldInfos = new MutableFieldInfos();
+ ArrayList<FieldInfo> filteredInfos = new ArrayList<FieldInfo>();
for (FieldInfo fi : in.getFieldInfos()) {
if (hasField(fi.name)) {
- fieldInfos.add(fi);
+ filteredInfos.add(fi);
}
}
+ fieldInfos = new ReadOnlyFieldInfos(filteredInfos.toArray(new FieldInfo[filteredInfos.size()]));
}
boolean hasField(String field) {
diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java b/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
index e967ef42b73..d4eb5389fea 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
@@ -62,7 +62,6 @@ import org.apache.lucene.index.LogMergePolicy;
import org.apache.lucene.index.MergePolicy;
import org.apache.lucene.index.MergeScheduler;
import org.apache.lucene.index.MultiFields;
-import org.apache.lucene.index.MutableFieldInfos;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.index.TieredMergePolicy;
@@ -679,14 +678,6 @@ public class _TestUtil {
}
}
- /** Adds field info for a Document. */
- // nocommit: what uses this?
- public static void add(Document doc, MutableFieldInfos fieldInfos) {
- for (IndexableField field : doc) {
- fieldInfos.addOrUpdate(field.name(), field.fieldType());
- }
- }
-
/**
* insecure, fast version of File.createTempFile
* uses Random instead of SecureRandom.
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index b2ae0edfee6..4151d02bbd2 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -452,11 +452,10 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
@Override
public void stringField(FieldInfo fieldInfo, String value) throws IOException {
final FieldType ft = new FieldType(TextField.TYPE_STORED);
- ft.setStoreTermVectors(fieldInfo.storeTermVector);
- ft.setStoreTermVectors(fieldInfo.storeTermVector);
- ft.setIndexed(fieldInfo.isIndexed);
- ft.setOmitNorms(fieldInfo.omitNorms);
- ft.setIndexOptions(fieldInfo.indexOptions);
+ ft.setStoreTermVectors(fieldInfo.hasVectors());
+ ft.setIndexed(fieldInfo.isIndexed());
+ ft.setOmitNorms(fieldInfo.omitsNorms());
+ ft.setIndexOptions(fieldInfo.getIndexOptions());
doc.add(new Field(fieldInfo.name, value, ft));
}
@@ -464,7 +463,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
public void intField(FieldInfo fieldInfo, int value) {
FieldType ft = new FieldType(IntField.TYPE);
ft.setStored(true);
- ft.setIndexed(fieldInfo.isIndexed);
+ ft.setIndexed(fieldInfo.isIndexed());
doc.add(new IntField(fieldInfo.name, value, ft));
}
@@ -472,7 +471,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
public void longField(FieldInfo fieldInfo, long value) {
FieldType ft = new FieldType(LongField.TYPE);
ft.setStored(true);
- ft.setIndexed(fieldInfo.isIndexed);
+ ft.setIndexed(fieldInfo.isIndexed());
doc.add(new LongField(fieldInfo.name, value, ft));
}
@@ -480,7 +479,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
public void floatField(FieldInfo fieldInfo, float value) {
FieldType ft = new FieldType(FloatField.TYPE);
ft.setStored(true);
- ft.setIndexed(fieldInfo.isIndexed);
+ ft.setIndexed(fieldInfo.isIndexed());
doc.add(new FloatField(fieldInfo.name, value, ft));
}
@@ -488,7 +487,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
public void doubleField(FieldInfo fieldInfo, double value) {
FieldType ft = new FieldType(DoubleField.TYPE);
ft.setStored(true);
- ft.setIndexed(fieldInfo.isIndexed);
+ ft.setIndexed(fieldInfo.isIndexed());
doc.add(new DoubleField(fieldInfo.name, value, ft));
}
}
diff --git a/solr/core/src/test/org/apache/solr/search/TestDocSet.java b/solr/core/src/test/org/apache/solr/search/TestDocSet.java
index d951ddcc85f..549cb147eec 100644
--- a/solr/core/src/test/org/apache/solr/search/TestDocSet.java
+++ b/solr/core/src/test/org/apache/solr/search/TestDocSet.java
@@ -367,8 +367,7 @@ public class TestDocSet extends LuceneTestCase {
@Override
public FieldInfos getFieldInfos() {
- // nocommit
- return new ReadOnlyFieldInfos(new FieldInfo[0], false, false, false);
+ return new ReadOnlyFieldInfos(new FieldInfo[0]);
}
@Override