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.IndexableField;
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.util.BytesRef;
@ -157,20 +157,20 @@ public class LazyDocument {
}
@Override
public PerDocFieldValues docValues() {
public DocValue docValue() {
if (num == 0) {
return getDocument().getField(name).docValues();
return getDocument().getField(name).docValue();
} else {
return getDocument().getFields(name)[num].docValues();
return getDocument().getFields(name)[num].docValue();
}
}
@Override
public DocValues.Type docValuesType() {
public DocValues.Type docValueType() {
if (num == 0) {
return getDocument().getField(name).docValuesType();
return getDocument().getField(name).docValueType();
} 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 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.Type; // javadocs
import org.apache.lucene.util.BytesRef;
@ -69,7 +69,7 @@ import org.apache.lucene.util.BytesRef;
* </pre>
*
* */
public class DocValuesField extends Field implements PerDocFieldValues {
public class DocValuesField extends Field implements DocValue {
protected BytesRef bytes;
protected double doubleValue;
@ -94,7 +94,7 @@ public class DocValuesField extends Field implements PerDocFieldValues {
}
@Override
public PerDocFieldValues docValues() {
public DocValue docValue() {
return this;
}
@ -307,7 +307,7 @@ public class DocValuesField extends Field implements PerDocFieldValues {
}
@Override
public DocValues.Type docValuesType() {
public DocValues.Type docValueType() {
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.IndexableFieldType;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.PerDocFieldValues;
import org.apache.lucene.index.DocValue;
import org.apache.lucene.util.BytesRef;
/**
@ -51,7 +51,7 @@ public class Field implements IndexableField {
// pre-analyzed tokenStream for indexed fields
protected TokenStream tokenStream;
// length/offset for all primitive types
protected PerDocFieldValues docValues;
protected DocValue docValue;
protected float boost = 1.0f;
@ -292,17 +292,17 @@ public class Field implements IndexableField {
return result.toString();
}
public void setDocValues(PerDocFieldValues docValues) {
this.docValues = docValues;
public void setDocValue(DocValue docValue) {
this.docValue = docValue;
}
@Override
public PerDocFieldValues docValues() {
public DocValue docValue() {
return null;
}
@Override
public DocValues.Type docValuesType() {
public DocValues.Type docValueType() {
return null;
}

View File

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

View File

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

View File

@ -76,10 +76,10 @@ public interface IndexableField {
public IndexableFieldType fieldType();
/** Non-null if doc values should be indexed */
public PerDocFieldValues docValues();
public DocValue docValue();
/** DocValues type; only used if docValues is non-null */
public DocValues.Type docValuesType();
/** DocValues type; only used if docValue is non-null */
public DocValues.Type docValueType();
/**
* 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.IndexReader;
import org.apache.lucene.index.MergeState;
import org.apache.lucene.index.PerDocFieldValues;
import org.apache.lucene.index.DocValue;
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
* 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.
*
* @lucene.experimental
@ -36,28 +36,28 @@ import org.apache.lucene.util.Bits;
public abstract class DocValuesConsumer {
/**
* Adds the given {@link PerDocFieldValues} instance to this
* Adds the given {@link DocValue} instance to this
* {@link DocValuesConsumer}
*
* @param docID
* 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.
* @param docValues
* the values to add
* @param docValue
* the value to add
* @throws IOException
* if an {@link IOException} occurs
*/
public abstract void add(int docID, PerDocFieldValues docValues)
public abstract void add(int docID, DocValue docValue)
throws IOException;
/**
* 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
* the total number of documents in this {@link DocValuesConsumer}.
* Must be greater than or equal the last given docID to
* {@link #add(int, PerDocFieldValues)}.
* {@link #add(int, DocValue)}.
* @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.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.Source;
import org.apache.lucene.index.DocValues.Type;
@ -302,9 +302,9 @@ public final class Bytes {
}
@Override
public void add(int docID, PerDocFieldValues docValues) throws IOException {
public void add(int docID, DocValue docValue) throws IOException {
final BytesRef ref;
if ((ref = docValues.getBytes()) != null) {
if ((ref = docValue.getBytes()) != null) {
add(docID, ref);
}
}

View File

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

View File

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

View File

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

View File

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