LUCENE-3622: PerFieldDocValues -> DocValue

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3622@1212833 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-12-10 18:17:34 +00:00
parent 5627b52e70
commit 124728c974
12 changed files with 48 additions and 48 deletions

View File

@ -28,7 +28,7 @@ import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.IndexableFieldType; import org.apache.lucene.index.IndexableFieldType;
import org.apache.lucene.index.PerDocFieldValues; import org.apache.lucene.index.DocValue;
import org.apache.lucene.index.DocValues; import org.apache.lucene.index.DocValues;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;
@ -157,20 +157,20 @@ public class LazyDocument {
} }
@Override @Override
public PerDocFieldValues docValues() { public DocValue docValue() {
if (num == 0) { if (num == 0) {
return getDocument().getField(name).docValues(); return getDocument().getField(name).docValue();
} else { } else {
return getDocument().getFields(name)[num].docValues(); return getDocument().getFields(name)[num].docValue();
} }
} }
@Override @Override
public DocValues.Type docValuesType() { public DocValues.Type docValueType() {
if (num == 0) { if (num == 0) {
return getDocument().getField(name).docValuesType(); return getDocument().getField(name).docValueType();
} else { } else {
return getDocument().getFields(name)[num].docValuesType(); return getDocument().getFields(name)[num].docValueType();
} }
} }

View File

@ -20,7 +20,7 @@ import java.io.Reader;
import java.util.Comparator; import java.util.Comparator;
import org.apache.lucene.index.IndexableFieldType; import org.apache.lucene.index.IndexableFieldType;
import org.apache.lucene.index.PerDocFieldValues; import org.apache.lucene.index.DocValue;
import org.apache.lucene.index.DocValues; import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.DocValues.Type; // javadocs import org.apache.lucene.index.DocValues.Type; // javadocs
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;
@ -69,7 +69,7 @@ import org.apache.lucene.util.BytesRef;
* </pre> * </pre>
* *
* */ * */
public class DocValuesField extends Field implements PerDocFieldValues { public class DocValuesField extends Field implements DocValue {
protected BytesRef bytes; protected BytesRef bytes;
protected double doubleValue; protected double doubleValue;
@ -94,7 +94,7 @@ public class DocValuesField extends Field implements PerDocFieldValues {
} }
@Override @Override
public PerDocFieldValues docValues() { public DocValue docValue() {
return this; return this;
} }
@ -307,7 +307,7 @@ public class DocValuesField extends Field implements PerDocFieldValues {
} }
@Override @Override
public DocValues.Type docValuesType() { public DocValues.Type docValueType() {
return type; return type;
} }

View File

@ -28,7 +28,7 @@ import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.index.DocValues; import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexableFieldType; import org.apache.lucene.index.IndexableFieldType;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.PerDocFieldValues; import org.apache.lucene.index.DocValue;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;
/** /**
@ -51,7 +51,7 @@ public class Field implements IndexableField {
// pre-analyzed tokenStream for indexed fields // pre-analyzed tokenStream for indexed fields
protected TokenStream tokenStream; protected TokenStream tokenStream;
// length/offset for all primitive types // length/offset for all primitive types
protected PerDocFieldValues docValues; protected DocValue docValue;
protected float boost = 1.0f; protected float boost = 1.0f;
@ -292,17 +292,17 @@ public class Field implements IndexableField {
return result.toString(); return result.toString();
} }
public void setDocValues(PerDocFieldValues docValues) { public void setDocValue(DocValue docValue) {
this.docValues = docValues; this.docValue = docValue;
} }
@Override @Override
public PerDocFieldValues docValues() { public DocValue docValue() {
return null; return null;
} }
@Override @Override
public DocValues.Type docValuesType() { public DocValues.Type docValueType() {
return null; return null;
} }

View File

@ -259,9 +259,9 @@ final class DocFieldProcessor extends DocConsumer {
if (field.fieldType().stored()) { if (field.fieldType().stored()) {
fieldsWriter.addField(field, fp.fieldInfo); fieldsWriter.addField(field, fp.fieldInfo);
} }
final PerDocFieldValues docValues = field.docValues(); final DocValue docValue = field.docValue();
if (docValues != null) { if (docValue != null) {
docValuesConsumer(field.docValuesType(), docState, fp.fieldInfo).add(docState.docID, docValues); docValuesConsumer(field.docValueType(), docState, fp.fieldInfo).add(docState.docID, docValue);
} }
} }

View File

@ -30,7 +30,7 @@ import org.apache.lucene.util.BytesRef;
* *
* @lucene.experimental * @lucene.experimental
*/ */
public interface PerDocFieldValues { public interface DocValue {
/** /**
* Sets the given <code>long</code> value. * Sets the given <code>long</code> value.
@ -96,5 +96,5 @@ public interface PerDocFieldValues {
/** /**
* Returns the {@link Type} * Returns the {@link Type}
*/ */
public DocValues.Type docValuesType(); public DocValues.Type docValueType();
} }

View File

@ -76,10 +76,10 @@ public interface IndexableField {
public IndexableFieldType fieldType(); public IndexableFieldType fieldType();
/** Non-null if doc values should be indexed */ /** Non-null if doc values should be indexed */
public PerDocFieldValues docValues(); public DocValue docValue();
/** DocValues type; only used if docValues is non-null */ /** DocValues type; only used if docValue is non-null */
public DocValues.Type docValuesType(); public DocValues.Type docValueType();
/** /**
* Creates the TokenStream used for indexing this field. If appropriate, * Creates the TokenStream used for indexing this field. If appropriate,

View File

@ -21,14 +21,14 @@ import java.io.IOException;
import org.apache.lucene.index.DocValues; import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.MergeState; import org.apache.lucene.index.MergeState;
import org.apache.lucene.index.PerDocFieldValues; import org.apache.lucene.index.DocValue;
import org.apache.lucene.util.Bits; import org.apache.lucene.util.Bits;
/** /**
* Abstract API that consumes {@link PerDocFieldValues}. * Abstract API that consumes {@link DocValue}s.
* {@link DocValuesConsumer} are always associated with a specific field and * {@link DocValuesConsumer} are always associated with a specific field and
* segments. Concrete implementations of this API write the given * segments. Concrete implementations of this API write the given
* {@link PerDocFieldValues} into a implementation specific format depending on * {@link DocValue} into a implementation specific format depending on
* the fields meta-data. * the fields meta-data.
* *
* @lucene.experimental * @lucene.experimental
@ -36,28 +36,28 @@ import org.apache.lucene.util.Bits;
public abstract class DocValuesConsumer { public abstract class DocValuesConsumer {
/** /**
* Adds the given {@link PerDocFieldValues} instance to this * Adds the given {@link DocValue} instance to this
* {@link DocValuesConsumer} * {@link DocValuesConsumer}
* *
* @param docID * @param docID
* the document ID to add the value for. The docID must always * the document ID to add the value for. The docID must always
* increase or be <tt>0</tt> if it is the first call to this method. * increase or be <tt>0</tt> if it is the first call to this method.
* @param docValues * @param docValue
* the values to add * the value to add
* @throws IOException * @throws IOException
* if an {@link IOException} occurs * if an {@link IOException} occurs
*/ */
public abstract void add(int docID, PerDocFieldValues docValues) public abstract void add(int docID, DocValue docValue)
throws IOException; throws IOException;
/** /**
* Called when the consumer of this API is doc with adding * Called when the consumer of this API is doc with adding
* {@link PerDocFieldValues} to this {@link DocValuesConsumer} * {@link DocValue} to this {@link DocValuesConsumer}
* *
* @param docCount * @param docCount
* the total number of documents in this {@link DocValuesConsumer}. * the total number of documents in this {@link DocValuesConsumer}.
* Must be greater than or equal the last given docID to * Must be greater than or equal the last given docID to
* {@link #add(int, PerDocFieldValues)}. * {@link #add(int, DocValue)}.
* @throws IOException * @throws IOException
*/ */
public abstract void finish(int docCount) throws IOException; public abstract void finish(int docCount) throws IOException;

View File

@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicLong;
import org.apache.lucene.index.DocValues; import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexFileNames; import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.PerDocFieldValues; import org.apache.lucene.index.DocValue;
import org.apache.lucene.index.DocValues.SortedSource; import org.apache.lucene.index.DocValues.SortedSource;
import org.apache.lucene.index.DocValues.Source; import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.index.DocValues.Type; import org.apache.lucene.index.DocValues.Type;
@ -302,9 +302,9 @@ public final class Bytes {
} }
@Override @Override
public void add(int docID, PerDocFieldValues docValues) throws IOException { public void add(int docID, DocValue docValue) throws IOException {
final BytesRef ref; final BytesRef ref;
if ((ref = docValues.getBytes()) != null) { if ((ref = docValue.getBytes()) != null) {
add(docID, ref); add(docID, ref);
} }
} }

View File

@ -19,7 +19,7 @@ package org.apache.lucene.index.codecs.lucene40.values;
import java.io.IOException; import java.io.IOException;
import org.apache.lucene.index.DocValues; import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.PerDocFieldValues; import org.apache.lucene.index.DocValue;
import org.apache.lucene.index.DocValues.Source; import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.index.DocValues.Type; import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.store.Directory; import org.apache.lucene.store.Directory;
@ -85,8 +85,8 @@ public class Floats {
} }
@Override @Override
public void add(int docID, PerDocFieldValues docValues) throws IOException { public void add(int docID, DocValue docValue) throws IOException {
add(docID, docValues.getFloat()); add(docID, docValue.getFloat());
} }
@Override @Override

View File

@ -21,7 +21,7 @@ import java.io.IOException;
import org.apache.lucene.index.DocValues; import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.DocValues.Type; import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.index.PerDocFieldValues; import org.apache.lucene.index.DocValue;
import org.apache.lucene.store.Directory; import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexInput;
@ -109,8 +109,8 @@ public final class Ints {
} }
@Override @Override
public void add(int docID, PerDocFieldValues docValues) throws IOException { public void add(int docID, DocValue docValue) throws IOException {
add(docID, docValues.getInt()); add(docID, docValue.getInt());
} }
@Override @Override

View File

@ -20,7 +20,7 @@ import java.io.IOException;
import org.apache.lucene.index.DocValues; import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexFileNames; import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.PerDocFieldValues; import org.apache.lucene.index.DocValue;
import org.apache.lucene.index.DocValues.Source; import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.index.DocValues.Type; import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.index.codecs.lucene40.values.FixedStraightBytesImpl.FixedBytesWriterBase; import org.apache.lucene.index.codecs.lucene40.values.FixedStraightBytesImpl.FixedBytesWriterBase;
@ -151,8 +151,8 @@ class PackedIntValues {
} }
@Override @Override
public void add(int docID, PerDocFieldValues docValues) throws IOException { public void add(int docID, DocValue docValue) throws IOException {
add(docID, docValues.getInt()); add(docID, docValue.getInt());
} }
} }

View File

@ -156,12 +156,12 @@ public class TestIndexableField extends LuceneTestCase {
// TODO: randomly enable doc values // TODO: randomly enable doc values
@Override @Override
public PerDocFieldValues docValues() { public DocValue docValue() {
return null; return null;
} }
@Override @Override
public DocValues.Type docValuesType() { public DocValues.Type docValueType() {
return null; return null;
} }