From 124728c97487911ab225397878e15c5469ba0360 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Sat, 10 Dec 2011 18:17:34 +0000 Subject: [PATCH] LUCENE-3622: PerFieldDocValues -> DocValue git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3622@1212833 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/document/LazyDocument.java | 14 +++++++------- .../apache/lucene/document/DocValuesField.java | 8 ++++---- .../java/org/apache/lucene/document/Field.java | 12 ++++++------ .../apache/lucene/index/DocFieldProcessor.java | 6 +++--- .../{PerDocFieldValues.java => DocValue.java} | 4 ++-- .../apache/lucene/index/IndexableField.java | 6 +++--- .../lucene/index/codecs/DocValuesConsumer.java | 18 +++++++++--------- .../index/codecs/lucene40/values/Bytes.java | 6 +++--- .../index/codecs/lucene40/values/Floats.java | 6 +++--- .../index/codecs/lucene40/values/Ints.java | 6 +++--- .../lucene40/values/PackedIntValues.java | 6 +++--- .../lucene/index/TestIndexableField.java | 4 ++-- 12 files changed, 48 insertions(+), 48 deletions(-) rename lucene/src/java/org/apache/lucene/index/{PerDocFieldValues.java => DocValue.java} (97%) diff --git a/lucene/contrib/misc/src/java/org/apache/lucene/document/LazyDocument.java b/lucene/contrib/misc/src/java/org/apache/lucene/document/LazyDocument.java index edaf7f52329..b7217086328 100644 --- a/lucene/contrib/misc/src/java/org/apache/lucene/document/LazyDocument.java +++ b/lucene/contrib/misc/src/java/org/apache/lucene/document/LazyDocument.java @@ -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(); } } diff --git a/lucene/src/java/org/apache/lucene/document/DocValuesField.java b/lucene/src/java/org/apache/lucene/document/DocValuesField.java index 097a8814b2e..2cb494c2e43 100644 --- a/lucene/src/java/org/apache/lucene/document/DocValuesField.java +++ b/lucene/src/java/org/apache/lucene/document/DocValuesField.java @@ -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; * * * */ -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; } diff --git a/lucene/src/java/org/apache/lucene/document/Field.java b/lucene/src/java/org/apache/lucene/document/Field.java index 45b9a5a2ff1..26b26be4aa6 100644 --- a/lucene/src/java/org/apache/lucene/document/Field.java +++ b/lucene/src/java/org/apache/lucene/document/Field.java @@ -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; } diff --git a/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java b/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java index df3f4202d2a..8610887dcde 100644 --- a/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java +++ b/lucene/src/java/org/apache/lucene/index/DocFieldProcessor.java @@ -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); } } diff --git a/lucene/src/java/org/apache/lucene/index/PerDocFieldValues.java b/lucene/src/java/org/apache/lucene/index/DocValue.java similarity index 97% rename from lucene/src/java/org/apache/lucene/index/PerDocFieldValues.java rename to lucene/src/java/org/apache/lucene/index/DocValue.java index c82545eed6d..dacb7f6fba5 100644 --- a/lucene/src/java/org/apache/lucene/index/PerDocFieldValues.java +++ b/lucene/src/java/org/apache/lucene/index/DocValue.java @@ -30,7 +30,7 @@ import org.apache.lucene.util.BytesRef; * * @lucene.experimental */ -public interface PerDocFieldValues { +public interface DocValue { /** * Sets the given long value. @@ -96,5 +96,5 @@ public interface PerDocFieldValues { /** * Returns the {@link Type} */ - public DocValues.Type docValuesType(); + public DocValues.Type docValueType(); } diff --git a/lucene/src/java/org/apache/lucene/index/IndexableField.java b/lucene/src/java/org/apache/lucene/index/IndexableField.java index 4a2c8a95073..54ffca44497 100644 --- a/lucene/src/java/org/apache/lucene/index/IndexableField.java +++ b/lucene/src/java/org/apache/lucene/index/IndexableField.java @@ -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, diff --git a/lucene/src/java/org/apache/lucene/index/codecs/DocValuesConsumer.java b/lucene/src/java/org/apache/lucene/index/codecs/DocValuesConsumer.java index e8ddee5088e..f189badc756 100644 --- a/lucene/src/java/org/apache/lucene/index/codecs/DocValuesConsumer.java +++ b/lucene/src/java/org/apache/lucene/index/codecs/DocValuesConsumer.java @@ -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 0 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; diff --git a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/Bytes.java b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/Bytes.java index 2b227e32d8a..789d3aab49e 100644 --- a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/Bytes.java +++ b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/Bytes.java @@ -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); } } diff --git a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/Floats.java b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/Floats.java index b2ed4ea0abb..0a552276e50 100644 --- a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/Floats.java +++ b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/Floats.java @@ -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 diff --git a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/Ints.java b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/Ints.java index 5da35ab299d..bc5de345e85 100644 --- a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/Ints.java +++ b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/Ints.java @@ -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 diff --git a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/PackedIntValues.java b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/PackedIntValues.java index 10983e4bf37..2670510b4c9 100644 --- a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/PackedIntValues.java +++ b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/PackedIntValues.java @@ -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()); } } diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexableField.java b/lucene/src/test/org/apache/lucene/index/TestIndexableField.java index 1e170f332e0..0310f8dc103 100644 --- a/lucene/src/test/org/apache/lucene/index/TestIndexableField.java +++ b/lucene/src/test/org/apache/lucene/index/TestIndexableField.java @@ -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; }