You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2012/08/31 00:43:59 UTC
svn commit: r1379200 [4/11] - in /lucene/dev/branches/lucene3312: ./
dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/libraries/
dev-tools/maven/ dev-tools/maven/lucene/core/
dev-tools/maven/lucene/test-framework/ dev-tools/scripts/ lucene/
lucene/an...
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/FloatField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/FloatField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/FloatField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/FloatField.java Thu Aug 30 22:43:41 2012
@@ -114,6 +114,10 @@ import org.apache.lucene.util.NumericUti
public final class FloatField extends Field {
+ /**
+ * Type for a FloatField that is not stored:
+ * normalization factors, frequencies, and positions are omitted.
+ */
public static final FieldType TYPE_NOT_STORED = new FieldType();
static {
TYPE_NOT_STORED.setIndexed(true);
@@ -124,6 +128,10 @@ public final class FloatField extends Fi
TYPE_NOT_STORED.freeze();
}
+ /**
+ * Type for a stored FloatField:
+ * normalization factors, frequencies, and positions are omitted.
+ */
public static final FieldType TYPE_STORED = new FieldType();
static {
TYPE_STORED.setIndexed(true);
@@ -137,14 +145,26 @@ public final class FloatField extends Fi
/** Creates a stored or un-stored FloatField with the provided value
* and default <code>precisionStep</code> {@link
- * NumericUtils#PRECISION_STEP_DEFAULT} (4). */
+ * NumericUtils#PRECISION_STEP_DEFAULT} (4).
+ * @param name field name
+ * @param value 32-bit double value
+ * @param stored Store.YES if the content should also be stored
+ * @throws IllegalArgumentException if the field name is null.
+ */
public FloatField(String name, float value, Store stored) {
super(name, stored == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
fieldsData = Float.valueOf(value);
}
/** Expert: allows you to customize the {@link
- * FieldType}. */
+ * FieldType}.
+ * @param name field name
+ * @param value 32-bit float value
+ * @param type customized field type: must have {@link FieldType#numericType()}
+ * of {@link FieldType.NumericType#FLOAT}.
+ * @throws IllegalArgumentException if the field name or type is null, or
+ * if the field type does not have a FLOAT numericType()
+ */
public FloatField(String name, float value, FieldType type) {
super(name, type);
if (type.numericType() != FieldType.NumericType.FLOAT) {
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java Thu Aug 30 22:43:41 2012
@@ -37,12 +37,21 @@ import org.apache.lucene.index.DocValues
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);
TYPE.freeze();
}
+ /**
+ * Creates a new DocValues field with the specified 32-bit integer value
+ * @param name field name
+ * @param value 32-bit integer value
+ * @throws IllegalArgumentException if the field name is null
+ */
public IntDocValuesField(String name, int value) {
super(name, TYPE);
fieldsData = Integer.valueOf(value);
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/IntField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/IntField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/IntField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/IntField.java Thu Aug 30 22:43:41 2012
@@ -114,6 +114,10 @@ import org.apache.lucene.util.NumericUti
public final class IntField extends Field {
+ /**
+ * Type for an IntField that is not stored:
+ * normalization factors, frequencies, and positions are omitted.
+ */
public static final FieldType TYPE_NOT_STORED = new FieldType();
static {
TYPE_NOT_STORED.setIndexed(true);
@@ -124,6 +128,10 @@ public final class IntField extends Fiel
TYPE_NOT_STORED.freeze();
}
+ /**
+ * Type for a stored IntField:
+ * normalization factors, frequencies, and positions are omitted.
+ */
public static final FieldType TYPE_STORED = new FieldType();
static {
TYPE_STORED.setIndexed(true);
@@ -137,14 +145,26 @@ public final class IntField extends Fiel
/** Creates a stored or un-stored IntField with the provided value
* and default <code>precisionStep</code> {@link
- * NumericUtils#PRECISION_STEP_DEFAULT} (4). */
+ * NumericUtils#PRECISION_STEP_DEFAULT} (4).
+ * @param name field name
+ * @param value 32-bit integer value
+ * @param stored Store.YES if the content should also be stored
+ * @throws IllegalArgumentException if the field name is null.
+ */
public IntField(String name, int value, Store stored) {
super(name, stored == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
fieldsData = Integer.valueOf(value);
}
/** Expert: allows you to customize the {@link
- * FieldType}. */
+ * FieldType}.
+ * @param name field name
+ * @param value 32-bit integer value
+ * @param type customized field type: must have {@link FieldType#numericType()}
+ * of {@link FieldType.NumericType#INT}.
+ * @throws IllegalArgumentException if the field name or type is null, or
+ * if the field type does not have a INT numericType()
+ */
public IntField(String name, int value, FieldType type) {
super(name, type);
if (type.numericType() != FieldType.NumericType.INT) {
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java Thu Aug 30 22:43:41 2012
@@ -37,12 +37,21 @@ import org.apache.lucene.index.DocValues
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);
TYPE.freeze();
}
+ /**
+ * Creates a new DocValues field with the specified 64-bit long value
+ * @param name field name
+ * @param value 64-bit long value
+ * @throws IllegalArgumentException if the field name is null
+ */
public LongDocValuesField(String name, long value) {
super(name, TYPE);
fieldsData = Long.valueOf(value);
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/LongField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/LongField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/LongField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/LongField.java Thu Aug 30 22:43:41 2012
@@ -124,6 +124,10 @@ import org.apache.lucene.util.NumericUti
public final class LongField extends Field {
+ /**
+ * Type for a LongField that is not stored:
+ * normalization factors, frequencies, and positions are omitted.
+ */
public static final FieldType TYPE_NOT_STORED = new FieldType();
static {
TYPE_NOT_STORED.setIndexed(true);
@@ -134,6 +138,10 @@ public final class LongField extends Fie
TYPE_NOT_STORED.freeze();
}
+ /**
+ * Type for a stored LongField:
+ * normalization factors, frequencies, and positions are omitted.
+ */
public static final FieldType TYPE_STORED = new FieldType();
static {
TYPE_STORED.setIndexed(true);
@@ -147,14 +155,26 @@ public final class LongField extends Fie
/** Creates a stored or un-stored LongField with the provided value
* and default <code>precisionStep</code> {@link
- * NumericUtils#PRECISION_STEP_DEFAULT} (4). */
+ * NumericUtils#PRECISION_STEP_DEFAULT} (4).
+ * @param name field name
+ * @param value 64-bit long value
+ * @param stored Store.YES if the content should also be stored
+ * @throws IllegalArgumentException if the field name is null.
+ */
public LongField(String name, long value, Store stored) {
super(name, stored == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
fieldsData = Long.valueOf(value);
}
/** Expert: allows you to customize the {@link
- * FieldType}. */
+ * FieldType}.
+ * @param name field name
+ * @param value 64-bit long value
+ * @param type customized field type: must have {@link FieldType#numericType()}
+ * of {@link FieldType.NumericType#LONG}.
+ * @throws IllegalArgumentException if the field name or type is null, or
+ * if the field type does not have a LONG numericType()
+ */
public LongField(String name, long value, FieldType type) {
super(name, type);
if (type.numericType() != FieldType.NumericType.LONG) {
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java Thu Aug 30 22:43:41 2012
@@ -41,6 +41,9 @@ import org.apache.lucene.index.AtomicRea
public class PackedLongDocValuesField extends StoredField {
+ /**
+ * Type for packed long DocValues.
+ */
public static final FieldType TYPE = new FieldType();
static {
TYPE.setDocValueType(DocValues.Type.VAR_INTS);
@@ -48,6 +51,12 @@ public class PackedLongDocValuesField ex
TYPE.freeze();
}
+ /**
+ * Creates a new DocValues field with the specified long value
+ * @param name field name
+ * @param value 64-bit long value
+ * @throws IllegalArgumentException if the field name is null
+ */
public PackedLongDocValuesField(String name, long value) {
super(name, TYPE);
fieldsData = Long.valueOf(value);
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java Thu Aug 30 22:43:41 2012
@@ -38,12 +38,21 @@ import org.apache.lucene.index.DocValues
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);
TYPE.freeze();
}
+ /**
+ * Creates a new DocValues field with the specified 16-bit short value
+ * @param name field name
+ * @param value 16-bit short value
+ * @throws IllegalArgumentException if the field name is null
+ */
public ShortDocValuesField(String name, short value) {
super(name, TYPE);
fieldsData = Short.valueOf(value);
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java Thu Aug 30 22:43:41 2012
@@ -40,22 +40,47 @@ import org.apache.lucene.util.BytesRef;
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);
TYPE_FIXED_LEN.freeze();
}
+ /**
+ * Type for sorted bytes DocValues: can have variable lengths
+ */
public static final FieldType TYPE_VAR_LEN = new FieldType();
static {
TYPE_VAR_LEN.setDocValueType(DocValues.Type.BYTES_VAR_SORTED);
TYPE_VAR_LEN.freeze();
}
+ /**
+ * Create a new variable-length sorted DocValues field.
+ * <p>
+ * This calls
+ * {@link SortedBytesDocValuesField#SortedBytesDocValuesField(String, BytesRef, boolean)
+ * SortedBytesDocValuesField(name, bytes, false}, meaning by default
+ * it allows for values of different lengths. If your values are all
+ * the same length, use that constructor instead.
+ * @param name field name
+ * @param bytes binary content
+ * @throws IllegalArgumentException if the field name is null
+ */
public SortedBytesDocValuesField(String name, BytesRef bytes) {
this(name, bytes, false);
}
+ /**
+ * Create a new fixed or variable length sorted DocValues field.
+ * @param name field name
+ * @param bytes binary content
+ * @param isFixedLength true if all values have the same length.
+ * @throws IllegalArgumentException if the field name is null
+ */
public SortedBytesDocValuesField(String name, BytesRef bytes, boolean isFixedLength) {
super(name, isFixedLength ? TYPE_FIXED_LEN : TYPE_VAR_LEN);
fieldsData = bytes;
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/StoredField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/StoredField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/StoredField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/StoredField.java Thu Aug 30 22:43:41 2012
@@ -27,6 +27,9 @@ import org.apache.lucene.util.BytesRef;
* return the field and its value. */
public class StoredField extends Field {
+ /**
+ * Type for a stored-only field.
+ */
public final static FieldType TYPE;
static {
TYPE = new FieldType();
@@ -34,10 +37,28 @@ public class StoredField extends Field {
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);
}
@@ -46,14 +67,38 @@ public class StoredField extends Field {
super(name, value, TYPE);
}
+ /**
+ * 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)
+ * @param offset starting position of the byte array
+ * @param length valid length of the byte array
+ * @throws IllegalArgumentException if the field name is null.
+ */
public StoredField(String name, byte[] value, int offset, int length) {
super(name, value, offset, length, TYPE);
}
+ /**
+ * Create a stored-only field with the given binary value.
+ * <p>NOTE: the provided BytesRef is not copied so be sure
+ * not to change it until you're done with this field.
+ * @param name field name
+ * @param value BytesRef pointing to binary content (not copied)
+ * @throws IllegalArgumentException if the field name is null.
+ */
public StoredField(String name, BytesRef value) {
super(name, value, TYPE);
}
+ /**
+ * Create a stored-only field with the given string value.
+ * @param name field name
+ * @param value string value
+ * @throws IllegalArgumentException if the field name or value is null.
+ */
public StoredField(String name, String value) {
super(name, value, TYPE);
}
@@ -63,21 +108,45 @@ public class StoredField extends Field {
}
// 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;
}
+ /**
+ * Create a stored-only field with the given float value.
+ * @param name field name
+ * @param value float value
+ * @throws IllegalArgumentException if the field name is null.
+ */
public StoredField(String name, float value) {
super(name, TYPE);
fieldsData = value;
}
+ /**
+ * Create a stored-only field with the given long value.
+ * @param name field name
+ * @param value long value
+ * @throws IllegalArgumentException if the field name is null.
+ */
public StoredField(String name, long value) {
super(name, TYPE);
fieldsData = value;
}
+ /**
+ * Create a stored-only field with the given double value.
+ * @param name field name
+ * @param value double value
+ * @throws IllegalArgumentException if the field name is null.
+ */
public StoredField(String name, double value) {
super(name, TYPE);
fieldsData = value;
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java Thu Aug 30 22:43:41 2012
@@ -43,23 +43,49 @@ import org.apache.lucene.util.BytesRef;
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);
TYPE_FIXED_LEN.freeze();
}
+ /**
+ * Type for direct bytes DocValues: can have variable lengths
+ */
public static final FieldType TYPE_VAR_LEN = new FieldType();
static {
TYPE_VAR_LEN.setDocValueType(DocValues.Type.BYTES_VAR_STRAIGHT);
TYPE_VAR_LEN.freeze();
}
+ /**
+ * Create a new variable-length direct DocValues field.
+ * <p>
+ * This calls
+ * {@link StraightBytesDocValuesField#StraightBytesDocValuesField(String, BytesRef, boolean)
+ * StraightBytesDocValuesField(name, bytes, false}, meaning by default
+ * it allows for values of different lengths. If your values are all
+ * the same length, use that constructor instead.
+ * @param name field name
+ * @param bytes binary content
+ * @throws IllegalArgumentException if the field name is null
+ */
public StraightBytesDocValuesField(String name, BytesRef bytes) {
super(name, TYPE_VAR_LEN);
fieldsData = bytes;
}
+ /**
+ * Create a new fixed or variable length direct DocValues field.
+ * <p>
+ * @param name field name
+ * @param bytes binary content
+ * @param isFixedLength true if all values have the same length.
+ * @throws IllegalArgumentException if the field name is null
+ */
public StraightBytesDocValuesField(String name, BytesRef bytes, boolean isFixedLength) {
super(name, isFixedLength ? TYPE_FIXED_LEN : TYPE_VAR_LEN);
fieldsData = bytes;
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/StringField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/StringField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/StringField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/StringField.java Thu Aug 30 22:43:41 2012
@@ -50,7 +50,12 @@ public final class StringField extends F
TYPE_STORED.freeze();
}
- /** Creates a new StringField. */
+ /** Creates a new StringField.
+ * @param name field name
+ * @param value String value
+ * @param stored Store.YES if the content should also be stored
+ * @throws IllegalArgumentException if the field name or value is null.
+ */
public StringField(String name, String value, Store stored) {
super(name, value, stored == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
}
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/TextField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/TextField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/TextField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/document/TextField.java Thu Aug 30 22:43:41 2012
@@ -27,10 +27,10 @@ import org.apache.lucene.analysis.TokenS
public final class TextField extends Field {
- /* Indexed, tokenized, not stored. */
+ /** Indexed, tokenized, not stored. */
public static final FieldType TYPE_NOT_STORED = new FieldType();
- /* Indexed, tokenized, stored. */
+ /** Indexed, tokenized, stored. */
public static final FieldType TYPE_STORED = new FieldType();
static {
@@ -46,17 +46,32 @@ public final class TextField extends Fie
// TODO: add sugar for term vectors...?
- /** Creates a new un-stored TextField with Reader value. */
+ /** Creates a new un-stored TextField with Reader value.
+ * @param name field name
+ * @param reader reader value
+ * @throws IllegalArgumentException if the field name is null
+ * @throws NullPointerException if the reader is null
+ */
public TextField(String name, Reader reader) {
super(name, reader, TYPE_NOT_STORED);
}
- /** Creates a new TextField with String value. */
+ /** Creates a new TextField with String value.
+ * @param name field name
+ * @param value string value
+ * @param store Store.YES if the content should also be stored
+ * @throws IllegalArgumentException if the field name or value is null.
+ */
public TextField(String name, String value, Store store) {
super(name, value, store == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
}
- /** Creates a new un-stored TextField with TokenStream value. */
+ /** Creates a new un-stored TextField with TokenStream value.
+ * @param name field name
+ * @param stream TokenStream value
+ * @throws IllegalArgumentException if the field name is null.
+ * @throws NullPointerException if the tokenStream is null
+ */
public TextField(String name, TokenStream stream) {
super(name, stream, TYPE_NOT_STORED);
}
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java Thu Aug 30 22:43:41 2012
@@ -51,6 +51,7 @@ import org.apache.lucene.store.Directory
public abstract class DirectoryReader extends BaseCompositeReader<AtomicReader> {
public static final int DEFAULT_TERMS_INDEX_DIVISOR = 1;
+ /** The index directory. */
protected final Directory directory;
/** Returns a IndexReader reading the index in the given
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FieldInfo.java Thu Aug 30 22:43:41 2012
@@ -31,7 +31,9 @@ import org.apache.lucene.index.DocValues
**/
public final class FieldInfo {
+ /** Field's name */
public final String name;
+ /** Internal field number */
public final int number;
private boolean indexed;
@@ -55,14 +57,29 @@ public final class FieldInfo {
// NOTE: order is important here; FieldInfo uses this
// order to merge two conflicting IndexOptions (always
// "downgrades" by picking the lowest).
- /** only documents are indexed: term frequencies and positions are omitted */
+ /**
+ * Only documents are indexed: term frequencies and positions are omitted.
+ * Phrase and other positional queries on the field will throw an exception, and scoring
+ * will behave as if any term in the document appears only once.
+ */
// TODO: maybe rename to just DOCS?
DOCS_ONLY,
- /** only documents and term frequencies are indexed: positions are omitted */
+ /**
+ * Only documents and term frequencies are indexed: positions are omitted.
+ * This enables normal scoring, except Phrase and other positional queries
+ * will throw an exception.
+ */
DOCS_AND_FREQS,
- /** documents, frequencies and positions */
+ /**
+ * Indexes documents, frequencies and positions.
+ * This is a typical default for full-text search: full scoring is enabled
+ * and positional queries are supported.
+ */
DOCS_AND_FREQS_AND_POSITIONS,
- /** documents, frequencies, positions and offsets */
+ /**
+ * Indexes documents, frequencies, positions and offsets.
+ * Character offsets are encoded alongside the positions.
+ */
DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS,
};
@@ -149,27 +166,27 @@ public final class FieldInfo {
assert checkConsistency();
}
- /** @return IndexOptions for the field, or null if the field is not indexed */
+ /** Returns IndexOptions for the field, or null if the field is not indexed */
public IndexOptions getIndexOptions() {
return indexOptions;
}
/**
- * @return true if this field has any docValues.
+ * Returns true if this field has any docValues.
*/
public boolean hasDocValues() {
return docValueType != null;
}
/**
- * @return {@link DocValues.Type} of the docValues. this may be null if the field has no docvalues.
+ * Returns {@link DocValues.Type} of the docValues. this may be null if the field has no docvalues.
*/
public DocValues.Type getDocValuesType() {
return docValueType;
}
/**
- * @return {@link DocValues.Type} of the norm. this may be null if the field has no norms.
+ * Returns {@link DocValues.Type} of the norm. this may be null if the field has no norms.
*/
public DocValues.Type getNormType() {
return normType;
@@ -193,35 +210,35 @@ public final class FieldInfo {
}
/**
- * @return true if norms are explicitly omitted for this field
+ * Returns true if norms are explicitly omitted for this field
*/
public boolean omitsNorms() {
return omitNorms;
}
/**
- * @return true if this field actually has any norms.
+ * Returns true if this field actually has any norms.
*/
public boolean hasNorms() {
return normType != null;
}
/**
- * @return true if this field is indexed.
+ * Returns true if this field is indexed.
*/
public boolean isIndexed() {
return indexed;
}
/**
- * @return true if any payloads exist for this field.
+ * Returns true if any payloads exist for this field.
*/
public boolean hasPayloads() {
return storePayloads;
}
/**
- * @return true if any term vectors exist for this field.
+ * Returns true if any term vectors exist for this field.
*/
public boolean hasVectors() {
return storeTermVector;
@@ -256,7 +273,7 @@ public final class FieldInfo {
}
/**
- * @return internal codec attributes map. May be null if no mappings exist.
+ * Returns internal codec attributes map. May be null if no mappings exist.
*/
public Map<String,String> attributes() {
return attributes;
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java Thu Aug 30 22:43:41 2012
@@ -44,6 +44,9 @@ public class FieldInfos implements Itera
private final HashMap<String,FieldInfo> byName = new HashMap<String,FieldInfo>();
private final Collection<FieldInfo> values; // for an unmodifiable iterator
+ /**
+ * Constructs a new FieldInfos from an array of FieldInfo objects
+ */
public FieldInfos(FieldInfo[] infos) {
boolean hasVectors = false;
boolean hasProx = false;
@@ -98,30 +101,22 @@ public class FieldInfos implements Itera
return hasOffsets;
}
- /**
- * @return true if at least one field has any vectors
- */
+ /** Returns true if any fields have vectors */
public boolean hasVectors() {
return hasVectors;
}
- /**
- * @return true if at least one field has any norms
- */
+ /** Returns true if any fields have norms */
public boolean hasNorms() {
return hasNorms;
}
- /**
- * @return true if at least one field has doc values
- */
+ /** Returns true if any fields have DocValues */
public boolean hasDocValues() {
return hasDocValues;
}
- /**
- * @return number of fields
- */
+ /** Returns the number of fields */
public int size() {
assert byNumber.size() == byName.size();
return byNumber.size();
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FilterAtomicReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FilterAtomicReader.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FilterAtomicReader.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FilterAtomicReader.java Thu Aug 30 22:43:41 2012
@@ -40,8 +40,13 @@ public class FilterAtomicReader extends
/** Base class for filtering {@link Fields}
* implementations. */
public static class FilterFields extends Fields {
+ /** The underlying Fields instance. */
protected final Fields in;
+ /**
+ * Creates a new FilterFields.
+ * @param in the underlying Fields instance.
+ */
public FilterFields(Fields in) {
this.in = in;
}
@@ -65,8 +70,13 @@ public class FilterAtomicReader extends
/** Base class for filtering {@link Terms}
* implementations. */
public static class FilterTerms extends Terms {
+ /** The underlying Terms instance. */
protected final Terms in;
+ /**
+ * Creates a new FilterTerms
+ * @param in the underlying Terms instance.
+ */
public FilterTerms(Terms in) {
this.in = in;
}
@@ -124,8 +134,13 @@ public class FilterAtomicReader extends
/** Base class for filtering {@link TermsEnum} implementations. */
public static class FilterTermsEnum extends TermsEnum {
+ /** The underlying TermsEnum instance. */
protected final TermsEnum in;
+ /**
+ * Creates a new FilterTermsEnum
+ * @param in the underlying TermsEnum instance.
+ */
public FilterTermsEnum(TermsEnum in) { this.in = in; }
@Override
@@ -201,8 +216,13 @@ public class FilterAtomicReader extends
/** Base class for filtering {@link DocsEnum} implementations. */
public static class FilterDocsEnum extends DocsEnum {
+ /** The underlying DocsEnum instance. */
protected final DocsEnum in;
+ /**
+ * Create a new FilterDocsEnum
+ * @param in the underlying DocsEnum instance.
+ */
public FilterDocsEnum(DocsEnum in) {
this.in = in;
}
@@ -235,8 +255,13 @@ public class FilterAtomicReader extends
/** Base class for filtering {@link DocsAndPositionsEnum} implementations. */
public static class FilterDocsAndPositionsEnum extends DocsAndPositionsEnum {
+ /** The underlying DocsAndPositionsEnum instance. */
protected final DocsAndPositionsEnum in;
+ /**
+ * Create a new FilterDocsAndPositionsEnum
+ * @param in the underlying DocsAndPositionsEnum instance.
+ */
public FilterDocsAndPositionsEnum(DocsAndPositionsEnum in) {
this.in = in;
}
@@ -287,6 +312,7 @@ public class FilterAtomicReader extends
}
}
+ /** The underlying AtomicReader. */
protected final AtomicReader in;
/**
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FilteredTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FilteredTermsEnum.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FilteredTermsEnum.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/FilteredTermsEnum.java Thu Aug 30 22:43:41 2012
@@ -48,7 +48,20 @@ public abstract class FilteredTermsEnum
* the enum should call {@link #nextSeekTerm} and step forward.
* @see #accept(BytesRef)
*/
- protected static enum AcceptStatus {YES, YES_AND_SEEK, NO, NO_AND_SEEK, END};
+ protected static enum AcceptStatus {
+ /** Accept the term and position the enum at the next term. */
+ YES,
+ /** Accept the term and advance ({@link FilteredTermsEnum#nextSeekTerm(BytesRef)})
+ * to the next term. */
+ YES_AND_SEEK,
+ /** Reject the term and position the enum at the next term. */
+ NO,
+ /** Reject the term and advance ({@link FilteredTermsEnum#nextSeekTerm(BytesRef)})
+ * to the next term. */
+ NO_AND_SEEK,
+ /** Reject the term and stop enumerating. */
+ END
+ };
/** Return if term is accepted, not accepted or the iteration should ended
* (and possibly seek).
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexFileNames.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexFileNames.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexFileNames.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexFileNames.java Thu Aug 30 22:43:41 2012
@@ -40,6 +40,9 @@ import org.apache.lucene.codecs.Codec;
*/
public final class IndexFileNames {
+
+ /** No instance */
+ private IndexFileNames() {}
/** Name of the index segment file */
public static final String SEGMENTS = "segments";
@@ -184,6 +187,10 @@ public final class IndexFileNames {
return filename;
}
+ /**
+ * Removes the extension (anything after the first '.'),
+ * otherwise returns the original filename.
+ */
public static String stripExtension(String filename) {
int idx = filename.indexOf('.');
if (idx != -1) {
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexReader.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexReader.java Thu Aug 30 22:43:41 2012
@@ -243,7 +243,8 @@ public abstract class IndexReader implem
}
/**
- * @throws AlreadyClosedException if this IndexReader is closed
+ * Throws AlreadyClosedException if this IndexReader or any
+ * of its child readers is closed, otherwise returns.
*/
protected final void ensureOpen() throws AlreadyClosedException {
if (refCount.get() <= 0) {
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java Thu Aug 30 22:43:41 2012
@@ -549,6 +549,14 @@ public class IndexWriter implements Clos
}
}
+ /**
+ * Used internally to throw an {@link
+ * AlreadyClosedException} if this IndexWriter has been
+ * closed.
+ * <p>
+ * Calls {@link #ensureOpen(boolean) ensureOpen(true)}.
+ * @throws AlreadyClosedException if this IndexWriter is closed
+ */
protected final void ensureOpen() throws AlreadyClosedException {
ensureOpen(true);
}
@@ -1030,6 +1038,9 @@ public class IndexWriter implements Clos
return count;
}
+ /**
+ * Returns true if this index has deletions (including buffered deletions).
+ */
public synchronized boolean hasDeletions() {
ensureOpen();
if (bufferedDeletesStream.any()) {
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexableField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexableField.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexableField.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexableField.java Thu Aug 30 22:43:41 2012
@@ -22,6 +22,8 @@ import java.io.Reader;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.search.similarities.DefaultSimilarity; // javadocs
+import org.apache.lucene.search.similarities.Similarity; // javadocs
import org.apache.lucene.util.BytesRef;
// TODO: how to handle versioning here...?
@@ -46,6 +48,25 @@ public interface IndexableField extends
*/
public TokenStream tokenStream(Analyzer analyzer) throws IOException;
- /** Field boost (you must pre-multiply in any doc boost). */
+ /**
+ * 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();
}
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java Thu Aug 30 22:43:41 2012
@@ -17,6 +17,7 @@ package org.apache.lucene.index;
* limitations under the License.
*/
+import org.apache.lucene.analysis.Analyzer; // javadocs
import org.apache.lucene.index.FieldInfo.IndexOptions;
/**
@@ -31,29 +32,68 @@ 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();
}
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/MultiFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/MultiFields.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/MultiFields.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/MultiFields.java Thu Aug 30 22:43:41 2012
@@ -89,6 +89,15 @@ public final class MultiFields extends F
}
}
+ /** Returns a single {@link Bits} instance for this
+ * reader, merging live Documents on the
+ * fly. This method will return null if the reader
+ * has no deletions.
+ *
+ * <p><b>NOTE</b>: this is a very slow way to access live docs.
+ * For example, each Bits access will require a binary search.
+ * It's better to get the sub-readers and iterate through them
+ * yourself. */
public static Bits getLiveDocs(IndexReader reader) {
if (reader.hasDeletions()) {
final List<AtomicReaderContext> leaves = reader.leaves();
@@ -176,6 +185,11 @@ public final class MultiFields extends F
return null;
}
+ /**
+ * Expert: construct a new MultiFields instance directly.
+ * @lucene.internal
+ */
+ // TODO: why is this public?
public MultiFields(Fields[] subs, ReaderSlice[] subSlices) {
this.subs = subs;
this.subSlices = subSlices;
@@ -229,6 +243,14 @@ public final class MultiFields extends F
return -1;
}
+ /** Returns the total number of occurrences of this term
+ * across all documents (the sum of the freq() for each
+ * doc that has this term). This will be -1 if the
+ * codec doesn't support this measure. Note that, like
+ * other term measures, this measure does not take
+ * deleted documents into account.
+ * @see TermsEnum#totalTermFreq()
+ */
public static long totalTermFreq(IndexReader r, String field, BytesRef text) throws IOException {
final Terms terms = getTerms(r, field);
if (terms != null) {
@@ -256,6 +278,14 @@ public final class MultiFields extends F
return builder.finish();
}
+ /** Call this to get the (merged) FieldInfos representing the
+ * set of indexed fields <b>only</b> for a composite reader.
+ * <p>
+ * NOTE: the returned field numbers will likely not
+ * correspond to the actual field numbers in the underlying
+ * readers, and codec metadata ({@link FieldInfo#getAttribute(String)}
+ * will be unavailable.
+ */
public static Collection<String> getIndexedFields(IndexReader reader) {
final Collection<String> fields = new HashSet<String>();
for(final FieldInfo fieldInfo : getMergedFieldInfos(reader)) {
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java Thu Aug 30 22:43:41 2012
@@ -165,7 +165,6 @@ public final class SegmentInfo {
return Collections.unmodifiableSet(setFiles);
}
- /** {@inheritDoc} */
@Override
public String toString() {
return toString(dir, 0);
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/SegmentInfoPerCommit.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/SegmentInfoPerCommit.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/SegmentInfoPerCommit.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/SegmentInfoPerCommit.java Thu Aug 30 22:43:41 2012
@@ -97,15 +97,25 @@ public class SegmentInfoPerCommit {
sizeInBytes = -1;
}
+ /**
+ * Sets the generation number of the live docs file.
+ * @see #getDelGen()
+ */
public void setDelGen(long delGen) {
this.delGen = delGen;
sizeInBytes = -1;
}
+ /** Returns true if there are any deletions for the
+ * segment at this commit. */
public boolean hasDeletions() {
return delGen != -1;
}
+ /**
+ * Returns the next available generation number
+ * of the live docs file.
+ */
public long getNextDelGen() {
if (delGen == -1) {
return 1;
@@ -114,10 +124,17 @@ public class SegmentInfoPerCommit {
}
}
+ /**
+ * Returns generation number of the live docs file
+ * or -1 if there are no deletes yet.
+ */
public long getDelGen() {
return delGen;
}
+ /**
+ * Returns the number of deleted docs in the segment.
+ */
public int getDelCount() {
return delCount;
}
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/SegmentReader.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/SegmentReader.java Thu Aug 30 22:43:41 2012
@@ -47,9 +47,11 @@ public final class SegmentReader extends
final SegmentCoreReaders core;
/**
+ * Constructs a new SegmentReader with a new core.
* @throws CorruptIndexException if the index is corrupt
* @throws IOException if there is a low-level IO error
*/
+ // TODO: why is this public?
public SegmentReader(SegmentInfoPerCommit si, int termInfosIndexDivisor, IOContext context) throws IOException {
this.si = si;
core = new SegmentCoreReaders(this, si.info.dir, si, context, termInfosIndexDivisor);
@@ -76,19 +78,19 @@ public final class SegmentReader extends
}
}
- // Create new SegmentReader sharing core from a previous
- // SegmentReader and loading new live docs from a new
- // deletes file. Used by openIfChanged.
+ /** Create new SegmentReader sharing core from a previous
+ * SegmentReader and loading new live docs from a new
+ * deletes file. Used by openIfChanged. */
SegmentReader(SegmentInfoPerCommit si, SegmentCoreReaders core, IOContext context) throws IOException {
this(si, core,
si.info.getCodec().liveDocsFormat().readLiveDocs(si.info.dir, si, context),
si.info.getDocCount() - si.getDelCount());
}
- // Create new SegmentReader sharing core from a previous
- // SegmentReader and using the provided in-memory
- // liveDocs. Used by IndexWriter to provide a new NRT
- // reader:
+ /** Create new SegmentReader sharing core from a previous
+ * SegmentReader and using the provided in-memory
+ * liveDocs. Used by IndexWriter to provide a new NRT
+ * reader */
SegmentReader(SegmentInfoPerCommit si, SegmentCoreReaders core, Bits liveDocs, int numDocs) {
this.si = si;
this.core = core;
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/Term.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/Term.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/Term.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/Term.java Thu Aug 30 22:43:41 2012
@@ -132,8 +132,4 @@ public final class Term implements Compa
@Override
public final String toString() { return field + ":" + bytes.utf8ToString(); }
-
- public Term deepCopyOf() {
- return new Term(field, BytesRef.deepCopyOf(bytes));
- }
}
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java Thu Aug 30 22:43:41 2012
@@ -51,12 +51,15 @@ public abstract class TermsEnum implemen
return atts;
}
- /** Represents returned result from {@link #seekCeil}.
- * If status is FOUND, then the precise term was found.
- * If status is NOT_FOUND, then a different term was
- * found. If the status is END, the end of the iteration
- * was hit. */
- public static enum SeekStatus {END, FOUND, NOT_FOUND};
+ /** Represents returned result from {@link #seekCeil}. */
+ public static enum SeekStatus {
+ /** The term was not found, and the end of iteration was hit. */
+ END,
+ /** The precise term was found. */
+ FOUND,
+ /** A different term was found after the requested term */
+ NOT_FOUND
+ };
/** Attempts to seek to the exact term, returning
* true if the term is found. If this returns false, the
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommitTool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommitTool.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommitTool.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/index/TwoPhaseCommitTool.java Thu Aug 30 22:43:41 2012
@@ -27,6 +27,9 @@ import java.util.Map;
* @lucene.experimental
*/
public final class TwoPhaseCommitTool {
+
+ /** No instance */
+ private TwoPhaseCommitTool() {}
/**
* A wrapper of a {@link TwoPhaseCommit}, which delegates all calls to the
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java Thu Aug 30 22:43:41 2012
@@ -61,7 +61,7 @@ public class DisjunctionMaxQuery extends
/**
* Creates a new DisjunctionMaxQuery
- * @param disjuncts a Collection<Query> of all the disjuncts to add
+ * @param disjuncts a {@code Collection<Query>} of all the disjuncts to add
* @param tieBreakerMultiplier the weight to give to each matching non-maximum disjunct
*/
public DisjunctionMaxQuery(Collection<Query> disjuncts, float tieBreakerMultiplier) {
@@ -77,14 +77,14 @@ public class DisjunctionMaxQuery extends
}
/** Add a collection of disjuncts to this disjunction
- * via Iterable<Query>
+ * via {@code Iterable<Query>}
* @param disjuncts a collection of queries to add as disjuncts.
*/
public void add(Collection<Query> disjuncts) {
this.disjuncts.addAll(disjuncts);
}
- /** @return An Iterator<Query> over the disjuncts */
+ /** @return An {@code Iterator<Query>} over the disjuncts */
public Iterator<Query> iterator() {
return disjuncts.iterator();
}
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/DocIdSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/DocIdSet.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/DocIdSet.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/DocIdSet.java Thu Aug 30 22:43:41 2012
@@ -72,7 +72,7 @@ public abstract class DocIdSet {
* external disk access (as {@link Bits} interface cannot throw
* {@link IOException}). This is generally true for bit sets
* like {@link org.apache.lucene.util.FixedBitSet}, which return
- * itsself if they are used as {@code DocIdSet}.
+ * itself if they are used as {@code DocIdSet}.
*/
public Bits bits() throws IOException {
return null;
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/NumericRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/NumericRangeQuery.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/NumericRangeQuery.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/NumericRangeQuery.java Thu Aug 30 22:43:41 2012
@@ -289,7 +289,7 @@ public final class NumericRangeQuery<T e
@Override @SuppressWarnings("unchecked")
protected TermsEnum getTermsEnum(final Terms terms, AttributeSource atts) throws IOException {
- // very strange: java.lang.Number itsself is not Comparable, but all subclasses used here are
+ // very strange: java.lang.Number itself is not Comparable, but all subclasses used here are
if (min != null && max != null && ((Comparable<T>) min).compareTo(max) > 0) {
return TermsEnum.EMPTY;
}
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/Scorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/Scorer.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/Scorer.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/Scorer.java Thu Aug 30 22:43:41 2012
@@ -113,13 +113,26 @@ public abstract class Scorer extends Doc
return Collections.emptyList();
}
- /** a child Scorer and its relationship to its parent.
+ /** A child Scorer and its relationship to its parent.
* the meaning of the relationship depends upon the parent query.
* @lucene.experimental */
public static class ChildScorer {
+ /**
+ * Child Scorer. (note this is typically a direct child, and may
+ * itself also have children).
+ */
public final Scorer child;
+ /**
+ * An arbitrary string relating this scorer to the parent.
+ */
public final String relationship;
+ /**
+ * Creates a new ChildScorer node with the specified relationship.
+ * <p>
+ * The relationship can be any be any string that makes sense to
+ * the parent Scorer.
+ */
public ChildScorer(Scorer child, String relationship) {
this.child = child;
this.relationship = relationship;
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java Thu Aug 30 22:43:41 2012
@@ -1,9 +1,5 @@
package org.apache.lucene.search.similarities;
-import org.apache.lucene.index.FieldInvertState;
-import org.apache.lucene.index.Norm;
-import org.apache.lucene.util.BytesRef;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -21,6 +17,10 @@ import org.apache.lucene.util.BytesRef;
* limitations under the License.
*/
+import org.apache.lucene.index.FieldInvertState;
+import org.apache.lucene.index.Norm;
+import org.apache.lucene.util.BytesRef;
+
/** Expert: Default scoring implementation. */
public class DefaultSimilarity extends TFIDFSimilarity {
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexInput.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexInput.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexInput.java Thu Aug 30 22:43:41 2012
@@ -21,7 +21,7 @@ import java.io.IOException;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
-/** Writes bytes through to a primary IndexOutput, computing
+/** Reads bytes through to a primary IndexInput, computing
* checksum as it goes. Note that you cannot use seek().
*
* @lucene.internal
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/store/Directory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/store/Directory.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/store/Directory.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/store/Directory.java Thu Aug 30 22:43:41 2012
@@ -187,7 +187,7 @@ public abstract class Directory implemen
* }
* </pre>
* <p>
- * <b>NOTE:</b> this method does not check whether <i>dest<i> exist and will
+ * <b>NOTE:</b> this method does not check whether <i>dest</i> exist and will
* overwrite it if it does.
*/
public void copy(Directory to, String src, String dest, IOContext context) throws IOException {
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/Constants.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/Constants.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/Constants.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/Constants.java Thu Aug 30 22:43:41 2012
@@ -33,10 +33,10 @@ public final class Constants {
public static final String JVM_VERSION = System.getProperty("java.vm.version");
public static final String JVM_NAME = System.getProperty("java.vm.name");
- /** The value of <tt>System.getProperty("java.version")<tt>. **/
+ /** The value of <tt>System.getProperty("java.version")</tt>. **/
public static final String JAVA_VERSION = System.getProperty("java.version");
- /** The value of <tt>System.getProperty("os.name")<tt>. **/
+ /** The value of <tt>System.getProperty("os.name")</tt>. **/
public static final String OS_NAME = System.getProperty("os.name");
/** True iff running on Linux. */
public static final boolean LINUX = OS_NAME.startsWith("Linux");
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/IOUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/IOUtils.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/IOUtils.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/IOUtils.java Thu Aug 30 22:43:41 2012
@@ -98,7 +98,9 @@ public final class IOUtils {
}
}
- /** @see #closeWhileHandlingException(Exception, Closeable...) */
+ /**
+ * Closes all given <tt>Closeable</tt>s, suppressing all thrown exceptions.
+ * @see #closeWhileHandlingException(Exception, Closeable...) */
public static <E extends Exception> void closeWhileHandlingException(E priorException, Iterable<? extends Closeable> objects) throws E, IOException {
Throwable th = null;
@@ -160,6 +162,7 @@ public final class IOUtils {
}
/**
+ * Closes all given <tt>Closeable</tt>s.
* @see #close(Closeable...)
*/
public static void close(Iterable<? extends Closeable> objects) throws IOException {
@@ -205,6 +208,7 @@ public final class IOUtils {
}
/**
+ * Closes all given <tt>Closeable</tt>s, suppressing all thrown exceptions.
* @see #closeWhileHandlingException(Closeable...)
*/
public static void closeWhileHandlingException(Iterable<? extends Closeable> objects) {
@@ -322,6 +326,11 @@ public final class IOUtils {
}
}
+ /**
+ * Deletes all given files, suppressing all thrown IOExceptions.
+ * <p>
+ * Note that the files should not be null.
+ */
public static void deleteFilesIgnoringExceptions(Directory dir, String... files) {
for (String name : files) {
try {
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java Thu Aug 30 22:43:41 2012
@@ -103,7 +103,7 @@ public abstract class PriorityQueue<T> {
*
* <pre>
* // extends getSentinelObject() to return a non-null value.
- * PriorityQueue<MyObject> pq = new MyQueue<MyObject>(numHits);
+ * PriorityQueue<MyObject> pq = new MyQueue<MyObject>(numHits);
* // save the 'top' element, which is guaranteed to not be null.
* MyObject pqTop = pq.top();
* <...>
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/SmallFloat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/SmallFloat.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/SmallFloat.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/SmallFloat.java Thu Aug 30 22:43:41 2012
@@ -21,6 +21,9 @@ package org.apache.lucene.util;
* @lucene.internal
*/
public class SmallFloat {
+
+ /** No instance */
+ private SmallFloat() {}
/** Converts a 32 bit float to an 8 bit float.
* <br>Values less than zero are all mapped to zero.
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/WeakIdentityMap.java Thu Aug 30 22:43:41 2012
@@ -65,35 +65,51 @@ public final class WeakIdentityMap<K,V>
this.backingStore = backingStore;
}
+ /** Removes all of the mappings from this map. */
public void clear() {
backingStore.clear();
reap();
}
+ /** Returns {@code true} if this map contains a mapping for the specified key. */
public boolean containsKey(Object key) {
reap();
return backingStore.containsKey(new IdentityWeakReference(key, null));
}
+ /** Returns the value to which the specified key is mapped. */
public V get(Object key) {
reap();
return backingStore.get(new IdentityWeakReference(key, null));
}
+ /** Associates the specified value with the specified key in this map.
+ * If the map previously contained a mapping for this key, the old value
+ * is replaced. */
public V put(K key, V value) {
reap();
return backingStore.put(new IdentityWeakReference(key, queue), value);
}
+ /** Returns {@code true} if this map contains no key-value mappings. */
public boolean isEmpty() {
return size() == 0;
}
+ /** Removes the mapping for a key from this weak hash map if it is present.
+ * Returns the value to which this map previously associated the key,
+ * or {@code null} if the map contained no mapping for the key.
+ * A return value of {@code null} does not necessarily indicate that
+ * the map contained.*/
public V remove(Object key) {
reap();
return backingStore.remove(new IdentityWeakReference(key, null));
}
+ /** Returns the number of key-value mappings in this map. This result is a snapshot,
+ * and may not reflect unprocessed entries that will be removed before next
+ * attempted access because they are no longer referenced.
+ */
public int size() {
if (backingStore.isEmpty())
return 0;
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/fst/Util.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/fst/Util.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/fst/Util.java Thu Aug 30 22:43:41 2012
@@ -89,7 +89,7 @@ public final class Util {
* pair where the output is equal to the target, and will
* return null if that output does not exist.
*
- * <p>NOTE: this only works with FST<Long>, only
+ * <p>NOTE: this only works with {@code FST<Long>}, only
* works when the outputs are ascending in order with
* the inputs and only works when you shared
* the outputs (pass doShare=true to {@link
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/hash/HashFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/hash/HashFunction.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/hash/HashFunction.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/hash/HashFunction.java Thu Aug 30 22:43:41 2012
@@ -1,84 +1,84 @@
-package org.apache.lucene.util.hash;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.util.Set;
-
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.NamedSPILoader;
-
-
-/**
- * Base class for hashing functions that can be referred to by name.
- * Subclasses are expected to provide threadsafe implementations of the hash function
- * on the range of bytes referenced in the provided {@link BytesRef}
- * @lucene.experimental
- */
-public abstract class HashFunction implements NamedSPILoader.NamedSPI {
-
- /**
- * Hashes the contents of the referenced bytes
- * @param bytes the data to be hashed
- * @return the hash of the bytes referenced by bytes.offset and length bytes.length
- */
- public abstract int hash(BytesRef bytes);
-
- private static final NamedSPILoader<HashFunction> loader =
- new NamedSPILoader<HashFunction>(HashFunction.class);
-
- private final String name;
-
- public HashFunction(String name) {
- NamedSPILoader.checkServiceName(name);
- this.name = name;
- }
-
- /** Returns this codec's name */
- @Override
- public final String getName() {
- return name;
- }
-
- /** looks up a hash function by name */
- public static HashFunction forName(String name) {
- return loader.lookup(name);
- }
-
- /** returns a list of all available hash function names */
- public static Set<String> availableHashFunctionNames() {
- return loader.availableServices();
- }
-
- /**
- * Reloads the hash function list from the given {@link ClassLoader}.
- * Changes to the function list are visible after the method ends, all
- * iterators ({@link #availableHashFunctionNames()},...) stay consistent.
- *
- * <p><b>NOTE:</b> Only new functions are added, existing ones are
- * never removed or replaced.
- *
- * <p><em>This method is expensive and should only be called for discovery
- * of new functions on the given classpath/classloader!</em>
- */
- public static void reloadHashFunctions(ClassLoader classloader) {
- loader.reload(classloader);
- }
-
- @Override
- public String toString() {
- return name;
- }
-}
+package org.apache.lucene.util.hash;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.Set;
+
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.NamedSPILoader;
+
+
+/**
+ * Base class for hashing functions that can be referred to by name.
+ * Subclasses are expected to provide threadsafe implementations of the hash function
+ * on the range of bytes referenced in the provided {@link BytesRef}
+ * @lucene.experimental
+ */
+public abstract class HashFunction implements NamedSPILoader.NamedSPI {
+
+ /**
+ * Hashes the contents of the referenced bytes
+ * @param bytes the data to be hashed
+ * @return the hash of the bytes referenced by bytes.offset and length bytes.length
+ */
+ public abstract int hash(BytesRef bytes);
+
+ private static final NamedSPILoader<HashFunction> loader =
+ new NamedSPILoader<HashFunction>(HashFunction.class);
+
+ private final String name;
+
+ public HashFunction(String name) {
+ NamedSPILoader.checkServiceName(name);
+ this.name = name;
+ }
+
+ /** Returns this codec's name */
+ @Override
+ public final String getName() {
+ return name;
+ }
+
+ /** looks up a hash function by name */
+ public static HashFunction forName(String name) {
+ return loader.lookup(name);
+ }
+
+ /** returns a list of all available hash function names */
+ public static Set<String> availableHashFunctionNames() {
+ return loader.availableServices();
+ }
+
+ /**
+ * Reloads the hash function list from the given {@link ClassLoader}.
+ * Changes to the function list are visible after the method ends, all
+ * iterators ({@link #availableHashFunctionNames()},...) stay consistent.
+ *
+ * <p><b>NOTE:</b> Only new functions are added, existing ones are
+ * never removed or replaced.
+ *
+ * <p><em>This method is expensive and should only be called for discovery
+ * of new functions on the given classpath/classloader!</em>
+ */
+ public static void reloadHashFunctions(ClassLoader classloader) {
+ loader.reload(classloader);
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
Modified: lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/hash/MurmurHash2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/hash/MurmurHash2.java?rev=1379200&r1=1379199&r2=1379200&view=diff
==============================================================================
--- lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/hash/MurmurHash2.java (original)
+++ lucene/dev/branches/lucene3312/lucene/core/src/java/org/apache/lucene/util/hash/MurmurHash2.java Thu Aug 30 22:43:41 2012
@@ -1,105 +1,105 @@
-package org.apache.lucene.util.hash;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.lucene.util.BytesRef;
-
-/**
- * This is a very fast, non-cryptographic hash suitable for general hash-based
- * lookup. See http://murmurhash.googlepages.com/ for more details.
- * <p>
- * The C version of MurmurHash 2.0 found at that site was ported to Java by
- * Andrzej Bialecki (ab at getopt org).
- * </p>
- * <p>
- * The code from getopt.org was adapted by Mark Harwood in the form here as one of a pluggable choice of
- * hashing functions as the core function had to be adapted to work with BytesRefs with offsets and lengths
- * rather than raw byte arrays.
- * </p>
- * @lucene.experimental
- */
-public class MurmurHash2 extends HashFunction{
-
-
- public static final String HASH_NAME="MurmurHash2";
-
- public MurmurHash2() {
- super(HASH_NAME);
- }
-
- public static int hash(byte[] data, int seed, int offset, int len) {
- int m = 0x5bd1e995;
- int r = 24;
- int h = seed ^ len;
- int len_4 = len >> 2;
- for (int i = 0; i < len_4; i++) {
- int i_4 = offset + (i << 2);
- int k = data[i_4 + 3];
- k = k << 8;
- k = k | (data[i_4 + 2] & 0xff);
- k = k << 8;
- k = k | (data[i_4 + 1] & 0xff);
- k = k << 8;
- k = k | (data[i_4 + 0] & 0xff);
- k *= m;
- k ^= k >>> r;
- k *= m;
- h *= m;
- h ^= k;
- }
- int len_m = len_4 << 2;
- int left = len - len_m;
- if (left != 0) {
- if (left >= 3) {
- h ^= data[offset + len - 3] << 16;
- }
- if (left >= 2) {
- h ^= data[offset + len - 2] << 8;
- }
- if (left >= 1) {
- h ^= data[offset + len - 1];
- }
- h *= m;
- }
- h ^= h >>> 13;
- h *= m;
- h ^= h >>> 15;
- return h;
- }
-
- /**
- * Generates 32 bit hash from byte array with default seed value.
- *
- * @param data
- * byte array to hash
- * @param offset
- * the start position in the array to hash
- * @param len
- * length of the array elements to hash
- * @return 32 bit hash of the given array
- */
- public static final int hash32(final byte[] data, int offset, int len) {
- return MurmurHash2.hash(data, 0x9747b28c, offset, len);
- }
-
-
- @Override
- public final int hash(BytesRef br) {
- return hash32(br.bytes, br.offset, br.length);
- }
-
-}
+package org.apache.lucene.util.hash;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.util.BytesRef;
+
+/**
+ * This is a very fast, non-cryptographic hash suitable for general hash-based
+ * lookup. See http://murmurhash.googlepages.com/ for more details.
+ * <p>
+ * The C version of MurmurHash 2.0 found at that site was ported to Java by
+ * Andrzej Bialecki (ab at getopt org).
+ * </p>
+ * <p>
+ * The code from getopt.org was adapted by Mark Harwood in the form here as one of a pluggable choice of
+ * hashing functions as the core function had to be adapted to work with BytesRefs with offsets and lengths
+ * rather than raw byte arrays.
+ * </p>
+ * @lucene.experimental
+ */
+public class MurmurHash2 extends HashFunction{
+
+
+ public static final String HASH_NAME="MurmurHash2";
+
+ public MurmurHash2() {
+ super(HASH_NAME);
+ }
+
+ public static int hash(byte[] data, int seed, int offset, int len) {
+ int m = 0x5bd1e995;
+ int r = 24;
+ int h = seed ^ len;
+ int len_4 = len >> 2;
+ for (int i = 0; i < len_4; i++) {
+ int i_4 = offset + (i << 2);
+ int k = data[i_4 + 3];
+ k = k << 8;
+ k = k | (data[i_4 + 2] & 0xff);
+ k = k << 8;
+ k = k | (data[i_4 + 1] & 0xff);
+ k = k << 8;
+ k = k | (data[i_4 + 0] & 0xff);
+ k *= m;
+ k ^= k >>> r;
+ k *= m;
+ h *= m;
+ h ^= k;
+ }
+ int len_m = len_4 << 2;
+ int left = len - len_m;
+ if (left != 0) {
+ if (left >= 3) {
+ h ^= data[offset + len - 3] << 16;
+ }
+ if (left >= 2) {
+ h ^= data[offset + len - 2] << 8;
+ }
+ if (left >= 1) {
+ h ^= data[offset + len - 1];
+ }
+ h *= m;
+ }
+ h ^= h >>> 13;
+ h *= m;
+ h ^= h >>> 15;
+ return h;
+ }
+
+ /**
+ * Generates 32 bit hash from byte array with default seed value.
+ *
+ * @param data
+ * byte array to hash
+ * @param offset
+ * the start position in the array to hash
+ * @param len
+ * length of the array elements to hash
+ * @return 32 bit hash of the given array
+ */
+ public static final int hash32(final byte[] data, int offset, int len) {
+ return MurmurHash2.hash(data, 0x9747b28c, offset, len);
+ }
+
+
+ @Override
+ public final int hash(BytesRef br) {
+ return hash32(br.bytes, br.offset, br.length);
+ }
+
+}