Apache Solr open-source search software
LUCENE-3312: Merge up to trunk and fix basic Javadocs merge conflicts. The new classes now need method descriptions, mainly oal.index.StorableField(Type)
Uwe Schindler50d263930823
diff --cc lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.javaindex 707ec2e8bc4,076af30f530..74e2142da2b--- a/lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java+++ b/lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java@@@ -36,8 -36,11 +36,11 @@@ import org.apache.lucene.index.DocValue* @see DocValues for further information* */-public class ByteDocValuesField extends Field {+public class ByteDocValuesField extends StoredField {+ /**+ * Type for 8-bit byte DocValues.+ */public static final FieldType TYPE = new FieldType();static {TYPE.setDocValueType(DocValues.Type.FIXED_INTS_8);diff --cc lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.javaindex a4f9ab2f763,bc846a443fe..98755d63673--- a/lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java+++ b/lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java@@@ -41,9 -41,12 +41,12 @@@ import org.apache.lucene.util.BytesRef* @see DocValues for further information* */-public class DerefBytesDocValuesField extends Field {+public class DerefBytesDocValuesField extends StoredField {// TODO: ideally indexer figures out var vs fixed on its own!?+ /**+ * Type for indirect bytes DocValues: all with the same length+ */public static final FieldType TYPE_FIXED_LEN = new FieldType();static {TYPE_FIXED_LEN.setDocValueType(DocValues.Type.BYTES_FIXED_DEREF);diff --cc lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.javaindex 60d255af5b9,2f79c411f1f..111fd258abe--- a/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java+++ b/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java@@@ -97,7 -96,14 +97,11 @@@ public class DocumentStoredFieldVisitoreturn fieldsToAdd == null || fieldsToAdd.contains(fieldInfo.name) ? Status.YES : Status.NO;}+ /**+ * Retrieve the visited document.- * @return Document populated with stored fields. Note that only- * the stored information in the field instances is valid,- * data such as boosts, indexing options, term vector options,- * etc is not set.++ * @return StoredDocument populated with stored fields.+ */- public Document getDocument() {+ public StoredDocument getDocument() {return doc;}}diff --cc lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.javaindex c7d0fb113ed,bb4d1f57187..6b21cf3dffd--- a/lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java+++ b/lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java@@@ -36,8 -36,11 +36,11 @@@ import org.apache.lucene.index.DocValue* @see DocValues for further information* */-public class DoubleDocValuesField extends Field {+public class DoubleDocValuesField extends StoredField {+ /**+ * Type for 64-bit double DocValues.+ */public static final FieldType TYPE = new FieldType();static {TYPE.setDocValueType(DocValues.Type.FLOAT_64);diff --cc lucene/core/src/java/org/apache/lucene/document/Field.javaindex 37b23934b4b,8328e0719f8..70fb72a5150--- a/lucene/core/src/java/org/apache/lucene/document/Field.java+++ b/lucene/core/src/java/org/apache/lucene/document/Field.java@@@ -59,18 -58,24 +59,25 @@@ import org.apache.lucene.index.FieldInv* Field it is used in. It is strongly recommended that no* changes be made after Field instantiation.*/-public class Field implements IndexableField {+public class Field implements IndexableField, StorableField {+ /**+ * Field's type+ */protected final FieldType type;+++ /**+ * Field's name+ */protected final String name;- // Field's value:+ /** Field's value */protected Object fieldsData;- // Pre-analyzed tokenStream for indexed fields; this is- // separate from fieldsData because you are allowed to- // have both; eg maybe field has a String value but you- // customize how it's tokenized:+ /** Pre-analyzed tokenStream for indexed fields; this is+ * separate from fieldsData because you are allowed to+ * have both; eg maybe field has a String value but you+ * customize how it's tokenized */protected TokenStream tokenStream;private transient TokenStream internalTokenStream;diff --cc lucene/core/src/java/org/apache/lucene/document/FieldType.javaindex cb2400dc8dd,a47641116b1..8f4b6c90fb8--- a/lucene/core/src/java/org/apache/lucene/document/FieldType.java+++ b/lucene/core/src/java/org/apache/lucene/document/FieldType.java@@@ -45,8 -55,11 +55,11 @@@ public class FieldType implements Indexprivate NumericType numericType;private boolean frozen;private int numericPrecisionStep = NumericUtils.PRECISION_STEP_DEFAULT;+ private DocValues.Type docValueType;+ /**+ * Create a new mutable FieldType with all of the properties from <code>ref</code>+ */public FieldType(FieldType ref) {this.indexed = ref.indexed();this.stored = ref.stored();@@@ -161,6 -299,36 +299,13 @@@this.indexOptions = value;}- /**- * Set's the field's DocValues.Type- * @param type DocValues type, or null if no DocValues should be stored.- * @throws IllegalStateException if this FieldType is frozen against- * future modifications.- * @see #docValueType()- */- public void setDocValueType(DocValues.Type type) {- checkIfFrozen();- docValueType = type;- }-- /**- * {@inheritDoc}- * <p>- * The default is <code>null</code> (no docValues)- * @see #setDocValueType(DocValues.Type)- */- @Override- public DocValues.Type docValueType() {- return docValueType;- }-+ /**+ * Specifies the field's numeric type.+ * @param type numeric type, or null if the field has no numeric type.+ * @throws IllegalStateException if this FieldType is frozen against+ * future modifications.+ * @see #numericType()+ */public void setNumericType(NumericType type) {checkIfFrozen();numericType = type;@@@ -236,17 -423,4 +400,30 @@@return result.toString();}++ /* from StorableFieldType */+++ /**++ * {@inheritDoc}++ * <p>++ * The default is <code>null</code> (no docValues)++ * @see #setDocValueType(DocValues.Type)++ */+ @Override+ public DocValues.Type docValueType() {+ return docValueType;+ }+++ /**++ * Set's the field's DocValues.Type++ * @param type DocValues type, or null if no DocValues should be stored.++ * @throws IllegalStateException if this FieldType is frozen against++ * future modifications.++ * @see #docValueType()++ */+ public void setDocValueType(DocValues.Type type) {+ checkIfFrozen();+ docValueType = type;+ this.stored = true;+ }}diff --cc lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.javaindex 178a82a0ec3,dd4f1c20d6a..bf66370ef9b--- a/lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java+++ b/lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java@@@ -35,8 -35,11 +35,11 @@@ import org.apache.lucene.index.DocValue* @see DocValues for further information* */-public class FloatDocValuesField extends Field {+public class FloatDocValuesField extends StoredField {+ /**+ * Type for 32-bit float DocValues.+ */public static final FieldType TYPE = new FieldType();static {TYPE.setDocValueType(DocValues.Type.FLOAT_32);diff --cc lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.javaindex 0193e6909b0,28914bce434..a06012cdb44--- a/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java+++ b/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java@@@ -35,8 -35,11 +35,11 @@@ import org.apache.lucene.index.DocValue* @see DocValues for further information* */-public class IntDocValuesField extends Field {+public class IntDocValuesField extends StoredField {+ /**+ * Type for 32-bit integer DocValues.+ */public static final FieldType TYPE = new FieldType();static {TYPE.setDocValueType(DocValues.Type.FIXED_INTS_32);diff --cc lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.javaindex 2a3f22caac1,e3484bd60a7..e0233318aa7--- a/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java+++ b/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java@@@ -35,8 -35,11 +35,11 @@@ import org.apache.lucene.index.DocValue* @see DocValues for further information* */-public class LongDocValuesField extends Field {+public class LongDocValuesField extends StoredField {+ /**+ * Type for 64-bit long DocValues.+ */public static final FieldType TYPE = new FieldType();static {TYPE.setDocValueType(DocValues.Type.FIXED_INTS_64);diff --cc lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.javaindex 401245295c0,8d3f2ba652f..93908dd15a2--- a/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java+++ b/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java@@@ -39,8 -39,11 +39,11 @@@ import org.apache.lucene.index.AtomicRe* @see DocValues for further information* */-public class PackedLongDocValuesField extends Field {+public class PackedLongDocValuesField extends StoredField {+ /**+ * Type for packed long DocValues.+ */public static final FieldType TYPE = new FieldType();static {TYPE.setDocValueType(DocValues.Type.VAR_INTS);diff --cc lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.javaindex 79c0bdee403,45dafc99664..cb338766083--- a/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java+++ b/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java@@@ -36,8 -36,11 +36,11 @@@ import org.apache.lucene.index.DocValue* @see DocValues for further information* */-public class ShortDocValuesField extends Field {+public class ShortDocValuesField extends StoredField {+ /**+ * Type for 16-bit short DocValues.+ */public static final FieldType TYPE = new FieldType();static {TYPE.setDocValueType(DocValues.Type.FIXED_INTS_16);diff --cc lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.javaindex f8e9ce991f7,594e26da733..a5ec57bff70--- a/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java+++ b/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java@@@ -37,9 -37,12 +37,12 @@@ import org.apache.lucene.util.BytesRef* @see DocValues for further information* */-public class SortedBytesDocValuesField extends Field {+public class SortedBytesDocValuesField extends StoredField {// TODO: ideally indexer figures out var vs fixed on its own!?+ /**+ * Type for sorted bytes DocValues: all with the same length+ */public static final FieldType TYPE_FIXED_LEN = new FieldType();static {TYPE_FIXED_LEN.setDocValueType(DocValues.Type.BYTES_FIXED_SORTED);diff --cc lucene/core/src/java/org/apache/lucene/document/StoredField.javaindex 4e340fd584f,6ffa81a8cce..95e536a13af--- a/lucene/core/src/java/org/apache/lucene/document/StoredField.java+++ b/lucene/core/src/java/org/apache/lucene/document/StoredField.java@@@ -25,8 -24,11 +25,11 @@@ import org.apache.lucene.util.BytesRef/** A field whose value is stored so that {@link* IndexSearcher#doc} and {@link IndexReader#document} will* return the field and its value. */-public final class StoredField extends Field {+public class StoredField extends Field {+ /**+ * Type for a stored-only field.+ */public final static FieldType TYPE;static {TYPE = new FieldType();@@@ -34,14 -36,14 +37,32 @@@TYPE.freeze();}+ /**+ * Create a stored-only field with the given binary value.+ * <p>NOTE: the provided byte[] is not copied so be sure+ * not to change it until you're done with this field.+ * @param name field name+ * @param value byte array pointing to binary content (not copied)+ * @throws IllegalArgumentException if the field name is null.+ */+ protected StoredField(String name, FieldType type) {+ super(name, type);+ }+++ /**++ * Expert: allows you to customize the {@link++ * FieldType}.++ * <p>NOTE: the provided byte[] is not copied so be sure++ * not to change it until you're done with this field.++ * @param name field name++ * @param value byte array pointing to binary content (not copied)++ * @param type custom {@link FieldType} for this field++ * @throws IllegalArgumentException if the field name is null.++ */+ public StoredField(String name, BytesRef bytes, FieldType type) {+ super(name, bytes, type);+ }+public StoredField(String name, byte[] value) {super(name, value, TYPE);}@@@ -57,12 -83,14 +102,18 @@@public StoredField(String name, String value) {super(name, value, TYPE);}++ public StoredField(String name, String value, FieldType type) {+ super(name, value, type);+ }// TODO: not great but maybe not a big problem?+ /**+ * Create a stored-only field with the given integer value.+ * @param name field name+ * @param value integer value+ * @throws IllegalArgumentException if the field name is null.+ */public StoredField(String name, int value) {super(name, TYPE);fieldsData = value;diff --cc lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.javaindex 3fc912ba5cd,cdca59b1c9e..f93d6b3e290--- a/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java+++ b/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java@@@ -40,9 -40,12 +40,12 @@@ import org.apache.lucene.util.BytesRef* @see DocValues for further information* */-public class StraightBytesDocValuesField extends Field {+public class StraightBytesDocValuesField extends StoredField {// TODO: ideally indexer figures out var vs fixed on its own!?+ /**+ * Type for direct bytes DocValues: all with the same length+ */public static final FieldType TYPE_FIXED_LEN = new FieldType();static {TYPE_FIXED_LEN.setDocValueType(DocValues.Type.BYTES_FIXED_STRAIGHT);diff --cc lucene/core/src/java/org/apache/lucene/index/IndexableField.javaindex ba8a84cc8a9,2df6f009a28..062dc8c427a--- a/lucene/core/src/java/org/apache/lucene/index/IndexableField.java+++ b/lucene/core/src/java/org/apache/lucene/index/IndexableField.java@@@ -33,19 -35,57 +35,38 @@@ import org.apache.lucene.util.BytesRef** @lucene.experimental */-public interface IndexableField {+public interface IndexableField extends GeneralField {- /** Field name */- public String name();+ /**+ * Creates the TokenStream used for indexing this field. If appropriate,+ * implementations should use the given Analyzer to create the TokenStreams.+ *+ * @param analyzer Analyzer that should be used to create the TokenStreams from+ * @return TokenStream value for indexing the document. Should always return+ * a non-null value if the field is to be indexed+ * @throws IOException Can be thrown while creating the TokenStream+ */+ public TokenStream tokenStream(Analyzer analyzer) throws IOException;- /** Field boost (you must pre-multiply in any doc boost). */- /** {@link IndexableFieldType} describing the properties- * of this field. */- public IndexableFieldType fieldType();-+ /**+ * Returns the field's index-time boost.+ * <p>+ * Only fields can have an index-time boost, if you want to simulate+ * a "document boost", then you must pre-multiply it across all the+ * relevant fields yourself.+ * <p>The boost is used to compute the norm factor for the field. By+ * default, in the {@link Similarity#computeNorm(FieldInvertState, Norm)} method,+ * the boost value is multiplied by the length normalization factor and then+ * rounded by {@link DefaultSimilarity#encodeNormValue(float)} before it is stored in the+ * index. One should attempt to ensure that this product does not overflow+ * the range of that encoding.+ * <p>+ * It is illegal to return a boost other than 1.0f for a field that is not+ * indexed ({@link IndexableFieldType#indexed()} is false) or omits normalization values+ * ({@link IndexableFieldType#omitNorms()} returns true).+ *+ * @see Similarity#computeNorm(FieldInvertState, Norm)+ * @see DefaultSimilarity#encodeNormValue(float)+ */public float boost();-- /** Non-null if this field has a binary value */- public BytesRef binaryValue();-- /** Non-null if this field has a string value */- public String stringValue();-- /** Non-null if this field has a Reader value */- public Reader readerValue();-- /** Non-null if this field has a numeric value */- public Number numericValue();-- /**- * Creates the TokenStream used for indexing this field. If appropriate,- * implementations should use the given Analyzer to create the TokenStreams.- *- * @param analyzer Analyzer that should be used to create the TokenStreams from- * @return TokenStream value for indexing the document. Should always return- * a non-null value if the field is to be indexed- * @throws IOException Can be thrown while creating the TokenStream- */- public TokenStream tokenStream(Analyzer analyzer) throws IOException;}diff --cc lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.javaindex 9ad21fcb5cb,91f2efe756f..6a7243135e8--- a/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java+++ b/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java@@@ -30,30 -31,69 +31,69 @@@ public interface IndexableFieldType/** True if the field's value should be stored */public boolean stored();-+- /** True if this field's value should be analyzed */+ /**+ * True if this field's value should be analyzed by the+ * {@link Analyzer}.+ * <p>+ * This has no effect if {@link #indexed()} returns false.+ */public boolean tokenized();- /** True if term vectors should be indexed */+ /**+ * True if this field's indexed form should be also stored+ * into term vectors.+ * <p>+ * This builds a miniature inverted-index for this field which+ * can be accessed in a document-oriented way from+ * {@link IndexReader#getTermVector(int,String)}.+ * <p>+ * This option is illegal if {@link #indexed()} returns false.+ */public boolean storeTermVectors();- /** True if term vector offsets should be indexed */+ /**+ * True if this field's token character offsets should also+ * be stored into term vectors.+ * <p>+ * This option is illegal if term vectors are not enabled for the field+ * ({@link #storeTermVectors()} is false)+ */public boolean storeTermVectorOffsets();- /** True if term vector positions should be indexed */+ /**+ * True if this field's token positions should also be stored+ * into the term vectors.+ * <p>+ * This option is illegal if term vectors are not enabled for the field+ * ({@link #storeTermVectors()} is false).+ */public boolean storeTermVectorPositions();- /** True if term vector payloads should be indexed */+ /**+ * True if this field's token payloads should also be stored+ * into the term vectors.+ * <p>+ * This option is illegal if term vector positions are not enabled+ * for the field ({@link #storeTermVectors()} is false).+ */public boolean storeTermVectorPayloads();- /** True if norms should not be indexed */+ /**+ * True if normalization values should be omitted for the field.+ * <p>+ * This saves memory, but at the expense of scoring quality (length normalization+ * will be disabled), and if you omit norms, you cannot use index-time boosts.+ */public boolean omitNorms();/** {@link IndexOptions}, describing what should be* recorded into the inverted index */public IndexOptions indexOptions();- /** DocValues type; if non-null then the field's value- * will be indexed into docValues */+ /**+ * DocValues {@link DocValues.Type}: if non-null then the field's value+ * will be indexed into docValues.+ */- public DocValues.Type docValueType();+ public DocValues.Type docValueType();}