Skip to content

Apache Lucene open-source search software

LUCENE-3108: Renamed parts of the DocValues API according to IndexDocValues and added javadoc comment

Simon Willnauere4beeafa035b
diff --git a/lucene/src/java/org/apache/lucene/document/DocValuesField.java b/lucene/src/java/org/apache/lucene/document/IndexDocValuesField.java
similarity index 90%
rename from lucene/src/java/org/apache/lucene/document/DocValuesField.java
rename to lucene/src/java/org/apache/lucene/document/IndexDocValuesField.java
index 38d6c3df3a2..997cde24501 100644
--- a/lucene/src/java/org/apache/lucene/document/DocValuesField.java
+++ b/lucene/src/java/org/apache/lucene/document/IndexDocValuesField.java
@@ -34,14 +34,14 @@ import org.apache.lucene.util.BytesRef;
* example usage, adding an int value:
*
* <pre>
- * document.add(new DocValuesField(name).setInt(value));
+ * document.add(new IndexDocValuesField(name).setInt(value));
* </pre>
*
* For optimal performance, re-use the <code>DocValuesField</code> and
* {@link Document} instance for more than one document:
*
* <pre>
- * DocValuesField field = new DocValuesField(name);
+ * IndexDocValuesField field = new IndexDocValuesField(name);
* Document document = new Document();
* document.add(field);
*
@@ -55,11 +55,11 @@ import org.apache.lucene.util.BytesRef;
*
* <p>
* If doc values are stored in addition to an indexed ({@link Index}) or stored
- * ({@link Store}) value it's recommended to use the {@link DocValuesField}'s
+ * ({@link Store}) value it's recommended to use the {@link IndexDocValuesField}'s
* {@link #set(AbstractField)} API:
*
* <pre>
- * DocValuesField field = new DocValuesField(name);
+ * IndexDocValuesField field = new IndexDocValuesField(name);
* Field indexedField = new Field(name, stringValue, Stored.NO, Indexed.ANALYZED);
* Document document = new Document();
* document.add(indexedField);
@@ -73,7 +73,7 @@ import org.apache.lucene.util.BytesRef;
* </pre>
*
* */
-public class DocValuesField extends AbstractField implements PerDocFieldValues {
+public class IndexDocValuesField extends AbstractField implements PerDocFieldValues {
protected BytesRef bytes;
protected double doubleValue;
@@ -82,17 +82,17 @@ public class DocValuesField extends AbstractField implements PerDocFieldValues {
protected Comparator<BytesRef> bytesComparator;
/**
- * Creates a new {@link DocValuesField} with the given name.
+ * Creates a new {@link IndexDocValuesField} with the given name.
*/
- public DocValuesField(String name) {
+ public IndexDocValuesField(String name) {
super(name, Store.NO, Index.NO, TermVector.NO);
setDocValues(this);
}
/**
- * Creates a {@link DocValuesField} prototype
+ * Creates a {@link IndexDocValuesField} prototype
*/
- DocValuesField() {
+ IndexDocValuesField() {
this("");
}
@@ -238,7 +238,7 @@ public class DocValuesField extends AbstractField implements PerDocFieldValues {
}
/**
- * Sets this {@link DocValuesField} to the given {@link AbstractField} and
+ * Sets this {@link IndexDocValuesField} to the given {@link AbstractField} and
* returns the given field. Any modifications to this instance will be visible
* to the given field.
*/
@@ -253,9 +253,9 @@ public class DocValuesField extends AbstractField implements PerDocFieldValues {
*
*/
public static <T extends AbstractField> T set(T field, ValueType type) {
- if (field instanceof DocValuesField)
+ if (field instanceof IndexDocValuesField)
return field;
- final DocValuesField valField = new DocValuesField();
+ final IndexDocValuesField valField = new IndexDocValuesField();
switch (type) {
case BYTES_FIXED_DEREF:
case BYTES_FIXED_SORTED:
diff --git a/lucene/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/src/java/org/apache/lucene/index/CheckIndex.java
index 1da3d4db6ea..cc5d1d214af 100644
--- a/lucene/src/java/org/apache/lucene/index/CheckIndex.java
+++ b/lucene/src/java/org/apache/lucene/index/CheckIndex.java
@@ -29,7 +29,7 @@ import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.index.codecs.DefaultSegmentInfosWriter;
import org.apache.lucene.index.codecs.PerDocValues;
import org.apache.lucene.index.values.IndexDocValues;
-import org.apache.lucene.index.values.DocValuesEnum;
+import org.apache.lucene.index.values.ValuesEnum;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
@@ -956,8 +956,8 @@ public class CheckIndex {
if (docValues == null) {
continue;
}
- final DocValuesEnum values = docValues.getEnum();
- while (values.nextDoc() != DocValuesEnum.NO_MORE_DOCS) {
+ final ValuesEnum values = docValues.getEnum();
+ while (values.nextDoc() != ValuesEnum.NO_MORE_DOCS) {
switch (fieldInfo.docValues) {
case BYTES_FIXED_DEREF:
case BYTES_FIXED_SORTED:
diff --git a/lucene/src/java/org/apache/lucene/index/DirectoryReader.java b/lucene/src/java/org/apache/lucene/index/DirectoryReader.java
index a5cbbfb1b46..2b05adf7030 100644
--- a/lucene/src/java/org/apache/lucene/index/DirectoryReader.java
+++ b/lucene/src/java/org/apache/lucene/index/DirectoryReader.java
@@ -1026,6 +1026,6 @@ class DirectoryReader extends IndexReader implements Cloneable {
@Override
public PerDocValues perDocValues() throws IOException {
- throw new UnsupportedOperationException("please use MultiPerDoc#getPerDocs, or wrap your IndexReader with SlowMultiReaderWrapper, if you really need a top level Fields");
+ throw new UnsupportedOperationException("please use MultiPerDocValues#getPerDocs, or wrap your IndexReader with SlowMultiReaderWrapper, if you really need a top level Fields");
}
}
diff --git a/lucene/src/java/org/apache/lucene/index/FieldsEnum.java b/lucene/src/java/org/apache/lucene/index/FieldsEnum.java
index 5d2d707a32d..3fa3729d45a 100644
--- a/lucene/src/java/org/apache/lucene/index/FieldsEnum.java
+++ b/lucene/src/java/org/apache/lucene/index/FieldsEnum.java
@@ -20,7 +20,7 @@ package org.apache.lucene.index;
import java.io.IOException;
import org.apache.lucene.index.values.IndexDocValues;
-import org.apache.lucene.index.values.DocValuesEnum;
+import org.apache.lucene.index.values.ValuesEnum;
import org.apache.lucene.util.AttributeSource;
/** Enumerates indexed fields. You must first call {@link
diff --git a/lucene/src/java/org/apache/lucene/index/MultiFields.java b/lucene/src/java/org/apache/lucene/index/MultiFields.java
index 920bcf669a3..ffe1ac557fe 100644
--- a/lucene/src/java/org/apache/lucene/index/MultiFields.java
+++ b/lucene/src/java/org/apache/lucene/index/MultiFields.java
@@ -23,9 +23,9 @@ import java.util.List;
import java.util.ArrayList;
import org.apache.lucene.index.values.IndexDocValues;
-import org.apache.lucene.index.values.MultiDocValues;
+import org.apache.lucene.index.values.MultiIndexDocValues;
import org.apache.lucene.index.values.ValueType;
-import org.apache.lucene.index.values.MultiDocValues.DocValuesIndex;
+import org.apache.lucene.index.values.MultiIndexDocValues.DocValuesIndex;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.util.ReaderUtil.Gather; // for javadocs
diff --git a/lucene/src/java/org/apache/lucene/index/MultiFieldsEnum.java b/lucene/src/java/org/apache/lucene/index/MultiFieldsEnum.java
index 173cd68d6c4..feaa61775ca 100644
--- a/lucene/src/java/org/apache/lucene/index/MultiFieldsEnum.java
+++ b/lucene/src/java/org/apache/lucene/index/MultiFieldsEnum.java
@@ -17,7 +17,7 @@ package org.apache.lucene.index;
* limitations under the License.
*/
-import org.apache.lucene.index.values.MultiDocValues;
+import org.apache.lucene.index.values.MultiIndexDocValues;
import org.apache.lucene.util.PriorityQueue;
import org.apache.lucene.util.ReaderUtil;
@@ -45,7 +45,7 @@ public final class MultiFieldsEnum extends FieldsEnum {
// Re-used TermsEnum
private final MultiTermsEnum terms;
- private final MultiDocValues docValues;
+ private final MultiIndexDocValues docValues;
private String currentField;
@@ -55,7 +55,7 @@ public final class MultiFieldsEnum extends FieldsEnum {
public MultiFieldsEnum(FieldsEnum[] subs, ReaderUtil.Slice[] subSlices) throws IOException {
terms = new MultiTermsEnum(subSlices);
queue = new FieldMergeQueue(subs.length);
- docValues = new MultiDocValues();
+ docValues = new MultiIndexDocValues();
top = new FieldsEnumWithSlice[subs.length];
List<FieldsEnumWithSlice> enumWithSlices = new ArrayList<FieldsEnumWithSlice>();
diff --git a/lucene/src/java/org/apache/lucene/index/MultiPerDocValues.java b/lucene/src/java/org/apache/lucene/index/MultiPerDocValues.java
index d4a5c062534..34397fbd914 100644
--- a/lucene/src/java/org/apache/lucene/index/MultiPerDocValues.java
+++ b/lucene/src/java/org/apache/lucene/index/MultiPerDocValues.java
@@ -25,9 +25,9 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.lucene.index.codecs.PerDocValues;
import org.apache.lucene.index.values.IndexDocValues;
-import org.apache.lucene.index.values.MultiDocValues;
+import org.apache.lucene.index.values.MultiIndexDocValues;
import org.apache.lucene.index.values.ValueType;
-import org.apache.lucene.index.values.MultiDocValues.DocValuesIndex;
+import org.apache.lucene.index.values.MultiIndexDocValues.DocValuesIndex;
import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.util.ReaderUtil.Gather;
@@ -115,7 +115,7 @@ public class MultiPerDocValues extends PerDocValues {
if (result == null) {
// Lazy init: first time this field is requested, we
// create & add to docValues:
- final List<MultiDocValues.DocValuesIndex> docValuesIndex = new ArrayList<MultiDocValues.DocValuesIndex>();
+ final List<MultiIndexDocValues.DocValuesIndex> docValuesIndex = new ArrayList<MultiIndexDocValues.DocValuesIndex>();
int docsUpto = 0;
ValueType type = null;
// Gather all sub-readers that share this field
@@ -126,24 +126,24 @@ public class MultiPerDocValues extends PerDocValues {
if (values != null) {
if (docsUpto != start) {
type = values.type();
- docValuesIndex.add(new MultiDocValues.DocValuesIndex(
- new MultiDocValues.DummyDocValues(start, type), docsUpto, start
+ docValuesIndex.add(new MultiIndexDocValues.DocValuesIndex(
+ new MultiIndexDocValues.DummyDocValues(start, type), docsUpto, start
- docsUpto));
}
- docValuesIndex.add(new MultiDocValues.DocValuesIndex(values, start,
+ docValuesIndex.add(new MultiIndexDocValues.DocValuesIndex(values, start,
length));
docsUpto = start + length;
} else if (i + 1 == subs.length && !docValuesIndex.isEmpty()) {
- docValuesIndex.add(new MultiDocValues.DocValuesIndex(
- new MultiDocValues.DummyDocValues(start, type), docsUpto, start
+ docValuesIndex.add(new MultiIndexDocValues.DocValuesIndex(
+ new MultiIndexDocValues.DummyDocValues(start, type), docsUpto, start
- docsUpto));
}
}
if (docValuesIndex.isEmpty()) {
return null;
}
- result = new MultiDocValues(
+ result = new MultiIndexDocValues(
docValuesIndex.toArray(DocValuesIndex.EMPTY_ARRAY));
docValues.put(field, result);
}
diff --git a/lucene/src/java/org/apache/lucene/index/MultiReader.java b/lucene/src/java/org/apache/lucene/index/MultiReader.java
index 7a943fadcd0..a67470930ac 100644
--- a/lucene/src/java/org/apache/lucene/index/MultiReader.java
+++ b/lucene/src/java/org/apache/lucene/index/MultiReader.java
@@ -407,6 +407,6 @@ public class MultiReader extends IndexReader implements Cloneable {
@Override
public PerDocValues perDocValues() throws IOException {
- throw new UnsupportedOperationException("please use MultiPerDoc#getPerDocs, or wrap your IndexReader with SlowMultiReaderWrapper, if you really need a top level Fields");
+ throw new UnsupportedOperationException("please use MultiPerDocValues#getPerDocs, or wrap your IndexReader with SlowMultiReaderWrapper, if you really need a top level Fields");
}
}
diff --git a/lucene/src/java/org/apache/lucene/index/values/Bytes.java b/lucene/src/java/org/apache/lucene/index/values/Bytes.java
index cddc69e449e..0944fc9ee4c 100644
--- a/lucene/src/java/org/apache/lucene/index/values/Bytes.java
+++ b/lucene/src/java/org/apache/lucene/index/values/Bytes.java
@@ -223,7 +223,7 @@ public final class Bytes {
protected abstract int maxDoc();
@Override
- public DocValuesEnum getEnum(AttributeSource attrSource) throws IOException {
+ public ValuesEnum getEnum(AttributeSource attrSource) throws IOException {
return new SourceEnum(attrSource, type(), this, maxDoc()) {
@Override
public int advance(int target) throws IOException {
@@ -315,7 +315,7 @@ public final class Bytes {
}
@Override
- public DocValuesEnum getEnum(AttributeSource attrSource) throws IOException {
+ public ValuesEnum getEnum(AttributeSource attrSource) throws IOException {
return new SourceEnum(attrSource, type(), this, maxDoc()) {
@Override
@@ -400,7 +400,7 @@ public final class Bytes {
}
@Override
- protected void setNextEnum(DocValuesEnum valuesEnum) {
+ protected void setNextEnum(ValuesEnum valuesEnum) {
bytesRef = valuesEnum.bytes();
}
diff --git a/lucene/src/java/org/apache/lucene/index/values/FixedDerefBytesImpl.java b/lucene/src/java/org/apache/lucene/index/values/FixedDerefBytesImpl.java
index 5513e4e06da..20f2e323546 100644
--- a/lucene/src/java/org/apache/lucene/index/values/FixedDerefBytesImpl.java
+++ b/lucene/src/java/org/apache/lucene/index/values/FixedDerefBytesImpl.java
@@ -184,11 +184,11 @@ class FixedDerefBytesImpl {
}
@Override
- public DocValuesEnum getEnum(AttributeSource source) throws IOException {
+ public ValuesEnum getEnum(AttributeSource source) throws IOException {
return new DerefBytesEnum(source, cloneData(), cloneIndex(), size);
}
- static class DerefBytesEnum extends DocValuesEnum {
+ static class DerefBytesEnum extends ValuesEnum {
protected final IndexInput datIn;
private final PackedInts.ReaderIterator idx;
protected final long fp;
@@ -215,7 +215,7 @@ class FixedDerefBytesImpl {
valueCount = idx.size();
}
- protected void copyFrom(DocValuesEnum valuesEnum) {
+ protected void copyFrom(ValuesEnum valuesEnum) {
bytesRef = valuesEnum.bytesRef;
if (bytesRef.bytes.length < size) {
bytesRef.grow(size);
diff --git a/lucene/src/java/org/apache/lucene/index/values/FixedSortedBytesImpl.java b/lucene/src/java/org/apache/lucene/index/values/FixedSortedBytesImpl.java
index b5ba7e8b3cc..3a32f9892c3 100644
--- a/lucene/src/java/org/apache/lucene/index/values/FixedSortedBytesImpl.java
+++ b/lucene/src/java/org/apache/lucene/index/values/FixedSortedBytesImpl.java
@@ -229,7 +229,7 @@ class FixedSortedBytesImpl {
}
@Override
- public DocValuesEnum getEnum(AttributeSource source) throws IOException {
+ public ValuesEnum getEnum(AttributeSource source) throws IOException {
// do unsorted
return new DerefBytesEnum(source, cloneData(), cloneIndex(), size);
}
diff --git a/lucene/src/java/org/apache/lucene/index/values/FixedStraightBytesImpl.java b/lucene/src/java/org/apache/lucene/index/values/FixedStraightBytesImpl.java
index a28e7d2793d..7b1e1673a0b 100644
--- a/lucene/src/java/org/apache/lucene/index/values/FixedStraightBytesImpl.java
+++ b/lucene/src/java/org/apache/lucene/index/values/FixedStraightBytesImpl.java
@@ -180,11 +180,11 @@ class FixedStraightBytesImpl {
}
@Override
- public DocValuesEnum getEnum(AttributeSource source) throws IOException {
+ public ValuesEnum getEnum(AttributeSource source) throws IOException {
return new FixedStraightBytesEnum(source, cloneData(), size, maxDoc);
}
- private static final class FixedStraightBytesEnum extends DocValuesEnum {
+ private static final class FixedStraightBytesEnum extends ValuesEnum {
private final IndexInput datIn;
private final int size;
private final int maxDoc;
@@ -203,7 +203,7 @@ class FixedStraightBytesImpl {
fp = datIn.getFilePointer();
}
- protected void copyFrom(DocValuesEnum valuesEnum) {
+ protected void copyFrom(ValuesEnum valuesEnum) {
bytesRef = valuesEnum.bytesRef;
if (bytesRef.bytes.length < size) {
bytesRef.grow(size);
diff --git a/lucene/src/java/org/apache/lucene/index/values/Floats.java b/lucene/src/java/org/apache/lucene/index/values/Floats.java
index 52a1f2faa0f..efe26b8d0e5 100644
--- a/lucene/src/java/org/apache/lucene/index/values/Floats.java
+++ b/lucene/src/java/org/apache/lucene/index/values/Floats.java
@@ -111,7 +111,7 @@ public class Floats {
}
@Override
- protected void setNextEnum(DocValuesEnum valuesEnum) {
+ protected void setNextEnum(ValuesEnum valuesEnum) {
floatsRef = valuesEnum.getFloat();
}
@@ -305,7 +305,7 @@ public class Floats {
}
@Override
- public DocValuesEnum getEnum(AttributeSource attrSource)
+ public ValuesEnum getEnum(AttributeSource attrSource)
throws IOException {
return new SourceEnum(attrSource, ValueType.FLOAT_32, this, maxDoc) {
@Override
@@ -337,7 +337,7 @@ public class Floats {
}
@Override
- public DocValuesEnum getEnum(AttributeSource attrSource)
+ public ValuesEnum getEnum(AttributeSource attrSource)
throws IOException {
return new SourceEnum(attrSource, type(), this, maxDoc) {
@Override
@@ -363,7 +363,7 @@ public class Floats {
}
@Override
- public DocValuesEnum getEnum(AttributeSource source) throws IOException {
+ public ValuesEnum getEnum(AttributeSource source) throws IOException {
IndexInput indexInput = (IndexInput) datIn.clone();
indexInput.seek(CodecUtil.headerLength(CODEC_NAME));
// skip precision:
@@ -443,7 +443,7 @@ public class Floats {
}
}
- static abstract class FloatsEnumImpl extends DocValuesEnum {
+ static abstract class FloatsEnumImpl extends ValuesEnum {
protected final IndexInput dataIn;
protected int pos = -1;
protected final int precision;
diff --git a/lucene/src/java/org/apache/lucene/index/values/IndexDocValues.java b/lucene/src/java/org/apache/lucene/index/values/IndexDocValues.java
index e4d68bc3ee0..32885679f24 100644
--- a/lucene/src/java/org/apache/lucene/index/values/IndexDocValues.java
+++ b/lucene/src/java/org/apache/lucene/index/values/IndexDocValues.java
@@ -20,15 +20,35 @@ import java.io.Closeable;
import java.io.IOException;
import java.util.Comparator;
+import org.apache.lucene.document.IndexDocValuesField;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.FieldsEnum;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.codecs.Codec;
+import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.util.AttributeSource;
import org.apache.lucene.util.BytesRef;
/**
- * nocommit - javadoc
+ * {@link IndexDocValues} provides a dense per-document typed storage for fast
+ * value access based on the lucene internal document id. {@link IndexDocValues}
+ * exposes two distinct APIs:
+ * <ul>
+ * <li>via {@link Source} an entirely RAM resident API for random access</li>
+ * <li>via {@link ValuesEnum} a disk resident API for sequential access</li>
+ * </ul> {@link IndexDocValues} are exposed via
+ * {@link IndexReader#perDocValues()} on a per-segment basis. For best
+ * performance {@link IndexDocValues} should be consumed per-segment just like
+ * IndexReader.
+ * <p>
+ * {@link IndexDocValues} are fully integrated into the {@link Codec} API.
+ * Custom implementations can be exposed on a per field basis via
+ * {@link CodecProvider}.
*
+ * @see ValueType for limitations and default implementation documentation
+ * @see IndexDocValuesField for adding values to the index
+ * @see Codec#docsConsumer(org.apache.lucene.index.PerDocWriteState) for
+ * customization
* @lucene.experimental
*/
public abstract class IndexDocValues implements Closeable {
@@ -45,23 +65,23 @@ public abstract class IndexDocValues implements Closeable {
/**
* Returns an iterator that steps through all documents values for this
- * {@link IndexDocValues} field instance. {@link DocValuesEnum} will skip document
+ * {@link IndexDocValues} field instance. {@link ValuesEnum} will skip document
* without a value if applicable.
*/
- public DocValuesEnum getEnum() throws IOException {
+ public ValuesEnum getEnum() throws IOException {
return getEnum(null);
}
/**
* Returns an iterator that steps through all documents values for this
- * {@link IndexDocValues} field instance. {@link DocValuesEnum} will skip document
+ * {@link IndexDocValues} field instance. {@link ValuesEnum} will skip document
* without a value if applicable.
* <p>
* If an {@link AttributeSource} is supplied to this method the
- * {@link DocValuesEnum} will use the given source to access implementation
+ * {@link ValuesEnum} will use the given source to access implementation
* related attributes.
*/
- public abstract DocValuesEnum getEnum(AttributeSource attrSource)
+ public abstract ValuesEnum getEnum(AttributeSource attrSource)
throws IOException;
/**
@@ -215,9 +235,9 @@ public abstract class IndexDocValues implements Closeable {
}
/**
- * Returns a {@link DocValuesEnum} for this source.
+ * Returns a {@link ValuesEnum} for this source.
*/
- public DocValuesEnum getEnum() throws IOException {
+ public ValuesEnum getEnum() throws IOException {
return getEnum(null);
}
@@ -229,18 +249,18 @@ public abstract class IndexDocValues implements Closeable {
public abstract ValueType type();
/**
- * Returns a {@link DocValuesEnum} for this source which uses the given
+ * Returns a {@link ValuesEnum} for this source which uses the given
* {@link AttributeSource}.
*/
- public abstract DocValuesEnum getEnum(AttributeSource attrSource)
+ public abstract ValuesEnum getEnum(AttributeSource attrSource)
throws IOException;
}
/**
- * {@link DocValuesEnum} utility for {@link Source} implemenations.
+ * {@link ValuesEnum} utility for {@link Source} implemenations.
*
*/
- public abstract static class SourceEnum extends DocValuesEnum {
+ public abstract static class SourceEnum extends ValuesEnum {
protected final Source source;
protected final int numDocs;
protected int pos = -1;
@@ -284,7 +304,7 @@ public abstract class IndexDocValues implements Closeable {
/**
* A sorted variant of {@link Source} for <tt>byte[]</tt> values per document.
* <p>
- * Note: {@link DocValuesEnum} obtained from a {@link SortedSource} will
+ * Note: {@link ValuesEnum} obtained from a {@link SortedSource} will
* enumerate values in document order and not in sorted order.
*/
public static abstract class SortedSource extends Source {
diff --git a/lucene/src/java/org/apache/lucene/index/values/Ints.java b/lucene/src/java/org/apache/lucene/index/values/Ints.java
index d11b548761e..d3cf1039538 100644
--- a/lucene/src/java/org/apache/lucene/index/values/Ints.java
+++ b/lucene/src/java/org/apache/lucene/index/values/Ints.java
@@ -20,8 +20,8 @@ package org.apache.lucene.index.values;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.lucene.index.values.PackedIntsImpl.IntsReader;
-import org.apache.lucene.index.values.PackedIntsImpl.IntsWriter;
+import org.apache.lucene.index.values.IntsImpl.IntsReader;
+import org.apache.lucene.index.values.IntsImpl.IntsWriter;
import org.apache.lucene.store.Directory;
/**
diff --git a/lucene/src/java/org/apache/lucene/index/values/PackedIntsImpl.java b/lucene/src/java/org/apache/lucene/index/values/IntsImpl.java
similarity index 96%
rename from lucene/src/java/org/apache/lucene/index/values/PackedIntsImpl.java
rename to lucene/src/java/org/apache/lucene/index/values/IntsImpl.java
index 4f3f885629a..af93a5212cb 100644
--- a/lucene/src/java/org/apache/lucene/index/values/PackedIntsImpl.java
+++ b/lucene/src/java/org/apache/lucene/index/values/IntsImpl.java
@@ -37,7 +37,7 @@ import org.apache.lucene.util.packed.PackedInts;
*
* @lucene.experimental
* */
-class PackedIntsImpl {
+class IntsImpl {
private static final String CODEC_NAME = "Ints";
private static final byte PACKED = 0x00;
@@ -163,7 +163,7 @@ class PackedIntsImpl {
}
@Override
- protected void setNextEnum(DocValuesEnum valuesEnum) {
+ protected void setNextEnum(ValuesEnum valuesEnum) {
intsRef = valuesEnum.getInt();
}
@@ -244,7 +244,7 @@ class PackedIntsImpl {
}
@Override
- public DocValuesEnum getEnum(AttributeSource attrSource)
+ public ValuesEnum getEnum(AttributeSource attrSource)
throws IOException {
return new SourceEnum(attrSource, type(), this, values.length) {
@@ -283,7 +283,7 @@ class PackedIntsImpl {
}
@Override
- public DocValuesEnum getEnum(AttributeSource attrSource)
+ public ValuesEnum getEnum(AttributeSource attrSource)
throws IOException {
return new SourceEnum(attrSource, type(), this, values.size()) {
@Override
@@ -309,11 +309,11 @@ class PackedIntsImpl {
}
@Override
- public DocValuesEnum getEnum(AttributeSource source) throws IOException {
+ public ValuesEnum getEnum(AttributeSource source) throws IOException {
final IndexInput input = (IndexInput) datIn.clone();
boolean success = false;
try {
- DocValuesEnum inst = packed ? new PackedIntsEnumImpl(source, input)
+ ValuesEnum inst = packed ? new PackedIntsEnumImpl(source, input)
: new FixedIntsEnumImpl(source, input);
success = true;
return inst;
@@ -331,7 +331,7 @@ class PackedIntsImpl {
}
- private static final class PackedIntsEnumImpl extends DocValuesEnum {
+ private static final class PackedIntsEnumImpl extends ValuesEnum {
private final PackedInts.ReaderIterator ints;
private long minValue;
private final IndexInput dataIn;
@@ -381,7 +381,7 @@ class PackedIntsImpl {
}
}
- private static final class FixedIntsEnumImpl extends DocValuesEnum {
+ private static final class FixedIntsEnumImpl extends ValuesEnum {
private final IndexInput dataIn;
private final int maxDoc;
private int pos = -1;
diff --git a/lucene/src/java/org/apache/lucene/index/values/MultiDocValues.java b/lucene/src/java/org/apache/lucene/index/values/MultiIndexDocValues.java
similarity index 91%
rename from lucene/src/java/org/apache/lucene/index/values/MultiDocValues.java
rename to lucene/src/java/org/apache/lucene/index/values/MultiIndexDocValues.java
index 3187d80a216..c6c4c4b2d3b 100644
--- a/lucene/src/java/org/apache/lucene/index/values/MultiDocValues.java
+++ b/lucene/src/java/org/apache/lucene/index/values/MultiIndexDocValues.java
@@ -24,9 +24,12 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.ReaderUtil;
/**
+ * A wrapper for compound IndexReader providing access to per segment
+ * {@link IndexDocValues}
+ *
* @lucene.experimental
*/
-public class MultiDocValues extends IndexDocValues {
+public class MultiIndexDocValues extends IndexDocValues {
public static class DocValuesIndex {
public final static DocValuesIndex[] EMPTY_ARRAY = new DocValuesIndex[0];
@@ -44,17 +47,17 @@ public class MultiDocValues extends IndexDocValues {
private DocValuesIndex[] docValuesIdx;
private int[] starts;
- public MultiDocValues() {
+ public MultiIndexDocValues() {
starts = new int[0];
docValuesIdx = new DocValuesIndex[0];
}
- public MultiDocValues(DocValuesIndex[] docValuesIdx) {
+ public MultiIndexDocValues(DocValuesIndex[] docValuesIdx) {
reset(docValuesIdx);
}
@Override
- public DocValuesEnum getEnum(AttributeSource source) throws IOException {
+ public ValuesEnum getEnum(AttributeSource source) throws IOException {
return new MultiValuesEnum(docValuesIdx, starts);
}
@@ -87,7 +90,7 @@ public class MultiDocValues extends IndexDocValues {
}
@Override
- public DocValuesEnum getEnum(AttributeSource attrSource) throws IOException {
+ public ValuesEnum getEnum(AttributeSource attrSource) throws IOException {
return emptySoruce.getEnum(attrSource);
}
@@ -107,13 +110,13 @@ public class MultiDocValues extends IndexDocValues {
}
- private static class MultiValuesEnum extends DocValuesEnum {
+ private static class MultiValuesEnum extends ValuesEnum {
private DocValuesIndex[] docValuesIdx;
private final int maxDoc;
private int currentStart;
private int currentMax;
private int currentDoc = -1;
- private DocValuesEnum currentEnum;
+ private ValuesEnum currentEnum;
private final int[] starts;
public MultiValuesEnum(DocValuesIndex[] docValuesIdx, int[] starts)
@@ -222,7 +225,7 @@ public class MultiDocValues extends IndexDocValues {
}
@Override
- public DocValuesEnum getEnum(AttributeSource attrSource) throws IOException {
+ public ValuesEnum getEnum(AttributeSource attrSource) throws IOException {
throw new UnsupportedOperationException(); // TODO
}
@@ -258,8 +261,8 @@ public class MultiDocValues extends IndexDocValues {
}
@Override
- public DocValuesEnum getEnum(AttributeSource attrSource) throws IOException {
- return DocValuesEnum.emptyEnum(type);
+ public ValuesEnum getEnum(AttributeSource attrSource) throws IOException {
+ return ValuesEnum.emptyEnum(type);
}
@Override
diff --git a/lucene/src/java/org/apache/lucene/index/values/PerDocFieldValues.java b/lucene/src/java/org/apache/lucene/index/values/PerDocFieldValues.java
index cbd0bb79fe2..130d5b3a507 100644
--- a/lucene/src/java/org/apache/lucene/index/values/PerDocFieldValues.java
+++ b/lucene/src/java/org/apache/lucene/index/values/PerDocFieldValues.java
@@ -18,14 +18,14 @@ package org.apache.lucene.index.values;
*/
import java.util.Comparator;
-import org.apache.lucene.document.DocValuesField;
+import org.apache.lucene.document.IndexDocValuesField;
import org.apache.lucene.document.Fieldable;
import org.apache.lucene.index.codecs.DocValuesConsumer;
import org.apache.lucene.util.BytesRef;
/**
* Per document and field values consumed by {@link DocValuesConsumer}.
- * @see DocValuesField
+ * @see IndexDocValuesField
* @see Fieldable#setDocValues(PerDocFieldValues)
*
* @lucene.experimental
diff --git a/lucene/src/java/org/apache/lucene/index/values/ValueType.java b/lucene/src/java/org/apache/lucene/index/values/ValueType.java
index fa8f95a0700..af953f662b3 100644
--- a/lucene/src/java/org/apache/lucene/index/values/ValueType.java
+++ b/lucene/src/java/org/apache/lucene/index/values/ValueType.java
@@ -20,12 +20,14 @@ package org.apache.lucene.index.values;
import org.apache.lucene.index.codecs.Codec;
import org.apache.lucene.index.codecs.PerDocConsumer;
import org.apache.lucene.index.values.IndexDocValues.SortedSource;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.packed.PackedInts;
/**
- * {@link ValueType} specifies the type of the {@link IndexDocValues} for a certain field.
- * A {@link ValueType} only defines the data type for a field while the actual
- * Implementation used to encode and decode the values depends on the field's
- * {@link Codec}. It is up to the {@link Codec} implementing
+ * {@link ValueType} specifies the type of the {@link IndexDocValues} for a
+ * certain field. A {@link ValueType} only defines the data type for a field
+ * while the actual Implementation used to encode and decode the values depends
+ * on the field's {@link Codec}. It is up to the {@link Codec} implementing
* {@link PerDocConsumer#addValuesField(org.apache.lucene.index.FieldInfo)} and
* using a different low-level implementations to write the stored values for a
* field.
@@ -37,50 +39,141 @@ public enum ValueType {
* TODO: Add INT_32 INT_64 INT_16 & INT_8?!
*/
/**
- * Integer values.
+ * Defines an 64 bit integer value. By default this type uses a simple
+ * compression technique based on {@link PackedInts}. Internally only the used
+ * value range is encoded if it fits into 2<sup>63</sup>-1. If that range is
+ * exceeded the default implementation falls back to fixed size 64bit
+ * integers.
+ * <p>
+ * NOTE: this type uses <tt>0</tt> as the default value without any
+ * distinction between provided <tt>0</tt> values during indexing. All
+ * documents without an explicit value will use <tt>0</tt> instead. In turn,
+ * {@link ValuesEnum} instances will not skip documents without an explicit
+ * value assigned. Custom default values must be assigned explicitly.
+ * </p>
*/
INTS,
-
+
/**
- * 32 bit floating point values.
+ * Defines a 32 bit floating point values. By default there is no compression
+ * applied. To fit custom float values into less than 32bit either a custom
+ * implementation is needed or values must be encoded into a
+ * {@link #BYTES_FIXED_STRAIGHT} type.
+ * <p>
+ * NOTE: this type uses <tt>0.0f</tt> as the default value without any
+ * distinction between provided <tt>0.0f</tt> values during indexing. All
+ * documents without an explicit value will use <tt>0.0f</tt> instead. In
+ * turn, {@link ValuesEnum} instances will not skip documents without an
+ * explicit value assigned. Custom default values must be assigned explicitly.
+ * </p>
*/
FLOAT_32,
/**
- * 64 bit floating point values.
+ * Defines a 64 bit floating point values. By default there is no compression
+ * applied. To fit custom float values into less than 64bit either a custom
+ * implementation is needed or values must be encoded into a
+ * {@link #BYTES_FIXED_STRAIGHT} type.
+ * <p>
+ * NOTE: this type uses <tt>0.0d</tt> as the default value without any
+ * distinction between provided <tt>0.0d</tt> values during indexing. All
+ * documents without an explicit value will use <tt>0.0d</tt> instead. In
+ * turn, {@link ValuesEnum} instances will not skip documents without an
+ * explicit value assigned. Custom default values must be assigned explicitly.
+ * </p>
*/
FLOAT_64,
// TODO(simonw): -- shouldn't lucene decide/detect straight vs
// deref, as well fixed vs var?
/**
- * Fixed length straight stored byte variant
+ * Defines a fixed length straight stored byte variant. All values added to
+ * such a field must be of the same length. All bytes are stored sequentially
+ * for fast offset access.
+ * <p>
+ * NOTE: this type uses <tt>0-bytes</tt> based on the length of the first seen
+ * values as the default value without any distinction between explicitly
+ * provided values during indexing. All documents without an explicit value
+ * will use the default instead. In turn, {@link ValuesEnum} instances will
+ * not skip documents without an explicit value assigned. Custom default
+ * values must be assigned explicitly.
+ * </p>
*/
BYTES_FIXED_STRAIGHT,
/**
- * Fixed length dereferenced (indexed) byte variant
+ * Defines a fixed length dereferenced (indexed) byte variant. Fields with
+ * this type only store distinct byte values and store an additional offset
+ * pointer per document to dereference the payload.
+ * <p>
+ * NOTE: Fields of this type will not store values for documents without and
+ * explicitly provided value. If a documents value is accessed while no
+ * explicit value is stored the returned {@link BytesRef} will be a 0-length
+ * reference. In turn, {@link ValuesEnum} instances will skip over documents
+ * without an explicit value assigned. Custom default values must be assigned
+ * explicitly.
+ * </p>
*/
BYTES_FIXED_DEREF,
/**
- * Fixed length pre-sorted byte variant
+ * Defines a fixed length pre-sorted byte variant. Fields with this type only
+ * store distinct byte values and store an additional offset pointer per
+ * document to dereference the payload. The stored byte payload is presorted
+ * and allows access via document id, ordinal and by-value.
+ * <p>
+ * NOTE: Fields of this type will not store values for documents without and
+ * explicitly provided value. If a documents value is accessed while no
+ * explicit value is stored the returned {@link BytesRef} will be a 0-length
+ * reference. In turn, {@link ValuesEnum} instances will skip over documents
+ * without an explicit value assigned. Custom default values must be assigned
+ * explicitly.
+ * </p>
*
* @see SortedSource
*/
BYTES_FIXED_SORTED,
/**
- * Variable length straight stored byte variant
+ * Defines a variable length straight stored byte variant. All bytes are
+ * stored sequentially for compactness. Usage of this type via the
+ * disk-resident API might yield performance degradation since no additional
+ * index is used to advance by more than one documents value at a time.
+ * <p>
+ * NOTE: Fields of this type will not store values for documents without and
+ * explicitly provided value. If a documents value is accessed while no
+ * explicit value is stored the returned {@link BytesRef} will be a 0-length
+ * reference. Yet, in contrast to dereferences variants {@link ValuesEnum}
+ * instances will <b>not</b> skip over documents without an explicit value
+ * assigned. Custom default values must be assigned explicitly.
+ * </p>
*/
BYTES_VAR_STRAIGHT,
/**
- * Variable length dereferenced (indexed) byte variant
+ * Defines a variable length dereferenced (indexed) byte variant. Just as
+ * {@link #BYTES_FIXED_DEREF} yet supporting variable length values.
+ * <p>
+ * NOTE: Fields of this type will not store values for documents without and
+ * explicitly provided value. If a documents value is accessed while no
+ * explicit value is stored the returned {@link BytesRef} will be a 0-length
+ * reference. In turn, {@link ValuesEnum} instances will skip over documents
+ * without an explicit value assigned. Custom default values must be assigned
+ * explicitly.
+ * </p>
*/
BYTES_VAR_DEREF,
/**
- * Variable length pre-sorted byte variant
+ * Defines a variable length pre-sorted byte variant. Just as
+ * {@link #BYTES_FIXED_SORTED} yet supporting variable length values.
+ * <p>
+ * NOTE: Fields of this type will not store values for documents without and
+ * explicitly provided value. If a documents value is accessed while no
+ * explicit value is stored the returned {@link BytesRef} will be a 0-length
+ * reference. In turn, {@link ValuesEnum} instances will skip over documents
+ * without an explicit value assigned. Custom default values must be assigned
+ * explicitly.
+ * </p>
*
* @see SortedSource
*/
diff --git a/lucene/src/java/org/apache/lucene/index/values/DocValuesEnum.java b/lucene/src/java/org/apache/lucene/index/values/ValuesEnum.java
similarity index 87%
rename from lucene/src/java/org/apache/lucene/index/values/DocValuesEnum.java
rename to lucene/src/java/org/apache/lucene/index/values/ValuesEnum.java
index 2c9ef2b8fb9..03512073cde 100644
--- a/lucene/src/java/org/apache/lucene/index/values/DocValuesEnum.java
+++ b/lucene/src/java/org/apache/lucene/index/values/ValuesEnum.java
@@ -25,7 +25,7 @@ import org.apache.lucene.util.FloatsRef;
import org.apache.lucene.util.LongsRef;
/**
- * {@link DocValuesEnum} is a {@link DocIdSetIterator} iterating <tt>byte[]</tt>
+ * {@link ValuesEnum} is a {@link DocIdSetIterator} iterating <tt>byte[]</tt>
* , <tt>long</tt> and <tt>double</tt> stored per document. Depending on the
* enum's {@link ValueType} ({@link #type()}) the enum might skip over documents that
* have no value stored. Types like {@link ValueType#BYTES_VAR_STRAIGHT} might not
@@ -41,7 +41,7 @@ import org.apache.lucene.util.LongsRef;
*
* @lucene.experimental
*/
-public abstract class DocValuesEnum extends DocIdSetIterator {
+public abstract class ValuesEnum extends DocIdSetIterator {
private AttributeSource source;
private final ValueType enumType;
protected BytesRef bytesRef;
@@ -49,17 +49,17 @@ public abstract class DocValuesEnum extends DocIdSetIterator {
protected LongsRef intsRef;
/**
- * Creates a new {@link DocValuesEnum} for the given type. The
+ * Creates a new {@link ValuesEnum} for the given type. The
* {@link AttributeSource} for this enum is set to <code>null</code>
*/
- protected DocValuesEnum(ValueType enumType) {
+ protected ValuesEnum(ValueType enumType) {
this(null, enumType);
}
/**
- * Creates a new {@link DocValuesEnum} for the given type.
+ * Creates a new {@link ValuesEnum} for the given type.
*/
- protected DocValuesEnum(AttributeSource source, ValueType enumType) {
+ protected ValuesEnum(AttributeSource source, ValueType enumType) {
this.source = source;
this.enumType = enumType;
switch (enumType) {
@@ -115,7 +115,7 @@ public abstract class DocValuesEnum extends DocIdSetIterator {
/**
* Copies the internal state from the given enum
*/
- protected void copyFrom(DocValuesEnum valuesEnum) {
+ protected void copyFrom(ValuesEnum valuesEnum) {
intsRef = valuesEnum.intsRef;
floatsRef = valuesEnum.floatsRef;
bytesRef = valuesEnum.bytesRef;
@@ -144,10 +144,10 @@ public abstract class DocValuesEnum extends DocIdSetIterator {
public abstract void close() throws IOException;
/**
- * Returns an empty {@link DocValuesEnum} for the given {@link ValueType}.
+ * Returns an empty {@link ValuesEnum} for the given {@link ValueType}.
*/
- public static DocValuesEnum emptyEnum(ValueType type) {
- return new DocValuesEnum(type) {
+ public static ValuesEnum emptyEnum(ValueType type) {
+ return new ValuesEnum(type) {
@Override
public int nextDoc() throws IOException {
return NO_MORE_DOCS;
diff --git a/lucene/src/java/org/apache/lucene/index/values/VarDerefBytesImpl.java b/lucene/src/java/org/apache/lucene/index/values/VarDerefBytesImpl.java
index f049119e51a..215acd469ea 100644
--- a/lucene/src/java/org/apache/lucene/index/values/VarDerefBytesImpl.java
+++ b/lucene/src/java/org/apache/lucene/index/values/VarDerefBytesImpl.java
@@ -249,7 +249,7 @@ class VarDerefBytesImpl {
}
@Override
- public DocValuesEnum getEnum(AttributeSource source) throws IOException {
+ public ValuesEnum getEnum(AttributeSource source) throws IOException {
return new VarDerefBytesEnum(source, cloneData(), cloneIndex());
}
diff --git a/lucene/src/java/org/apache/lucene/index/values/VarSortedBytesImpl.java b/lucene/src/java/org/apache/lucene/index/values/VarSortedBytesImpl.java
index ac6bbbe813e..89d4b7b1bf6 100644
--- a/lucene/src/java/org/apache/lucene/index/values/VarSortedBytesImpl.java
+++ b/lucene/src/java/org/apache/lucene/index/values/VarSortedBytesImpl.java
@@ -230,11 +230,11 @@ class VarSortedBytesImpl {
}
@Override
- public DocValuesEnum getEnum(AttributeSource source) throws IOException {
+ public ValuesEnum getEnum(AttributeSource source) throws IOException {
return new VarSortedBytesEnum(source, cloneData(), cloneIndex());
}
- private static class VarSortedBytesEnum extends DocValuesEnum {
+ private static class VarSortedBytesEnum extends ValuesEnum {
private PackedInts.Reader docToOrdIndex;
private PackedInts.Reader ordToOffsetIndex;
private IndexInput idxIn;
diff --git a/lucene/src/java/org/apache/lucene/index/values/VarStraightBytesImpl.java b/lucene/src/java/org/apache/lucene/index/values/VarStraightBytesImpl.java
index 477055dac0e..7d71643f51a 100644
--- a/lucene/src/java/org/apache/lucene/index/values/VarStraightBytesImpl.java
+++ b/lucene/src/java/org/apache/lucene/index/values/VarStraightBytesImpl.java
@@ -164,11 +164,11 @@ class VarStraightBytesImpl {
}
@Override
- public DocValuesEnum getEnum(AttributeSource source) throws IOException {
+ public ValuesEnum getEnum(AttributeSource source) throws IOException {
return new VarStraightBytesEnum(source, cloneData(), cloneIndex());
}
- private class VarStraightBytesEnum extends DocValuesEnum {
+ private class VarStraightBytesEnum extends ValuesEnum {
private final PackedInts.Reader addresses;
private final IndexInput datIn;
private final IndexInput idxIn;
diff --git a/lucene/src/java/org/apache/lucene/index/values/Writer.java b/lucene/src/java/org/apache/lucene/index/values/Writer.java
index 4c6132424e5..e3444545773 100644
--- a/lucene/src/java/org/apache/lucene/index/values/Writer.java
+++ b/lucene/src/java/org/apache/lucene/index/values/Writer.java
@@ -99,15 +99,15 @@ public abstract class Writer extends DocValuesConsumer {
/**
* Records a value from the given document id. The methods implementation
- * obtains the value for the document id from the last {@link DocValuesEnum}
- * set to {@link #setNextEnum(DocValuesEnum)}.
+ * obtains the value for the document id from the last {@link ValuesEnum}
+ * set to {@link #setNextEnum(ValuesEnum)}.
* <p>
* This method is used during merging to provide implementation agnostic
* default merge implementation.
* </p>
* <p>
* The given document id must be the same document id returned from
- * {@link DocValuesEnum#docID()} when this method is called. All documents IDs
+ * {@link ValuesEnum#docID()} when this method is called. All documents IDs
* between the given ID and the previously given ID or <tt>0</tt> if the
* method is call the first time are filled with default values depending on
* the {@link Writer} implementation. The given document ID must always be
@@ -116,13 +116,13 @@ public abstract class Writer extends DocValuesConsumer {
protected abstract void add(int docID) throws IOException;
/**
- * Sets the next {@link DocValuesEnum} to consume values from on calls to
+ * Sets the next {@link ValuesEnum} to consume values from on calls to
* {@link #add(int)}
*
* @param valuesEnum
- * the next {@link DocValuesEnum}, this must not be null
+ * the next {@link ValuesEnum}, this must not be null
*/
- protected abstract void setNextEnum(DocValuesEnum valuesEnum);
+ protected abstract void setNextEnum(ValuesEnum valuesEnum);
/**
* Finish writing and close any files and resources used by this Writer.
@@ -140,7 +140,7 @@ public abstract class Writer extends DocValuesConsumer {
// simply override this and decide if they want to merge
// segments using this generic implementation or if a bulk merge is possible
// / feasible.
- final DocValuesEnum valEnum = state.reader.getEnum();
+ final ValuesEnum valEnum = state.reader.getEnum();
assert valEnum != null;
try {
setNextEnum(valEnum); // set the current enum we are working on - the
@@ -150,11 +150,11 @@ public abstract class Writer extends DocValuesConsumer {
final Bits bits = state.bits;
final int docCount = state.docCount;
int currentDocId;
- if ((currentDocId = valEnum.advance(0)) != DocValuesEnum.NO_MORE_DOCS) {
+ if ((currentDocId = valEnum.advance(0)) != ValuesEnum.NO_MORE_DOCS) {
for (int i = 0; i < docCount; i++) {
if (bits == null || !bits.get(i)) {
if (currentDocId < i) {
- if ((currentDocId = valEnum.advance(i)) == DocValuesEnum.NO_MORE_DOCS) {
+ if ((currentDocId = valEnum.advance(i)) == ValuesEnum.NO_MORE_DOCS) {
break; // advance can jump over default values
}
}
diff --git a/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java b/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java
index 4f6d5759a46..ea1f8911fb3 100644
--- a/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java
+++ b/lucene/src/test-framework/org/apache/lucene/index/RandomIndexWriter.java
@@ -24,7 +24,7 @@ import java.util.Random;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.DocValuesField;
+import org.apache.lucene.document.IndexDocValuesField;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexWriter; // javadoc
import org.apache.lucene.index.codecs.CodecProvider;
@@ -173,7 +173,7 @@ public class RandomIndexWriter implements Closeable {
String name = "random_" + type.name() + "" + docValuesFieldPrefix;
if ("PreFlex".equals(codecProvider.getFieldCodec(name)) || doc.getFieldable(name) != null)
return;
- DocValuesField docValuesField = new DocValuesField(name);
+ IndexDocValuesField docValuesField = new IndexDocValuesField(name);
switch (type) {
case BYTES_FIXED_DEREF:
case BYTES_FIXED_SORTED:
diff --git a/lucene/src/test/org/apache/lucene/index/values/TestDocValues.java b/lucene/src/test/org/apache/lucene/index/values/TestDocValues.java
index 42d32a0ee41..c1365d824ac 100644
--- a/lucene/src/test/org/apache/lucene/index/values/TestDocValues.java
+++ b/lucene/src/test/org/apache/lucene/index/values/TestDocValues.java
@@ -83,7 +83,7 @@ public class TestDocValues extends LuceneTestCase {
IndexDocValues r = Bytes.getValues(dir, "test", mode, fixedSize, maxDoc);
for (int iter = 0; iter < 2; iter++) {
- DocValuesEnum bytesEnum = getEnum(r);
+ ValuesEnum bytesEnum = getEnum(r);
assertNotNull("enum is null", bytesEnum);
BytesRef ref = bytesEnum.bytes();
@@ -94,8 +94,8 @@ public class TestDocValues extends LuceneTestCase {
assertEquals("doc: " + idx + " lenLeft: " + values[idx].length()
+ " lenRight: " + utf8String.length(), values[idx], utf8String);
}
- assertEquals(DocValuesEnum.NO_MORE_DOCS, bytesEnum.advance(maxDoc));
- assertEquals(DocValuesEnum.NO_MORE_DOCS, bytesEnum.advance(maxDoc + 1));
+ assertEquals(ValuesEnum.NO_MORE_DOCS, bytesEnum.advance(maxDoc));
+ assertEquals(ValuesEnum.NO_MORE_DOCS, bytesEnum.advance(maxDoc + 1));
bytesEnum.close();
}
@@ -209,7 +209,7 @@ public class TestDocValues extends LuceneTestCase {
}
for (int iter = 0; iter < 2; iter++) {
- DocValuesEnum iEnum = getEnum(r);
+ ValuesEnum iEnum = getEnum(r);
LongsRef ints = iEnum.getInt();
for (int i = 0; i < NUM_VALUES + additionalDocs; i++) {
assertEquals(i, iEnum.nextDoc());
@@ -219,12 +219,12 @@ public class TestDocValues extends LuceneTestCase {
assertEquals(0, ints.get());
}
}
- assertEquals(DocValuesEnum.NO_MORE_DOCS, iEnum.nextDoc());
+ assertEquals(ValuesEnum.NO_MORE_DOCS, iEnum.nextDoc());
iEnum.close();
}
for (int iter = 0; iter < 2; iter++) {
- DocValuesEnum iEnum = getEnum(r);
+ ValuesEnum iEnum = getEnum(r);
LongsRef ints = iEnum.getInt();
for (int i = 0; i < NUM_VALUES + additionalDocs; i += 1 + random.nextInt(25)) {
assertEquals(i, iEnum.advance(i));
@@ -234,7 +234,7 @@ public class TestDocValues extends LuceneTestCase {
assertEquals(0, ints.get());
}
}
- assertEquals(DocValuesEnum.NO_MORE_DOCS, iEnum.advance(NUM_VALUES + additionalDocs));
+ assertEquals(ValuesEnum.NO_MORE_DOCS, iEnum.advance(NUM_VALUES + additionalDocs));
iEnum.close();
}
r.close();
@@ -272,7 +272,7 @@ public class TestDocValues extends LuceneTestCase {
}
for (int iter = 0; iter < 2; iter++) {
- DocValuesEnum fEnum = getEnum(r);
+ ValuesEnum fEnum = getEnum(r);
FloatsRef floats = fEnum.getFloat();
for (int i = 0; i < NUM_VALUES + additionalValues; i++) {
assertEquals(i, fEnum.nextDoc());
@@ -282,11 +282,11 @@ public class TestDocValues extends LuceneTestCase {
assertEquals(0.0d, floats.get(), delta);
}
}
- assertEquals(DocValuesEnum.NO_MORE_DOCS, fEnum.nextDoc());
+ assertEquals(ValuesEnum.NO_MORE_DOCS, fEnum.nextDoc());
fEnum.close();
}
for (int iter = 0; iter < 2; iter++) {
- DocValuesEnum fEnum = getEnum(r);
+ ValuesEnum fEnum = getEnum(r);
FloatsRef floats = fEnum.getFloat();
for (int i = 0; i < NUM_VALUES + additionalValues; i += 1 + random.nextInt(25)) {
assertEquals(i, fEnum.advance(i));
@@ -296,7 +296,7 @@ public class TestDocValues extends LuceneTestCase {
assertEquals(0.0d, floats.get(), delta);
}
}
- assertEquals(DocValuesEnum.NO_MORE_DOCS, fEnum.advance(NUM_VALUES + additionalValues));
+ assertEquals(ValuesEnum.NO_MORE_DOCS, fEnum.advance(NUM_VALUES + additionalValues));
fEnum.close();
}
@@ -308,7 +308,7 @@ public class TestDocValues extends LuceneTestCase {
runTestFloats(8, 0.0);
}
- private DocValuesEnum getEnum(IndexDocValues values) throws IOException {
+ private ValuesEnum getEnum(IndexDocValues values) throws IOException {
return random.nextBoolean() ? values.getEnum() : getSource(values).getEnum();
}
diff --git a/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java b/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java
index 910fe386a19..20ffa085e80 100644
--- a/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java
+++ b/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java
@@ -26,7 +26,7 @@ import java.util.List;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.AbstractField;
-import org.apache.lucene.document.DocValuesField;
+import org.apache.lucene.document.IndexDocValuesField;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.Field.Index;
@@ -64,10 +64,6 @@ import org.junit.Before;
*/
public class TestDocValuesIndexing extends LuceneTestCase {
/*
- * TODO: Roadmap to land on trunk
- *
- * - Add documentation for:
- * - DocValues
* - add test for unoptimized case with deletes
* - add multithreaded tests / integrate into stress indexing?
*/
@@ -87,7 +83,7 @@ public class TestDocValuesIndexing extends LuceneTestCase {
IndexWriter writer = new IndexWriter(dir, writerConfig(false));
for (int i = 0; i < 5; i++) {
Document doc = new Document();
- DocValuesField valuesField = new DocValuesField("docId");
+ IndexDocValuesField valuesField = new IndexDocValuesField("docId");
valuesField.setInt(i);
doc.add(valuesField);
doc.add(new Field("docId", "" + i, Store.NO, Index.ANALYZED));
@@ -198,10 +194,10 @@ public class TestDocValuesIndexing extends LuceneTestCase {
// check values
IndexReader merged = IndexReader.open(w, true);
- DocValuesEnum vE_1 = getValuesEnum(getDocValues(r_1, first.name()));
- DocValuesEnum vE_2 = getValuesEnum(getDocValues(r_2, second.name()));
- DocValuesEnum vE_1_merged = getValuesEnum(getDocValues(merged, first.name()));
- DocValuesEnum vE_2_merged = getValuesEnum(getDocValues(merged, second
+ ValuesEnum vE_1 = getValuesEnum(getDocValues(r_1, first.name()));
+ ValuesEnum vE_2 = getValuesEnum(getDocValues(r_2, second.name()));
+ ValuesEnum vE_1_merged = getValuesEnum(getDocValues(merged, first.name()));
+ ValuesEnum vE_2_merged = getValuesEnum(getDocValues(merged, second
.name()));
switch (second) { // these variants don't advance over missing values
case BYTES_FIXED_STRAIGHT:
@@ -219,10 +215,10 @@ public class TestDocValuesIndexing extends LuceneTestCase {
assertEquals(msg, i, vE_2.nextDoc());
assertEquals(msg, i + valuesPerIndex, vE_2_merged.nextDoc());
}
- assertEquals(msg, DocValuesEnum.NO_MORE_DOCS, vE_1.nextDoc());
- assertEquals(msg, DocValuesEnum.NO_MORE_DOCS, vE_2.nextDoc());
- assertEquals(msg, DocValuesEnum.NO_MORE_DOCS, vE_1_merged.advance(valuesPerIndex*2));
- assertEquals(msg, DocValuesEnum.NO_MORE_DOCS, vE_2_merged.nextDoc());
+ assertEquals(msg, ValuesEnum.NO_MORE_DOCS, vE_1.nextDoc());
+ assertEquals(msg, ValuesEnum.NO_MORE_DOCS, vE_2.nextDoc());
+ assertEquals(msg, ValuesEnum.NO_MORE_DOCS, vE_1_merged.advance(valuesPerIndex*2));
+ assertEquals(msg, ValuesEnum.NO_MORE_DOCS, vE_2_merged.nextDoc());
// close resources
r_1.close();
@@ -274,7 +270,7 @@ public class TestDocValuesIndexing extends LuceneTestCase {
assertEquals("index " + i, 0, value);
}
- DocValuesEnum intsEnum = getValuesEnum(intsReader);
+ ValuesEnum intsEnum = getValuesEnum(intsReader);
assertTrue(intsEnum.advance(base) >= base);
intsEnum = getValuesEnum(intsReader);
@@ -303,7 +299,7 @@ public class TestDocValuesIndexing extends LuceneTestCase {
assertEquals(val + " failed for doc: " + i + " base: " + base,
0.0d, value, 0.0d);
}
- DocValuesEnum floatEnum = getValuesEnum(floatReader);
+ ValuesEnum floatEnum = getValuesEnum(floatReader);
assertTrue(floatEnum.advance(base) >= base);
floatEnum = getValuesEnum(floatReader);
@@ -388,7 +384,7 @@ public class TestDocValuesIndexing extends LuceneTestCase {
assertNotNull("expected none null - " + msg, br);
assertEquals(0, br.length);
// make sure we advance at least until base
- DocValuesEnum bytesEnum = getValuesEnum(bytesReader);
+ ValuesEnum bytesEnum = getValuesEnum(bytesReader);
try {
final int advancedTo = bytesEnum.advance(0);
@@ -403,7 +399,7 @@ public class TestDocValuesIndexing extends LuceneTestCase {
}
}
- DocValuesEnum bytesEnum = getValuesEnum(bytesReader);
+ ValuesEnum bytesEnum = getValuesEnum(bytesReader);
final BytesRef enumRef = bytesEnum.bytes();
// test the actual doc values added in this iteration
assertEquals(base + numRemainingValues, r.numDocs());
@@ -480,9 +476,9 @@ public class TestDocValuesIndexing extends LuceneTestCase {
return source;
}
- private DocValuesEnum getValuesEnum(IndexDocValues values) throws IOException {
- DocValuesEnum valuesEnum;
- if (!(values instanceof MultiDocValues) && random.nextInt(10) == 0) {
+ private ValuesEnum getValuesEnum(IndexDocValues values) throws IOException {
+ ValuesEnum valuesEnum;
+ if (!(values instanceof MultiIndexDocValues) && random.nextInt(10) == 0) {
// TODO not supported by MultiDocValues yet!
valuesEnum = getSource(values).getEnum();
} else {
@@ -511,11 +507,11 @@ public class TestDocValuesIndexing extends LuceneTestCase {
OpenBitSet deleted = new OpenBitSet(numValues);
Document doc = new Document();
Index idx = IDX_VALUES[random.nextInt(IDX_VALUES.length)];
- AbstractField field = random.nextBoolean() ? new DocValuesField(value.name())
+ AbstractField field = random.nextBoolean() ? new IndexDocValuesField(value.name())
: newField(value.name(), _TestUtil.randomRealisticUnicodeString(random,
10), idx == Index.NO ? Store.YES : Store.NO, idx);
doc.add(field);
- DocValuesField valField = new DocValuesField("prototype");
+ IndexDocValuesField valField = new IndexDocValuesField("prototype");
final BytesRef bytesRef = new BytesRef();
final String idBase = value.name() + "_";
diff --git a/lucene/src/test/org/apache/lucene/search/TestSort.java b/lucene/src/test/org/apache/lucene/search/TestSort.java
index 4c81a18455a..170857b20a8 100644
--- a/lucene/src/test/org/apache/lucene/search/TestSort.java
+++ b/lucene/src/test/org/apache/lucene/search/TestSort.java
@@ -25,7 +25,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.DocValuesField;
+import org.apache.lucene.document.IndexDocValuesField;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.CorruptIndexException;
@@ -124,13 +124,13 @@ public class TestSort extends LuceneTestCase {
doc.add (new Field ("contents", data[i][1], Field.Store.NO, Field.Index.ANALYZED));
if (data[i][2] != null) {
Field f = supportsDocValues ?
- DocValuesField.set(new Field ("int", data[i][2], Field.Store.NO, Field.Index.NOT_ANALYZED), ValueType.INTS)
+ IndexDocValuesField.set(new Field ("int", data[i][2], Field.Store.NO, Field.Index.NOT_ANALYZED), ValueType.INTS)
: new Field ("int", data[i][2], Field.Store.NO, Field.Index.NOT_ANALYZED);
doc.add(f);
}
if (data[i][3] != null) {
Field f = supportsDocValues ?
- DocValuesField.set(new Field ("float", data[i][3], Field.Store.NO, Field.Index.NOT_ANALYZED), ValueType.FLOAT_32)
+ IndexDocValuesField.set(new Field ("float", data[i][3], Field.Store.NO, Field.Index.NOT_ANALYZED), ValueType.FLOAT_32)
: new Field ("float", data[i][3], Field.Store.NO, Field.Index.NOT_ANALYZED);
doc.add(f);
}
@@ -140,7 +140,7 @@ public class TestSort extends LuceneTestCase {
if (data[i][7] != null) doc.add (new Field ("long", data[i][7], Field.Store.NO, Field.Index.NOT_ANALYZED));
if (data[i][8] != null) {
Field f = supportsDocValues ?
- DocValuesField.set(new Field ("double", data[i][8], Field.Store.NO, Field.Index.NOT_ANALYZED), ValueType.FLOAT_64)
+ IndexDocValuesField.set(new Field ("double", data[i][8], Field.Store.NO, Field.Index.NOT_ANALYZED), ValueType.FLOAT_64)
: new Field ("double", data[i][8], Field.Store.NO, Field.Index.NOT_ANALYZED);
doc.add(f);
}