Index: lucene/src/java/org/apache/lucene/document/Field.java
===================================================================
--- lucene/src/java/org/apache/lucene/document/Field.java (revision 1158404)
+++ lucene/src/java/org/apache/lucene/document/Field.java (working copy)
@@ -20,15 +20,14 @@
import java.io.Reader;
import org.apache.lucene.analysis.TokenStream;
-<<<<<<<
import org.apache.lucene.index.FieldInfo.IndexOptions;
import org.apache.lucene.index.IndexWriter;
-=======
import org.apache.lucene.document.NumericField;
import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.values.PerDocFieldValues;
+import org.apache.lucene.index.values.ValueType;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.StringHelper;
->>>>>>>
/**
* A field is a section of a Document. Each field has two parts, a name and a
@@ -50,6 +49,7 @@
// length/offset for all primitive types
protected int binaryLength;
protected int binaryOffset;
+ protected PerDocFieldValues docValues;
protected float boost = 1.0f;
@@ -64,7 +64,7 @@
if (reader == null)
throw new NullPointerException("reader cannot be null");
- this.name = StringHelper.intern(name); // field names are interned
+ this.name = name; // field names are interned
this.fieldsData = reader;
this.type = type;
}
@@ -75,7 +75,7 @@
if (tokenStream == null)
throw new NullPointerException("tokenStream cannot be null");
- this.name = StringHelper.intern(name); // field names are interned
+ this.name = name; // field names are interned
this.fieldsData = null;
this.tokenStream = tokenStream;
this.type = type;
@@ -91,7 +91,7 @@
this.type = type;
this.binaryOffset = offset;
this.binaryLength = length;
- this.name = StringHelper.intern(name);
+ this.name = name;
}
public Field(String name, FieldType type, String value) {
@@ -117,9 +117,6 @@
this.type = type;
this.name = name;
this.fieldsData = value;
-
- if (internName) // field names are optionally interned
- name = StringHelper.intern(name);
}
public boolean isNumeric() {
@@ -237,63 +234,6 @@
return name;
}
-<<<<<<<
- /**
- * Create a field by specifying its name, value and how it will
- * be saved in the index.
- *
- * @param name The name of the field
- * @param value The string to process
- * @param store Whether value should be stored in the index
- * @param index Whether the field should be indexed, and if so, if it should
- * be tokenized before indexing
- * @param termVector Whether term vector should be stored
- * @throws NullPointerException if name or value is null
- * @throws IllegalArgumentException in any of the following situations:
- *
TermVector.YESnull
- */
- public Field(String name, Reader reader, TermVector termVector) {
- if (name == null)
- throw new NullPointerException("name cannot be null");
- if (reader == null)
- throw new NullPointerException("reader cannot be null");
-
- this.name = name;
- this.fieldsData = reader;
-
- this.isStored = false;
-
- this.isIndexed = true;
- this.isTokenized = true;
-
- this.isBinary = false;
-
- setStoreTermVector(termVector);
-=======
public Number numericValue() {
return null;
->>>>>>>
}
public NumericField.DataType numericDataType() {
return null;
}
-<<<<<<<
- /**
- * Create a tokenized and indexed field that is not stored, optionally with
- * storing term vectors. This is useful for pre-analyzed fields.
- * The TokenStream is read only when the Document is added to the index,
- * i.e. you may not close the TokenStream until {@link IndexWriter#addDocument(Document)}
- * has been called.
- *
- * @param name The name of the field
- * @param tokenStream The TokenStream with the content
- * @param termVector Whether term vector should be stored
- * @throws NullPointerException if name or tokenStream is null
- */
- public Field(String name, TokenStream tokenStream, TermVector termVector) {
- if (name == null)
- throw new NullPointerException("name cannot be null");
- if (tokenStream == null)
- throw new NullPointerException("tokenStream cannot be null");
-
- this.name = name;
- this.fieldsData = null;
- this.tokenStream = tokenStream;
-
- this.isStored = false;
-
- this.isIndexed = true;
- this.isTokenized = true;
-
- this.isBinary = false;
-
- setStoreTermVector(termVector);
-=======
private byte[] getBinaryValue(byte[] result /* unused */) {
if (isBinary || fieldsData instanceof byte[]) return (byte[]) fieldsData;
else return null;
}
- private byte[] getBinaryValue() {
+ protected byte[] getBinaryValue() {
return getBinaryValue(null);
}
@@ -417,7 +293,6 @@
} else {
return null;
}
->>>>>>>
}
/**
@@ -426,7 +301,7 @@
*
* @return length of byte[] segment that represents this Field value
*/
- private int getBinaryLength() {
+ protected int getBinaryLength() {
if (isBinary) {
return binaryLength;
} else if (fieldsData instanceof byte[]) return ((byte[]) fieldsData).length;
@@ -466,8 +341,8 @@
return type.omitNorms();
}
- public boolean omitTermFreqAndPositions() {
- return type.omitTermFreqAndPositions();
+ public IndexOptions getIndexOptions() {
+ return type.indexOptions();
}
public boolean storeTermVectors() {
@@ -495,33 +370,32 @@
result.append(name);
result.append(':');
-<<<<<<<
- if (name == null)
- throw new IllegalArgumentException("name cannot be null");
- if (value == null)
- throw new IllegalArgumentException("value cannot be null");
-
- this.name = name;
- fieldsData = value;
-
- isStored = true;
- isIndexed = false;
- isTokenized = false;
- indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
- omitNorms = true;
-
- isBinary = true;
- binaryLength = length;
- binaryOffset = offset;
-
- setStoreTermVector(TermVector.NO);
-=======
if (fieldsData != null && type.lazy() == false) {
result.append(fieldsData);
}
result.append('>');
return result.toString();
->>>>>>>
}
+
+ public PerDocFieldValues getDocValues() {
+ return docValues;
+ }
+
+ public void setDocValues(PerDocFieldValues docValues) {
+ this.docValues = docValues;
+ }
+
+ public boolean hasDocValues() {
+ return docValues != null && docValues.type() != null;
+ }
+
+ public ValueType docValuesType() {
+ return docValues == null? null : docValues.type();
+ }
+
+ public FieldType getFieldType() {
+ // get a copy
+ return new FieldType(type);
+ }
}
Index: lucene/src/java/org/apache/lucene/document/FieldType.java
===================================================================
--- lucene/src/java/org/apache/lucene/document/FieldType.java (revision 1158404)
+++ lucene/src/java/org/apache/lucene/document/FieldType.java (working copy)
@@ -17,6 +17,8 @@
* limitations under the License.
*/
+import org.apache.lucene.index.FieldInfo.IndexOptions;
+
public class FieldType {
private boolean indexed;
@@ -26,7 +28,7 @@
private boolean storeTermVectorOffsets;
private boolean storeTermVectorPositions;
private boolean omitNorms;
- private boolean omitTermFreqsAndPositions;
+ private IndexOptions indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
private boolean lazy;
private boolean frozen;
@@ -38,7 +40,7 @@
this.storeTermVectorOffsets = ref.storeTermVectorOffsets();
this.storeTermVectorPositions = ref.storeTermVectorPositions();
this.omitNorms = ref.omitNorms();
- this.omitTermFreqsAndPositions = ref.omitTermFreqAndPositions();
+ this.indexOptions = ref.indexOptions();
this.lazy = ref.lazy();
}
@@ -118,13 +120,13 @@
this.omitNorms = value;
}
- public boolean omitTermFreqAndPositions() {
- return this.omitTermFreqsAndPositions;
+ public IndexOptions indexOptions() {
+ return this.indexOptions;
}
- public void setOmitTermFreqAndPositions(boolean value) {
+ public void setIndexOptions(IndexOptions value) {
checkIfFrozen();
- this.omitTermFreqsAndPositions = value;
+ this.indexOptions = value;
}
public boolean lazy() {
@@ -171,8 +173,9 @@
if (omitNorms()) {
result.append(",omitNorms");
}
- if (omitTermFreqAndPositions()) {
- result.append(",omitTermFreqAndPositions");
+ if (indexOptions != IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
+ result.append(",indexOptions=");
+ result.append(indexOptions);
}
if (lazy()){
result.append(",lazy");
Index: lucene/src/java/org/apache/lucene/document/IndexDocValuesField.java
===================================================================
--- lucene/src/java/org/apache/lucene/document/IndexDocValuesField.java (revision 1158404)
+++ lucene/src/java/org/apache/lucene/document/IndexDocValuesField.java (working copy)
@@ -20,9 +20,6 @@
import java.util.Comparator;
import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.document.Field.Index;
-import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.document.Field.TermVector;
import org.apache.lucene.index.values.PerDocFieldValues;
import org.apache.lucene.index.values.ValueType;
import org.apache.lucene.util.BytesRef;
@@ -73,7 +70,7 @@
*
*
* */
-public class IndexDocValuesField extends AbstractField implements PerDocFieldValues {
+public class IndexDocValuesField extends Field implements PerDocFieldValues {
protected BytesRef bytes;
protected double doubleValue;
@@ -85,7 +82,7 @@
* Creates a new {@link IndexDocValuesField} with the given name.
*/
public IndexDocValuesField(String name) {
- super(name, Store.NO, Index.NO, TermVector.NO);
+ super(name, new FieldType());
setDocValues(this);
}
@@ -329,7 +326,7 @@
* returns the given field. Any modifications to this instance will be visible
* to the given field.
*/
- public The java native types int, long,
* float and double are
@@ -133,85 +129,6 @@
* class is a wrapper around this token stream type for
* easier, more intuitive usage.
- * The java native types int, long, float
- * and double are directly supported. However, any value that can
- * be converted into these native types can also be indexed. For example,
- * date/time values represented by a {@link java.util.Date} can be translated
- * into a long value using the {@link java.util.Date#getTime} method. If you
- * don't need millisecond precision, you can quantize the value, either by
- * dividing the result of {@link java.util.Date#getTime} or using the separate
- * getters (for year, month, etc.) to construct an int or
- * long value.
- *
- * To perform range querying or filtering against a NumericField,
- * use {@link NumericRangeQuery} or {@link NumericRangeFilter}. To sort
- * according to a NumericField, use the normal numeric sort types,
- * eg {@link SortField#INT}. NumericField values can also be loaded
- * directly from {@link FieldCache}.
- *
- * By default, a NumericField's value is not stored but is indexed
- * for range filtering and sorting. You can use the
- * {@link #NumericField(String,FieldType)} constructor if you need to
- * change these defaults, and alter the default field type (set it to stored).
- *
- * You may add the same field name as a NumericField to the same
- * document more than once. Range querying and filtering will be the logical OR
- * of all values; so a range query will hit all documents that have at least one
- * value in the range. However sort behavior is not defined. If you need to
- * sort, you should separately index a single-valued NumericField.
- *
- * A NumericField will consume somewhat more disk space in the
- * index than an ordinary single-valued field. However, for a typical index that
- * includes substantial textual content per document, this increase will likely
- * be in the noise.
- *
- * Within Lucene, each numeric value is indexed as a trie structure,
- * where each term is logically assigned to larger and larger pre-defined
- * brackets (which are simply lower-precision representations of the value). The
- * step size between each successive bracket is called the
- * precisionStep, measured in bits. Smaller
- * precisionStep values result in larger number of brackets, which
- * consumes more disk space in the index but may result in faster range search
- * performance. The default value, 4, was selected for a reasonable tradeoff of
- * disk space consumption versus performance. You can use the expert constructor
- * {@link #NumericField(String,int,FieldType)} if you'd like to change
- * the value. Note that you must also specify a congruent value when creating
- * {@link NumericRangeQuery} or {@link NumericRangeFilter}. For low cardinality
- * fields larger precision steps are good. If the cardinality is < 100, it is
- * fair to use {@link Integer#MAX_VALUE}, which produces one term per value.
- *
- *
- * For more information on the internals of numeric trie indexing, including the
- *
- * precisionStep configuration, see {@link NumericRangeQuery}.
- * The format of indexed values is described in {@link NumericUtils}.
- *
- *
- * If you only need to sort by numeric value, and never run range
- * querying/filtering, you can index using a precisionStep of
- * {@link Integer#MAX_VALUE}. This will minimize disk space consumed.
- *
- * More advanced users can instead use {@link NumericTokenStream} directly, when - * indexing numbers. This class is a wrapper around this token stream type for - * easier, more intuitive usage. - *
- * ->>>>>>> * @since 2.9 */ public final class NumericField extends Field { @@ -227,14 +144,14 @@ TYPE_UNSTORED.setIndexed(true); TYPE_UNSTORED.setTokenized(true); TYPE_UNSTORED.setOmitNorms(true); - TYPE_UNSTORED.setOmitTermFreqAndPositions(true); + TYPE_UNSTORED.setIndexOptions(IndexOptions.DOCS_ONLY); TYPE_UNSTORED.freeze(); TYPE_STORED.setIndexed(true); TYPE_STORED.setStored(true); TYPE_STORED.setTokenized(true); TYPE_STORED.setOmitNorms(true); - TYPE_STORED.setOmitTermFreqAndPositions(true); + TYPE_STORED.setIndexOptions(IndexOptions.DOCS_ONLY); TYPE_STORED.freeze(); } @@ -317,10 +234,6 @@ public NumericField(String name, int precisionStep, FieldType type) { super(name, type); this.precisionStep = precisionStep; -<<<<<<< - setIndexOptions(IndexOptions.DOCS_ONLY); -======= ->>>>>>> } /** Returns a {@link NumericTokenStream} for indexing the numeric value. */ Index: lucene/src/java/org/apache/lucene/document/StringField.java =================================================================== --- lucene/src/java/org/apache/lucene/document/StringField.java (revision 1158404) +++ lucene/src/java/org/apache/lucene/document/StringField.java (working copy) @@ -1,5 +1,7 @@ package org.apache.lucene.document; +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 @@ -24,13 +26,13 @@ static { TYPE_UNSTORED.setIndexed(true); TYPE_UNSTORED.setOmitNorms(true); - TYPE_UNSTORED.setOmitTermFreqAndPositions(true); + TYPE_UNSTORED.setIndexOptions(IndexOptions.DOCS_ONLY); TYPE_UNSTORED.freeze(); TYPE_STORED.setIndexed(true); TYPE_STORED.setStored(true); TYPE_STORED.setOmitNorms(true); - TYPE_STORED.setOmitTermFreqAndPositions(true); + TYPE_STORED.setIndexOptions(IndexOptions.DOCS_ONLY); TYPE_STORED.freeze(); } Index: lucene/src/java/org/apache/lucene/index/CheckIndex.java =================================================================== --- lucene/src/java/org/apache/lucene/index/CheckIndex.java (revision 1158404) +++ lucene/src/java/org/apache/lucene/index/CheckIndex.java (working copy) @@ -25,12 +25,9 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; -<<<<<<< -======= import org.apache.lucene.document.Document; import org.apache.lucene.index.codecs.CodecProvider; import org.apache.lucene.index.codecs.DefaultSegmentInfosWriter; ->>>>>>> import java.io.File; import java.io.IOException; import java.io.PrintStream; @@ -41,7 +38,6 @@ import java.util.List; import java.util.Map; -import org.apache.lucene.document.AbstractField; // for javadocs import org.apache.lucene.document.Document; import org.apache.lucene.index.codecs.CodecProvider; import org.apache.lucene.index.codecs.DefaultSegmentInfosWriter; @@ -193,13 +189,8 @@ int numFields; /** True if at least one of the fields in this segment -<<<<<<< * has position data - * @see AbstractField#setIndexOptions(org.apache.lucene.index.FieldInfo.IndexOptions) */ -======= - * does not omitTermFreqAndPositions. - * @see FieldType#setOmitTermFreqAndPositions */ ->>>>>>> + * @see FieldType#setIndexOptions(org.apache.lucene.index.FieldInfo.IndexOptions) */ public boolean hasProx; /** Map that includes certain Index: lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java =================================================================== --- lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java (revision 1158404) +++ lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java (working copy) @@ -24,19 +24,12 @@ import java.util.HashSet; import java.util.Map; -<<<<<<< import org.apache.lucene.document.Document; -import org.apache.lucene.document.Fieldable; -======= import org.apache.lucene.util.ArrayUtil; - - ->>>>>>> import org.apache.lucene.index.DocumentsWriterPerThread.DocState; import org.apache.lucene.index.codecs.Codec; import org.apache.lucene.index.codecs.PerDocConsumer; import org.apache.lucene.index.codecs.DocValuesConsumer; -import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.IOUtils; @@ -230,15 +223,9 @@ // needs to be more "pluggable" such that if I want // to have a new "thing" my Fields can do, I can // easily add it -<<<<<<< - FieldInfo fi = fieldInfos.addOrUpdate(fieldName, field.isIndexed(), field.isTermVectorStored(), - field.isStorePositionWithTermVector(), field.isStoreOffsetWithTermVector(), - field.getOmitNorms(), false, field.getIndexOptions(), field.docValuesType()); -======= FieldInfo fi = fieldInfos.addOrUpdate(fieldName, field.indexed(), field.storeTermVectors(), field.storeTermVectorPositions(), field.storeTermVectorOffsets(), - field.omitNorms(), false, field.omitTermFreqAndPositions()); ->>>>>>> + field.omitNorms(), false, field.getIndexOptions(), field.docValuesType()); fp = new DocFieldProcessorPerField(this, fi); fp.next = fieldHash[hashPos]; @@ -249,15 +236,9 @@ rehash(); } } else { -<<<<<<< - fieldInfos.addOrUpdate(fp.fieldInfo.name, field.isIndexed(), field.isTermVectorStored(), - field.isStorePositionWithTermVector(), field.isStoreOffsetWithTermVector(), - field.getOmitNorms(), false, field.getIndexOptions(), field.docValuesType()); -======= fieldInfos.addOrUpdate(fp.fieldInfo.name, field.indexed(), field.storeTermVectors(), field.storeTermVectorPositions(), field.storeTermVectorOffsets(), - field.omitNorms(), false, field.omitTermFreqAndPositions()); ->>>>>>> + field.omitNorms(), false, field.getIndexOptions(), field.docValuesType()); } if (thisFieldGen != fp.lastGen) { Index: lucene/src/java/org/apache/lucene/index/DocInverterPerField.java =================================================================== --- lucene/src/java/org/apache/lucene/index/DocInverterPerField.java (revision 1158404) +++ lucene/src/java/org/apache/lucene/index/DocInverterPerField.java (working copy) @@ -190,13 +190,8 @@ } } -<<<<<<< fieldState.offset += docState.analyzer == null ? 0 : docState.analyzer.getOffsetGap(field); - fieldState.boost *= field.getBoost(); -======= - fieldState.offset += docState.analyzer.getOffsetGap(field); fieldState.boost *= field.boost(); ->>>>>>> } // LUCENE-2387: don't hang onto the field, so GC can Index: lucene/src/java/org/apache/lucene/index/FieldInvertState.java =================================================================== --- lucene/src/java/org/apache/lucene/index/FieldInvertState.java (revision 1158404) +++ lucene/src/java/org/apache/lucene/index/FieldInvertState.java (working copy) @@ -56,12 +56,8 @@ numOverlap = 0; offset = 0; maxTermFrequency = 0; -<<<<<<< uniqueTermCount = 0; - boost = docBoost; -======= boost = 1.0f; ->>>>>>> attributeSource = null; } Index: lucene/src/java/org/apache/lucene/index/FieldsReader.java =================================================================== --- lucene/src/java/org/apache/lucene/index/FieldsReader.java (revision 1158404) +++ lucene/src/java/org/apache/lucene/index/FieldsReader.java (working copy) @@ -19,12 +19,12 @@ import java.io.IOException; +import org.apache.lucene.document.NumericField; import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.BufferedIndexInput; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; -<<<<<<< import org.apache.lucene.util.CloseableThreadLocal; import org.apache.lucene.util.IOUtils; @@ -32,8 +32,6 @@ import java.io.IOException; import java.io.Reader; import java.util.ArrayList; -======= ->>>>>>> /** * Class responsible for access to stored document fields. @@ -46,7 +44,8 @@ private final static int FORMAT_SIZE = 4; private final FieldInfos fieldInfos; - + private CloseableThreadLocaln
* th position. The {@link FieldSelector} may be used to determine
@@ -1013,8 +1010,6 @@
// TODO (1.5): When we convert to JDK 1.5 make this Set| - * lengthNorm - * · - * | ->>>>>>> -<<<<<<< -======= - * ∏ - * - *- * {@link org.apache.lucene.index.IndexableField#boost() f.getBoost}() - * | - *