You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2013/02/08 04:26:21 UTC
svn commit: r1443834 [2/16] - in /lucene/dev/branches/branch_4x: ./
dev-tools/ lucene/ lucene/analysis/
lucene/analysis/icu/src/java/org/apache/lucene/collation/
lucene/analysis/icu/src/test/org/apache/lucene/collation/ lucene/backwards/
lucene/benchma...
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xNormsProducer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xNormsProducer.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xNormsProducer.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xNormsProducer.java Fri Feb 8 03:26:14 2013
@@ -24,18 +24,17 @@ import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;
-import org.apache.lucene.codecs.PerDocProducer;
-import org.apache.lucene.index.DocValues;
-import org.apache.lucene.index.DocValues.Source;
-import org.apache.lucene.index.DocValues.Type;
+import org.apache.lucene.codecs.DocValuesProducer;
+import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.IndexFileNames;
+import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.SegmentInfo;
+import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.StringHelper;
@@ -45,7 +44,7 @@ import org.apache.lucene.util.StringHelp
* @deprecated Only for reading existing 3.x indexes
*/
@Deprecated
-class Lucene3xNormsProducer extends PerDocProducer {
+class Lucene3xNormsProducer extends DocValuesProducer {
/** norms header placeholder */
static final byte[] NORMS_HEADER = new byte[]{'N','R','M',-1};
@@ -126,11 +125,6 @@ class Lucene3xNormsProducer extends PerD
}
@Override
- public DocValues docValues(String field) throws IOException {
- return norms.get(field);
- }
-
- @Override
public void close() throws IOException {
try {
IOUtils.close(openFiles);
@@ -159,65 +153,22 @@ class Lucene3xNormsProducer extends PerD
return true;
}
}
-
- static final class NormSource extends Source {
- protected NormSource(byte[] bytes) {
- super(Type.FIXED_INTS_8);
- this.bytes = bytes;
- }
-
- final byte bytes[];
-
- @Override
- public BytesRef getBytes(int docID, BytesRef ref) {
- ref.bytes = bytes;
- ref.offset = docID;
- ref.length = 1;
- return ref;
- }
-
- @Override
- public long getInt(int docID) {
- return bytes[docID];
- }
- @Override
- public boolean hasArray() {
- return true;
- }
-
- @Override
- public Object getArray() {
- return bytes;
- }
-
- }
-
- private class NormsDocValues extends DocValues {
+ // holds a file+offset pointing to a norms, and lazy-loads it
+ // to a singleton NumericDocValues instance
+ private class NormsDocValues {
private final IndexInput file;
private final long offset;
+ private NumericDocValues instance;
+
public NormsDocValues(IndexInput normInput, long normSeek) {
this.file = normInput;
this.offset = normSeek;
}
-
- @Override
- protected Source loadSource() throws IOException {
- return new NormSource(bytes());
- }
-
- @Override
- protected Source loadDirectSource() throws IOException {
- return getSource();
- }
-
- @Override
- public Type getType() {
- return Type.FIXED_INTS_8;
- }
- byte[] bytes() throws IOException {
- byte[] bytes = new byte[maxdoc];
+ synchronized NumericDocValues getInstance() throws IOException {
+ if (instance == null) {
+ final byte[] bytes = new byte[maxdoc];
// some norms share fds
synchronized(file) {
file.seek(offset);
@@ -228,13 +179,31 @@ class Lucene3xNormsProducer extends PerD
openFiles.remove(file);
file.close();
}
- return bytes;
- }
+ instance = new NumericDocValues() {
+ @Override
+ public long get(int docID) {
+ return bytes[docID];
+ }
+ };
+ }
+ return instance;
+ }
+ }
- @Override
- public int getValueSize() {
- return 1;
- }
-
+ @Override
+ public NumericDocValues getNumeric(FieldInfo field) throws IOException {
+ NormsDocValues dv = norms.get(field.name);
+ assert dv != null;
+ return dv.getInstance();
+ }
+
+ @Override
+ public BinaryDocValues getBinary(FieldInfo field) throws IOException {
+ throw new AssertionError();
+ }
+
+ @Override
+ public SortedDocValues getSorted(FieldInfo field) throws IOException {
+ throw new AssertionError();
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xPostingsFormat.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xPostingsFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xPostingsFormat.java Fri Feb 8 03:26:14 2013
@@ -59,6 +59,6 @@ class Lucene3xPostingsFormat extends Pos
@Override
public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException {
- return new Lucene3xFields(state.dir, state.fieldInfos, state.segmentInfo, state.context, state.termsIndexDivisor);
+ return new Lucene3xFields(state.directory, state.fieldInfos, state.segmentInfo, state.context, state.termsIndexDivisor);
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40Codec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40Codec.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40Codec.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40Codec.java Fri Feb 8 03:26:14 2013
@@ -18,15 +18,16 @@ package org.apache.lucene.codecs.lucene4
*/
import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.codecs.FilterCodec;
import org.apache.lucene.codecs.LiveDocsFormat;
-import org.apache.lucene.codecs.NormsFormat;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.SegmentInfoFormat;
+import org.apache.lucene.codecs.DocValuesFormat;
+import org.apache.lucene.codecs.NormsFormat;
import org.apache.lucene.codecs.StoredFieldsFormat;
import org.apache.lucene.codecs.TermVectorsFormat;
+import org.apache.lucene.codecs.lucene42.Lucene42NormsFormat;
import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat;
/**
@@ -42,13 +43,11 @@ import org.apache.lucene.codecs.perfield
// if they are backwards compatible or smallish we can probably do the backwards in the postingsreader
// (it writes a minor version, etc).
@Deprecated
-public final class Lucene40Codec extends Codec {
+public class Lucene40Codec extends Codec {
private final StoredFieldsFormat fieldsFormat = new Lucene40StoredFieldsFormat();
private final TermVectorsFormat vectorsFormat = new Lucene40TermVectorsFormat();
private final FieldInfosFormat fieldInfosFormat = new Lucene40FieldInfosFormat();
- private final DocValuesFormat docValuesFormat = new Lucene40DocValuesFormat();
private final SegmentInfoFormat infosFormat = new Lucene40SegmentInfoFormat();
- private final NormsFormat normsFormat = new Lucene40NormsFormat();
private final LiveDocsFormat liveDocsFormat = new Lucene40LiveDocsFormat();
private final PostingsFormat postingsFormat = new PerFieldPostingsFormat() {
@@ -74,17 +73,12 @@ public final class Lucene40Codec extends
}
@Override
- public final DocValuesFormat docValuesFormat() {
- return docValuesFormat;
- }
-
- @Override
public final PostingsFormat postingsFormat() {
return postingsFormat;
}
@Override
- public final FieldInfosFormat fieldInfosFormat() {
+ public FieldInfosFormat fieldInfosFormat() {
return fieldInfosFormat;
}
@@ -92,12 +86,21 @@ public final class Lucene40Codec extends
public final SegmentInfoFormat segmentInfoFormat() {
return infosFormat;
}
+
+ private final DocValuesFormat defaultDVFormat = new Lucene40DocValuesFormat();
+
+ @Override
+ public DocValuesFormat docValuesFormat() {
+ return defaultDVFormat;
+ }
+
+ private final NormsFormat normsFormat = new Lucene40NormsFormat();
@Override
- public final NormsFormat normsFormat() {
+ public NormsFormat normsFormat() {
return normsFormat;
}
-
+
@Override
public final LiveDocsFormat liveDocsFormat() {
return liveDocsFormat;
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosFormat.java Fri Feb 8 03:26:14 2013
@@ -23,8 +23,6 @@ import org.apache.lucene.codecs.CodecUti
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.codecs.FieldInfosReader;
import org.apache.lucene.codecs.FieldInfosWriter;
-import org.apache.lucene.index.DocValues; // javadoc
-import org.apache.lucene.index.DocValues.Type; // javadoc
import org.apache.lucene.store.DataOutput; // javadoc
/**
@@ -72,32 +70,33 @@ import org.apache.lucene.store.DataOutpu
* <li>DocValuesBits: a byte containing per-document value types. The type
* recorded as two four-bit integers, with the high-order bits representing
* <code>norms</code> options, and the low-order bits representing
- * {@link DocValues} options. Each four-bit integer can be decoded as such:
+ * {@code DocValues} options. Each four-bit integer can be decoded as such:
* <ul>
* <li>0: no DocValues for this field.</li>
- * <li>1: variable-width signed integers. ({@link Type#VAR_INTS VAR_INTS})</li>
- * <li>2: 32-bit floating point values. ({@link Type#FLOAT_32 FLOAT_32})</li>
- * <li>3: 64-bit floating point values. ({@link Type#FLOAT_64 FLOAT_64})</li>
- * <li>4: fixed-length byte array values. ({@link Type#BYTES_FIXED_STRAIGHT BYTES_FIXED_STRAIGHT})</li>
- * <li>5: fixed-length dereferenced byte array values. ({@link Type#BYTES_FIXED_DEREF BYTES_FIXED_DEREF})</li>
- * <li>6: variable-length byte array values. ({@link Type#BYTES_VAR_STRAIGHT BYTES_VAR_STRAIGHT})</li>
- * <li>7: variable-length dereferenced byte array values. ({@link Type#BYTES_VAR_DEREF BYTES_VAR_DEREF})</li>
- * <li>8: 16-bit signed integers. ({@link Type#FIXED_INTS_16 FIXED_INTS_16})</li>
- * <li>9: 32-bit signed integers. ({@link Type#FIXED_INTS_32 FIXED_INTS_32})</li>
- * <li>10: 64-bit signed integers. ({@link Type#FIXED_INTS_64 FIXED_INTS_64})</li>
- * <li>11: 8-bit signed integers. ({@link Type#FIXED_INTS_8 FIXED_INTS_8})</li>
- * <li>12: fixed-length sorted byte array values. ({@link Type#BYTES_FIXED_SORTED BYTES_FIXED_SORTED})</li>
- * <li>13: variable-length sorted byte array values. ({@link Type#BYTES_VAR_SORTED BYTES_VAR_SORTED})</li>
+ * <li>1: variable-width signed integers. ({@code Type#VAR_INTS VAR_INTS})</li>
+ * <li>2: 32-bit floating point values. ({@code Type#FLOAT_32 FLOAT_32})</li>
+ * <li>3: 64-bit floating point values. ({@code Type#FLOAT_64 FLOAT_64})</li>
+ * <li>4: fixed-length byte array values. ({@code Type#BYTES_FIXED_STRAIGHT BYTES_FIXED_STRAIGHT})</li>
+ * <li>5: fixed-length dereferenced byte array values. ({@code Type#BYTES_FIXED_DEREF BYTES_FIXED_DEREF})</li>
+ * <li>6: variable-length byte array values. ({@code Type#BYTES_VAR_STRAIGHT BYTES_VAR_STRAIGHT})</li>
+ * <li>7: variable-length dereferenced byte array values. ({@code Type#BYTES_VAR_DEREF BYTES_VAR_DEREF})</li>
+ * <li>8: 16-bit signed integers. ({@code Type#FIXED_INTS_16 FIXED_INTS_16})</li>
+ * <li>9: 32-bit signed integers. ({@code Type#FIXED_INTS_32 FIXED_INTS_32})</li>
+ * <li>10: 64-bit signed integers. ({@code Type#FIXED_INTS_64 FIXED_INTS_64})</li>
+ * <li>11: 8-bit signed integers. ({@code Type#FIXED_INTS_8 FIXED_INTS_8})</li>
+ * <li>12: fixed-length sorted byte array values. ({@code Type#BYTES_FIXED_SORTED BYTES_FIXED_SORTED})</li>
+ * <li>13: variable-length sorted byte array values. ({@code Type#BYTES_VAR_SORTED BYTES_VAR_SORTED})</li>
* </ul>
* </li>
* <li>Attributes: a key-value map of codec-private attributes.</li>
* </ul>
*
* @lucene.experimental
+ * @deprecated Only for reading old 4.0 and 4.1 segments
*/
+@Deprecated
public class Lucene40FieldInfosFormat extends FieldInfosFormat {
private final FieldInfosReader reader = new Lucene40FieldInfosReader();
- private final FieldInfosWriter writer = new Lucene40FieldInfosWriter();
/** Sole constructor. */
public Lucene40FieldInfosFormat() {
@@ -110,6 +109,21 @@ public class Lucene40FieldInfosFormat ex
@Override
public FieldInfosWriter getFieldInfosWriter() throws IOException {
- return writer;
+ throw new UnsupportedOperationException("this codec can only be used for reading");
}
+
+ /** Extension of field infos */
+ static final String FIELD_INFOS_EXTENSION = "fnm";
+
+ static final String CODEC_NAME = "Lucene40FieldInfos";
+ static final int FORMAT_START = 0;
+ static final int FORMAT_CURRENT = FORMAT_START;
+
+ static final byte IS_INDEXED = 0x1;
+ static final byte STORE_TERMVECTOR = 0x2;
+ static final byte STORE_OFFSETS_IN_POSTINGS = 0x4;
+ static final byte OMIT_NORMS = 0x10;
+ static final byte STORE_PAYLOADS = 0x20;
+ static final byte OMIT_TERM_FREQ_AND_POSITIONS = 0x40;
+ static final byte OMIT_POSITIONS = -128;
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40FieldInfosReader.java Fri Feb 8 03:26:14 2013
@@ -27,8 +27,8 @@ import org.apache.lucene.index.CorruptIn
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.IndexFileNames;
+import org.apache.lucene.index.FieldInfo.DocValuesType;
import org.apache.lucene.index.FieldInfo.IndexOptions;
-import org.apache.lucene.index.DocValues;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
@@ -39,8 +39,10 @@ import org.apache.lucene.util.IOUtils;
*
* @lucene.experimental
* @see Lucene40FieldInfosFormat
+ * @deprecated Only for reading old 4.0 and 4.1 segments
*/
-public class Lucene40FieldInfosReader extends FieldInfosReader {
+@Deprecated
+class Lucene40FieldInfosReader extends FieldInfosReader {
/** Sole constructor. */
public Lucene40FieldInfosReader() {
@@ -48,14 +50,14 @@ public class Lucene40FieldInfosReader ex
@Override
public FieldInfos read(Directory directory, String segmentName, IOContext iocontext) throws IOException {
- final String fileName = IndexFileNames.segmentFileName(segmentName, "", Lucene40FieldInfosWriter.FIELD_INFOS_EXTENSION);
+ final String fileName = IndexFileNames.segmentFileName(segmentName, "", Lucene40FieldInfosFormat.FIELD_INFOS_EXTENSION);
IndexInput input = directory.openInput(fileName, iocontext);
boolean success = false;
try {
- CodecUtil.checkHeader(input, Lucene40FieldInfosWriter.CODEC_NAME,
- Lucene40FieldInfosWriter.FORMAT_START,
- Lucene40FieldInfosWriter.FORMAT_CURRENT);
+ CodecUtil.checkHeader(input, Lucene40FieldInfosFormat.CODEC_NAME,
+ Lucene40FieldInfosFormat.FORMAT_START,
+ Lucene40FieldInfosFormat.FORMAT_CURRENT);
final int size = input.readVInt(); //read in the size
FieldInfo infos[] = new FieldInfo[size];
@@ -64,18 +66,18 @@ public class Lucene40FieldInfosReader ex
String name = input.readString();
final int fieldNumber = input.readVInt();
byte bits = input.readByte();
- boolean isIndexed = (bits & Lucene40FieldInfosWriter.IS_INDEXED) != 0;
- boolean storeTermVector = (bits & Lucene40FieldInfosWriter.STORE_TERMVECTOR) != 0;
- boolean omitNorms = (bits & Lucene40FieldInfosWriter.OMIT_NORMS) != 0;
- boolean storePayloads = (bits & Lucene40FieldInfosWriter.STORE_PAYLOADS) != 0;
+ boolean isIndexed = (bits & Lucene40FieldInfosFormat.IS_INDEXED) != 0;
+ boolean storeTermVector = (bits & Lucene40FieldInfosFormat.STORE_TERMVECTOR) != 0;
+ boolean omitNorms = (bits & Lucene40FieldInfosFormat.OMIT_NORMS) != 0;
+ boolean storePayloads = (bits & Lucene40FieldInfosFormat.STORE_PAYLOADS) != 0;
final IndexOptions indexOptions;
if (!isIndexed) {
indexOptions = null;
- } else if ((bits & Lucene40FieldInfosWriter.OMIT_TERM_FREQ_AND_POSITIONS) != 0) {
+ } else if ((bits & Lucene40FieldInfosFormat.OMIT_TERM_FREQ_AND_POSITIONS) != 0) {
indexOptions = IndexOptions.DOCS_ONLY;
- } else if ((bits & Lucene40FieldInfosWriter.OMIT_POSITIONS) != 0) {
+ } else if ((bits & Lucene40FieldInfosFormat.OMIT_POSITIONS) != 0) {
indexOptions = IndexOptions.DOCS_AND_FREQS;
- } else if ((bits & Lucene40FieldInfosWriter.STORE_OFFSETS_IN_POSTINGS) != 0) {
+ } else if ((bits & Lucene40FieldInfosFormat.STORE_OFFSETS_IN_POSTINGS) != 0) {
indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
} else {
indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
@@ -89,11 +91,20 @@ public class Lucene40FieldInfosReader ex
}
// DV Types are packed in one byte
byte val = input.readByte();
- final DocValues.Type docValuesType = getDocValuesType((byte) (val & 0x0F));
- final DocValues.Type normsType = getDocValuesType((byte) ((val >>> 4) & 0x0F));
- final Map<String,String> attributes = input.readStringStringMap();
+ final LegacyDocValuesType oldValuesType = getDocValuesType((byte) (val & 0x0F));
+ final LegacyDocValuesType oldNormsType = getDocValuesType((byte) ((val >>> 4) & 0x0F));
+ final Map<String,String> attributes = input.readStringStringMap();;
+ if (oldValuesType.mapping != null) {
+ attributes.put(LEGACY_DV_TYPE_KEY, oldValuesType.name());
+ }
+ if (oldNormsType.mapping != null) {
+ if (oldNormsType.mapping != DocValuesType.NUMERIC) {
+ throw new CorruptIndexException("invalid norm type: " + oldNormsType);
+ }
+ attributes.put(LEGACY_NORM_TYPE_KEY, oldNormsType.name());
+ }
infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector,
- omitNorms, storePayloads, indexOptions, docValuesType, normsType, Collections.unmodifiableMap(attributes));
+ omitNorms, storePayloads, indexOptions, oldValuesType.mapping, oldNormsType.mapping, Collections.unmodifiableMap(attributes));
}
if (input.getFilePointer() != input.length()) {
@@ -110,39 +121,35 @@ public class Lucene40FieldInfosReader ex
}
}
}
-
- private static DocValues.Type getDocValuesType(final byte b) {
- switch(b) {
- case 0:
- return null;
- case 1:
- return DocValues.Type.VAR_INTS;
- case 2:
- return DocValues.Type.FLOAT_32;
- case 3:
- return DocValues.Type.FLOAT_64;
- case 4:
- return DocValues.Type.BYTES_FIXED_STRAIGHT;
- case 5:
- return DocValues.Type.BYTES_FIXED_DEREF;
- case 6:
- return DocValues.Type.BYTES_VAR_STRAIGHT;
- case 7:
- return DocValues.Type.BYTES_VAR_DEREF;
- case 8:
- return DocValues.Type.FIXED_INTS_16;
- case 9:
- return DocValues.Type.FIXED_INTS_32;
- case 10:
- return DocValues.Type.FIXED_INTS_64;
- case 11:
- return DocValues.Type.FIXED_INTS_8;
- case 12:
- return DocValues.Type.BYTES_FIXED_SORTED;
- case 13:
- return DocValues.Type.BYTES_VAR_SORTED;
- default:
- throw new IllegalStateException("unhandled indexValues type " + b);
+
+ static final String LEGACY_DV_TYPE_KEY = Lucene40FieldInfosReader.class.getSimpleName() + ".dvtype";
+ static final String LEGACY_NORM_TYPE_KEY = Lucene40FieldInfosReader.class.getSimpleName() + ".normtype";
+
+ // mapping of 4.0 types -> 4.2 types
+ static enum LegacyDocValuesType {
+ NONE(null),
+ VAR_INTS(DocValuesType.NUMERIC),
+ FLOAT_32(DocValuesType.NUMERIC),
+ FLOAT_64(DocValuesType.NUMERIC),
+ BYTES_FIXED_STRAIGHT(DocValuesType.BINARY),
+ BYTES_FIXED_DEREF(DocValuesType.BINARY),
+ BYTES_VAR_STRAIGHT(DocValuesType.BINARY),
+ BYTES_VAR_DEREF(DocValuesType.BINARY),
+ FIXED_INTS_16(DocValuesType.NUMERIC),
+ FIXED_INTS_32(DocValuesType.NUMERIC),
+ FIXED_INTS_64(DocValuesType.NUMERIC),
+ FIXED_INTS_8(DocValuesType.NUMERIC),
+ BYTES_FIXED_SORTED(DocValuesType.SORTED),
+ BYTES_VAR_SORTED(DocValuesType.SORTED);
+
+ final DocValuesType mapping;
+ LegacyDocValuesType(DocValuesType mapping) {
+ this.mapping = mapping;
}
}
+
+ // decodes a 4.0 type
+ private static LegacyDocValuesType getDocValuesType(byte b) {
+ return LegacyDocValuesType.values()[b];
+ }
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsBaseFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsBaseFormat.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsBaseFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsBaseFormat.java Fri Feb 8 03:26:14 2013
@@ -42,7 +42,7 @@ public final class Lucene40PostingsBaseF
@Override
public PostingsReaderBase postingsReaderBase(SegmentReadState state) throws IOException {
- return new Lucene40PostingsReader(state.dir, state.fieldInfos, state.segmentInfo, state.context, state.segmentSuffix);
+ return new Lucene40PostingsReader(state.directory, state.fieldInfos, state.segmentInfo, state.context, state.segmentSuffix);
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40PostingsFormat.java Fri Feb 8 03:26:14 2013
@@ -248,12 +248,12 @@ public class Lucene40PostingsFormat exte
@Override
public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException {
- PostingsReaderBase postings = new Lucene40PostingsReader(state.dir, state.fieldInfos, state.segmentInfo, state.context, state.segmentSuffix);
+ PostingsReaderBase postings = new Lucene40PostingsReader(state.directory, state.fieldInfos, state.segmentInfo, state.context, state.segmentSuffix);
boolean success = false;
try {
FieldsProducer ret = new BlockTreeTermsReader(
- state.dir,
+ state.directory,
state.fieldInfos,
state.segmentInfo,
postings,
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/package.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/package.html?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/package.html (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/package.html Fri Feb 8 03:26:14 2013
@@ -363,11 +363,11 @@ file, previously they were stored in tex
frequencies.</li>
<li>In version 4.0, the format of the inverted index became extensible via
the {@link org.apache.lucene.codecs.Codec Codec} api. Fast per-document storage
-({@link org.apache.lucene.index.DocValues DocValues}) was introduced. Normalization
-factors need no longer be a single byte, they can be any DocValues
-{@link org.apache.lucene.index.DocValues.Type type}. Terms need not be unicode
-strings, they can be any byte sequence. Term offsets can optionally be indexed
-into the postings lists. Payloads can be stored in the term vectors.</li>
+({@code DocValues}) was introduced. Normalization factors need no longer be a
+single byte, they can be any {@link org.apache.lucene.index.NumericDocValues NumericDocValues}.
+Terms need not be unicode strings, they can be any byte sequence. Term offsets
+can optionally be indexed into the postings lists. Payloads can be stored in the
+term vectors.</li>
</ul>
<a name="Limitations" id="Limitations"></a>
<h2>Limitations</h2>
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41Codec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41Codec.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41Codec.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41Codec.java Fri Feb 8 03:26:14 2013
@@ -20,19 +20,19 @@ package org.apache.lucene.codecs.lucene4
import java.io.IOException;
import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.codecs.FilterCodec;
import org.apache.lucene.codecs.LiveDocsFormat;
-import org.apache.lucene.codecs.NormsFormat;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.SegmentInfoFormat;
+import org.apache.lucene.codecs.DocValuesFormat;
+import org.apache.lucene.codecs.NormsFormat;
import org.apache.lucene.codecs.StoredFieldsFormat;
import org.apache.lucene.codecs.StoredFieldsWriter;
import org.apache.lucene.codecs.TermVectorsFormat;
-import org.apache.lucene.codecs.lucene40.Lucene40DocValuesFormat;
import org.apache.lucene.codecs.compressing.CompressingStoredFieldsFormat;
import org.apache.lucene.codecs.compressing.CompressionMode;
+import org.apache.lucene.codecs.lucene40.Lucene40DocValuesFormat;
import org.apache.lucene.codecs.lucene40.Lucene40FieldInfosFormat;
import org.apache.lucene.codecs.lucene40.Lucene40LiveDocsFormat;
import org.apache.lucene.codecs.lucene40.Lucene40NormsFormat;
@@ -64,9 +64,7 @@ public class Lucene41Codec extends Codec
};
private final TermVectorsFormat vectorsFormat = new Lucene40TermVectorsFormat();
private final FieldInfosFormat fieldInfosFormat = new Lucene40FieldInfosFormat();
- private final DocValuesFormat docValuesFormat = new Lucene40DocValuesFormat();
private final SegmentInfoFormat infosFormat = new Lucene40SegmentInfoFormat();
- private final NormsFormat normsFormat = new Lucene40NormsFormat();
private final LiveDocsFormat liveDocsFormat = new Lucene40LiveDocsFormat();
private final PostingsFormat postingsFormat = new PerFieldPostingsFormat() {
@@ -93,17 +91,12 @@ public class Lucene41Codec extends Codec
}
@Override
- public final DocValuesFormat docValuesFormat() {
- return docValuesFormat;
- }
-
- @Override
public final PostingsFormat postingsFormat() {
return postingsFormat;
}
@Override
- public final FieldInfosFormat fieldInfosFormat() {
+ public FieldInfosFormat fieldInfosFormat() {
return fieldInfosFormat;
}
@@ -111,11 +104,6 @@ public class Lucene41Codec extends Codec
public final SegmentInfoFormat segmentInfoFormat() {
return infosFormat;
}
-
- @Override
- public final NormsFormat normsFormat() {
- return normsFormat;
- }
@Override
public final LiveDocsFormat liveDocsFormat() {
@@ -131,5 +119,17 @@ public class Lucene41Codec extends Codec
return defaultFormat;
}
+ @Override
+ public DocValuesFormat docValuesFormat() {
+ return dvFormat;
+ }
+
private final PostingsFormat defaultFormat = PostingsFormat.forName("Lucene41");
+ private final DocValuesFormat dvFormat = new Lucene40DocValuesFormat();
+ private final NormsFormat normsFormat = new Lucene40NormsFormat();
+
+ @Override
+ public NormsFormat normsFormat() {
+ return normsFormat;
+ }
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsBaseFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsBaseFormat.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsBaseFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsBaseFormat.java Fri Feb 8 03:26:14 2013
@@ -41,7 +41,7 @@ public final class Lucene41PostingsBaseF
@Override
public PostingsReaderBase postingsReaderBase(SegmentReadState state) throws IOException {
- return new Lucene41PostingsReader(state.dir, state.fieldInfos, state.segmentInfo, state.context, state.segmentSuffix);
+ return new Lucene41PostingsReader(state.directory, state.fieldInfos, state.segmentInfo, state.context, state.segmentSuffix);
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsFormat.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsFormat.java Fri Feb 8 03:26:14 2013
@@ -427,14 +427,14 @@ public final class Lucene41PostingsForma
@Override
public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException {
- PostingsReaderBase postingsReader = new Lucene41PostingsReader(state.dir,
+ PostingsReaderBase postingsReader = new Lucene41PostingsReader(state.directory,
state.fieldInfos,
state.segmentInfo,
state.context,
state.segmentSuffix);
boolean success = false;
try {
- FieldsProducer ret = new BlockTreeTermsReader(state.dir,
+ FieldsProducer ret = new BlockTreeTermsReader(state.directory,
state.fieldInfos,
state.segmentInfo,
postingsReader,
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/package.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/package.html?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/package.html (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene41/package.html Fri Feb 8 03:26:14 2013
@@ -368,11 +368,11 @@ file, previously they were stored in tex
frequencies.</li>
<li>In version 4.0, the format of the inverted index became extensible via
the {@link org.apache.lucene.codecs.Codec Codec} api. Fast per-document storage
-({@link org.apache.lucene.index.DocValues DocValues}) was introduced. Normalization
-factors need no longer be a single byte, they can be any DocValues
-{@link org.apache.lucene.index.DocValues.Type type}. Terms need not be unicode
-strings, they can be any byte sequence. Term offsets can optionally be indexed
-into the postings lists. Payloads can be stored in the term vectors.</li>
+({@code DocValues}) was introduced. Normalization factors need no longer be a
+single byte, they can be any {@link org.apache.lucene.index.NumericDocValues NumericDocValues}.
+Terms need not be unicode strings, they can be any byte sequence. Term offsets
+can optionally be indexed into the postings lists. Payloads can be stored in the
+term vectors.</li>
<li>In version 4.1, the format of the postings list changed to use either
of FOR compression or variable-byte encoding, depending upon the frequency
of the term.</li>
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/perfield/PerFieldPostingsFormat.java Fri Feb 8 03:26:14 2013
@@ -37,7 +37,7 @@ import org.apache.lucene.index.Terms;
import org.apache.lucene.util.IOUtils;
/**
- * Enables per field format support.
+ * Enables per field postings support.
* <p>
* Note, when extending this class, the name ({@link #getName}) is
* written into the index. In order for the field to be read, the
Copied: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/BinaryDocValuesField.java (from r1443717, lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/document/BinaryDocValuesField.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/BinaryDocValuesField.java?p2=lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/BinaryDocValuesField.java&p1=lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/document/BinaryDocValuesField.java&r1=1443717&r2=1443834&rev=1443834&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/document/BinaryDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/BinaryDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -39,7 +39,7 @@ import org.apache.lucene.util.BytesRef;
*
* @see BinaryDocValues
* */
-public class BinaryDocValuesField extends StoredField {
+public class BinaryDocValuesField extends Field {
/**
* Type for straight bytes DocValues.
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -17,7 +17,7 @@ package org.apache.lucene.document;
* limitations under the License.
*/
-import org.apache.lucene.index.DocValues;
+import org.apache.lucene.index.NumericDocValues;
/**
* <p>
@@ -32,19 +32,12 @@ import org.apache.lucene.index.DocValues
* If you also need to store the value, you should add a
* separate {@link StoredField} instance.
*
- * @see DocValues
+ * @see NumericDocValues
+ * @deprecated use {@link NumericDocValuesField} instead.
* */
-public class ByteDocValuesField extends Field {
-
- /**
- * Type for 8-bit byte DocValues.
- */
- public static final FieldType TYPE = new FieldType();
- static {
- TYPE.setDocValueType(DocValues.Type.FIXED_INTS_8);
- TYPE.freeze();
- }
+@Deprecated
+public class ByteDocValuesField extends NumericDocValuesField {
/**
* Creates a new DocValues field with the specified 8-bit byte value
@@ -53,7 +46,11 @@ public class ByteDocValuesField extends
* @throws IllegalArgumentException if the field name is null.
*/
public ByteDocValuesField(String name, byte value) {
- super(name, TYPE);
- fieldsData = Byte.valueOf(value);
+ super(name, value);
+ }
+
+ @Override
+ public void setByteValue(byte value) {
+ setLongValue(value);
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -17,18 +17,13 @@ package org.apache.lucene.document;
* limitations under the License.
*/
-import org.apache.lucene.index.DocValues;
+import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.util.BytesRef;
/**
* <p>
* Field that stores
- * a per-document {@link BytesRef} value. The values are
- * stored indirectly, such that many documents sharing the
- * same value all point to a single copy of the value, which
- * is a good fit when the fields share values. If values
- * are (mostly) unique it's better to use {@link
- * StraightBytesDocValuesField}. Here's an example usage:
+ * a per-document {@link BytesRef} value. Here's an example usage:
*
* <pre class="prettyprint">
* document.add(new DerefBytesDocValuesField(name, new BytesRef("hello")));
@@ -38,57 +33,41 @@ import org.apache.lucene.util.BytesRef;
* If you also need to store the value, you should add a
* separate {@link StoredField} instance.
*
- * @see DocValues
+ * @see BinaryDocValues
+ * @deprecated Use {@link BinaryDocValuesField} instead.
* */
+@Deprecated
+public class DerefBytesDocValuesField extends BinaryDocValuesField {
-public class DerefBytesDocValuesField extends Field {
-
- // TODO: ideally indexer figures out var vs fixed on its own!?
/**
- * Type for indirect bytes DocValues: all with the same length
+ * Type for bytes DocValues: all with the same length
*/
- public static final FieldType TYPE_FIXED_LEN = new FieldType();
- static {
- TYPE_FIXED_LEN.setDocValueType(DocValues.Type.BYTES_FIXED_DEREF);
- TYPE_FIXED_LEN.freeze();
- }
+ public static final FieldType TYPE_FIXED_LEN = BinaryDocValuesField.TYPE;
/**
- * Type for indirect bytes DocValues: can have variable lengths
+ * Type for bytes DocValues: can have variable lengths
*/
- public static final FieldType TYPE_VAR_LEN = new FieldType();
- static {
- TYPE_VAR_LEN.setDocValueType(DocValues.Type.BYTES_VAR_DEREF);
- TYPE_VAR_LEN.freeze();
- }
+ public static final FieldType TYPE_VAR_LEN = BinaryDocValuesField.TYPE;
/**
- * Create a new variable-length indirect DocValues field.
- * <p>
- * This calls
- * {@link DerefBytesDocValuesField#DerefBytesDocValuesField(String, BytesRef, boolean)
- * DerefBytesDocValuesField(name, bytes, false}, meaning by default
- * it allows for values of different lengths. If your values are all
- * the same length, use that constructor instead.
+ * Create a new fixed or variable-length DocValues field.
* @param name field name
* @param bytes binary content
* @throws IllegalArgumentException if the field name is null
*/
public DerefBytesDocValuesField(String name, BytesRef bytes) {
- super(name, TYPE_VAR_LEN);
- fieldsData = bytes;
+ super(name, bytes);
}
/**
- * Create a new fixed or variable length indirect DocValues field.
+ * Create a new fixed or variable length DocValues field.
* <p>
* @param name field name
* @param bytes binary content
- * @param isFixedLength true if all values have the same length.
+ * @param isFixedLength (ignored)
* @throws IllegalArgumentException if the field name is null
*/
public DerefBytesDocValuesField(String name, BytesRef bytes, boolean isFixedLength) {
- super(name, isFixedLength ? TYPE_FIXED_LEN : TYPE_VAR_LEN);
- fieldsData = bytes;
+ super(name, bytes);
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -17,34 +17,21 @@ package org.apache.lucene.document;
* limitations under the License.
*/
-import org.apache.lucene.index.DocValues;
+import org.apache.lucene.index.AtomicReader; // javadocs
+import org.apache.lucene.search.FieldCache; // javadocs
/**
+ * Syntactic sugar for encoding doubles as NumericDocValues
+ * via {@link Double#doubleToRawLongBits(double)}.
* <p>
- * Field that stores a per-document <code>double</code> value for scoring,
- * sorting or value retrieval. Here's an example usage:
- *
- * <pre class="prettyprint">
- * document.add(new DoubleDocValuesField(name, 22.0));
- * </pre>
- *
+ * Per-document double values can be retrieved via
+ * {@link FieldCache#getDoubles(AtomicReader, String, boolean)}.
* <p>
- * If you also need to store the value, you should add a
- * separate {@link StoredField} instance.
- *
- * @see DocValues
- * */
-
-public class DoubleDocValuesField extends Field {
-
- /**
- * Type for 64-bit double DocValues.
- */
- public static final FieldType TYPE = new FieldType();
- static {
- TYPE.setDocValueType(DocValues.Type.FLOAT_64);
- TYPE.freeze();
- }
+ * <b>NOTE</b>: In most all cases this will be rather inefficient,
+ * requiring eight bytes per document. Consider encoding double
+ * values yourself with only as much precision as you require.
+ */
+public class DoubleDocValuesField extends NumericDocValuesField {
/**
* Creates a new DocValues field with the specified 64-bit double value
@@ -53,7 +40,16 @@ public class DoubleDocValuesField extend
* @throws IllegalArgumentException if the field name is null
*/
public DoubleDocValuesField(String name, double value) {
- super(name, TYPE);
- fieldsData = Double.valueOf(value);
+ super(name, Double.doubleToRawLongBits(value));
+ }
+
+ @Override
+ public void setDoubleValue(double value) {
+ super.setLongValue(Double.doubleToRawLongBits(value));
+ }
+
+ @Override
+ public void setLongValue(long value) {
+ throw new IllegalArgumentException("cannot change value type from Double to Long");
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/Field.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/Field.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/Field.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/Field.java Fri Feb 8 03:26:14 2013
@@ -29,7 +29,6 @@ import org.apache.lucene.document.FieldT
import org.apache.lucene.index.IndexWriter; // javadocs
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.IndexableFieldType;
-import org.apache.lucene.index.Norm; // javadocs
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.index.FieldInvertState; // javadocs
@@ -37,13 +36,8 @@ import org.apache.lucene.index.FieldInve
* Expert: directly create a field for a document. Most
* users should use one of the sugar subclasses: {@link
* IntField}, {@link LongField}, {@link FloatField}, {@link
- * DoubleField}, {@link ByteDocValuesField}, {@link
- * ShortDocValuesField}, {@link IntDocValuesField}, {@link
- * LongDocValuesField}, {@link PackedLongDocValuesField},
- * {@link FloatDocValuesField}, {@link
- * DoubleDocValuesField}, {@link SortedBytesDocValuesField},
- * {@link DerefBytesDocValuesField}, {@link
- * StraightBytesDocValuesField}, {@link
+ * DoubleField}, {@link BinaryDocValuesField}, {@link
+ * NumericDocValuesField}, {@link SortedDocValuesField}, {@link
* StringField}, {@link TextField}, {@link StoredField}.
*
* <p/> A field is a section of a Document. Each field has three
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/FieldType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/FieldType.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/FieldType.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/FieldType.java Fri Feb 8 03:26:14 2013
@@ -18,7 +18,7 @@ package org.apache.lucene.document;
*/
import org.apache.lucene.analysis.Analyzer; // javadocs
-import org.apache.lucene.index.DocValues;
+import org.apache.lucene.index.FieldInfo.DocValuesType;
import org.apache.lucene.index.FieldInfo.IndexOptions;
import org.apache.lucene.index.IndexableFieldType;
import org.apache.lucene.search.NumericRangeQuery; // javadocs
@@ -52,10 +52,10 @@ public class FieldType implements Indexa
private boolean storeTermVectorPayloads;
private boolean omitNorms;
private IndexOptions indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
- private DocValues.Type docValueType;
private NumericType numericType;
private boolean frozen;
private int numericPrecisionStep = NumericUtils.PRECISION_STEP_DEFAULT;
+ private DocValuesType docValueType;
/**
* Create a new mutable FieldType with all of the properties from <code>ref</code>
@@ -309,29 +309,6 @@ public class FieldType implements Indexa
}
/**
- * Set's the field's DocValues.Type
- * @param type DocValues type, or null if no DocValues should be stored.
- * @throws IllegalStateException if this FieldType is frozen against
- * future modifications.
- * @see #docValueType()
- */
- public void setDocValueType(DocValues.Type type) {
- checkIfFrozen();
- docValueType = type;
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * The default is <code>null</code> (no docValues)
- * @see #setDocValueType(DocValues.Type)
- */
- @Override
- public DocValues.Type docValueType() {
- return docValueType;
- }
-
- /**
* Specifies the field's numeric type.
* @param type numeric type, or null if the field has no numeric type.
* @throws IllegalStateException if this FieldType is frozen against
@@ -432,4 +409,27 @@ public class FieldType implements Indexa
return result.toString();
}
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * The default is <code>null</code> (no docValues)
+ * @see #setDocValueType(org.apache.lucene.index.FieldInfo.DocValuesType)
+ */
+ @Override
+ public DocValuesType docValueType() {
+ return docValueType;
+ }
+
+ /**
+ * Set's the field's DocValuesType
+ * @param type DocValues type, or null if no DocValues should be stored.
+ * @throws IllegalStateException if this FieldType is frozen against
+ * future modifications.
+ * @see #docValueType()
+ */
+ public void setDocValueType(DocValuesType type) {
+ checkIfFrozen();
+ docValueType = type;
+ }
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -17,33 +17,21 @@ package org.apache.lucene.document;
* limitations under the License.
*/
-import org.apache.lucene.index.DocValues;
+import org.apache.lucene.index.AtomicReader; // javadocs
+import org.apache.lucene.search.FieldCache; // javadocs
/**
+ * Syntactic sugar for encoding floats as NumericDocValues
+ * via {@link Float#floatToRawIntBits(float)}.
* <p>
- * Field that stores a per-document <code>float</code> value for scoring,
- * sorting or value retrieval. Here's an example usage:
- *
- * <pre class="prettyprint">
- * document.add(new FloatDocValuesField(name, 22f));
- * </pre>
- *
+ * Per-document floating point values can be retrieved via
+ * {@link FieldCache#getFloats(AtomicReader, String, boolean)}.
* <p>
- * If you also need to store the value, you should add a
- * separate {@link StoredField} instance.
- * @see DocValues
- * */
-
-public class FloatDocValuesField extends Field {
-
- /**
- * Type for 32-bit float DocValues.
- */
- public static final FieldType TYPE = new FieldType();
- static {
- TYPE.setDocValueType(DocValues.Type.FLOAT_32);
- TYPE.freeze();
- }
+ * <b>NOTE</b>: In most all cases this will be rather inefficient,
+ * requiring four bytes per document. Consider encoding floating
+ * point values yourself with only as much precision as you require.
+ */
+public class FloatDocValuesField extends NumericDocValuesField {
/**
* Creates a new DocValues field with the specified 32-bit float value
@@ -52,7 +40,16 @@ public class FloatDocValuesField extends
* @throws IllegalArgumentException if the field name is null
*/
public FloatDocValuesField(String name, float value) {
- super(name, TYPE);
- fieldsData = Float.valueOf(value);
+ super(name, Float.floatToRawIntBits(value));
+ }
+
+ @Override
+ public void setFloatValue(float value) {
+ super.setLongValue(Float.floatToRawIntBits(value));
+ }
+
+ @Override
+ public void setLongValue(long value) {
+ throw new IllegalArgumentException("cannot change value type from Float to Long");
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -17,7 +17,7 @@ package org.apache.lucene.document;
* limitations under the License.
*/
-import org.apache.lucene.index.DocValues;
+import org.apache.lucene.index.NumericDocValues;
/**
* <p>
@@ -31,19 +31,11 @@ import org.apache.lucene.index.DocValues
* <p>
* If you also need to store the value, you should add a
* separate {@link StoredField} instance.
- * @see DocValues
+ * @see NumericDocValues
+ * @deprecated use {@link NumericDocValuesField} instead.
* */
-
-public class IntDocValuesField extends Field {
-
- /**
- * Type for 32-bit integer DocValues.
- */
- public static final FieldType TYPE = new FieldType();
- static {
- TYPE.setDocValueType(DocValues.Type.FIXED_INTS_32);
- TYPE.freeze();
- }
+@Deprecated
+public class IntDocValuesField extends NumericDocValuesField {
/**
* Creates a new DocValues field with the specified 32-bit integer value
@@ -52,7 +44,11 @@ public class IntDocValuesField extends F
* @throws IllegalArgumentException if the field name is null
*/
public IntDocValuesField(String name, int value) {
- super(name, TYPE);
- fieldsData = Integer.valueOf(value);
+ super(name, value);
+ }
+
+ @Override
+ public void setIntValue(int value) {
+ setLongValue(value);
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -17,7 +17,7 @@ package org.apache.lucene.document;
* limitations under the License.
*/
-import org.apache.lucene.index.DocValues;
+import org.apache.lucene.index.NumericDocValues;
/**
* <p>
@@ -31,19 +31,11 @@ import org.apache.lucene.index.DocValues
* <p>
* If you also need to store the value, you should add a
* separate {@link StoredField} instance.
- * @see DocValues
+ * @see NumericDocValues
+ * @deprecated use {@link NumericDocValuesField} instead.
* */
-
-public class LongDocValuesField extends Field {
-
- /**
- * Type for 64-bit long DocValues.
- */
- public static final FieldType TYPE = new FieldType();
- static {
- TYPE.setDocValueType(DocValues.Type.FIXED_INTS_64);
- TYPE.freeze();
- }
+@Deprecated
+public class LongDocValuesField extends NumericDocValuesField {
/**
* Creates a new DocValues field with the specified 64-bit long value
@@ -52,7 +44,6 @@ public class LongDocValuesField extends
* @throws IllegalArgumentException if the field name is null
*/
public LongDocValuesField(String name, long value) {
- super(name, TYPE);
- fieldsData = Long.valueOf(value);
+ super(name, value);
}
}
Copied: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/NumericDocValuesField.java (from r1443717, lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/document/NumericDocValuesField.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/NumericDocValuesField.java?p2=lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/NumericDocValuesField.java&p1=lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/document/NumericDocValuesField.java&r1=1443717&r2=1443834&rev=1443834&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/document/NumericDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/NumericDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -33,7 +33,7 @@ import org.apache.lucene.index.FieldInfo
* separate {@link StoredField} instance.
* */
-public class NumericDocValuesField extends StoredField {
+public class NumericDocValuesField extends Field {
/**
* Type for numeric DocValues.
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -17,16 +17,12 @@ package org.apache.lucene.document;
* limitations under the License.
*/
-import org.apache.lucene.index.DocValues;
-import org.apache.lucene.index.AtomicReader; // javadocs
+import org.apache.lucene.index.NumericDocValues;
/**
* <p>
* Field that stores a per-document <code>long</code> value
- * for scoring, sorting or value retrieval. The values are
- * encoded in the index an in RAM (when loaded via
- * {@link AtomicReader#docValues})
- * using packed ints. Here's an example usage:
+ * for scoring, sorting or value retrieval. Here's an example usage:
*
* <pre class="prettyprint">
* document.add(new PackedLongDocValuesField(name, 22L));
@@ -36,19 +32,11 @@ import org.apache.lucene.index.AtomicRea
* If you also need to store the value, you should add a
* separate {@link StoredField} instance.
*
- * @see DocValues
+ * @see NumericDocValues
+ * @deprecated use {@link NumericDocValuesField} instead.
* */
-
-public class PackedLongDocValuesField extends Field {
-
- /**
- * Type for packed long DocValues.
- */
- public static final FieldType TYPE = new FieldType();
- static {
- TYPE.setDocValueType(DocValues.Type.VAR_INTS);
- TYPE.freeze();
- }
+@Deprecated
+public class PackedLongDocValuesField extends NumericDocValuesField {
/**
* Creates a new DocValues field with the specified long value
@@ -57,7 +45,6 @@ public class PackedLongDocValuesField ex
* @throws IllegalArgumentException if the field name is null
*/
public PackedLongDocValuesField(String name, long value) {
- super(name, TYPE);
- fieldsData = Long.valueOf(value);
+ super(name, value);
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -17,7 +17,7 @@ package org.apache.lucene.document;
* limitations under the License.
*/
-import org.apache.lucene.index.DocValues;
+import org.apache.lucene.index.NumericDocValues;
/**
* <p>
@@ -32,19 +32,11 @@ import org.apache.lucene.index.DocValues
* If you also need to store the value, you should add a
* separate {@link StoredField} instance.
*
- * @see DocValues
+ * @see NumericDocValues
+ * @deprecated use {@link NumericDocValuesField} instead.
* */
-
-public class ShortDocValuesField extends Field {
-
- /**
- * Type for 16-bit short DocValues.
- */
- public static final FieldType TYPE = new FieldType();
- static {
- TYPE.setDocValueType(DocValues.Type.FIXED_INTS_16);
- TYPE.freeze();
- }
+@Deprecated
+public class ShortDocValuesField extends NumericDocValuesField {
/**
* Creates a new DocValues field with the specified 16-bit short value
@@ -53,7 +45,11 @@ public class ShortDocValuesField extends
* @throws IllegalArgumentException if the field name is null
*/
public ShortDocValuesField(String name, short value) {
- super(name, TYPE);
- fieldsData = Short.valueOf(value);
+ super(name, value);
+ }
+
+ @Override
+ public void setShortValue(short value) {
+ setLongValue(value);
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -17,7 +17,7 @@ package org.apache.lucene.document;
* limitations under the License.
*/
-import org.apache.lucene.index.DocValues;
+import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.util.BytesRef;
/**
@@ -34,55 +34,40 @@ import org.apache.lucene.util.BytesRef;
* If you also need to store the value, you should add a
* separate {@link StoredField} instance.
*
- * @see DocValues
+ * @see SortedDocValues
+ * @deprecated Use {@link SortedDocValuesField} instead.
* */
+@Deprecated
+public class SortedBytesDocValuesField extends SortedDocValuesField {
-public class SortedBytesDocValuesField extends Field {
-
- // TODO: ideally indexer figures out var vs fixed on its own!?
/**
* Type for sorted bytes DocValues: all with the same length
*/
- public static final FieldType TYPE_FIXED_LEN = new FieldType();
- static {
- TYPE_FIXED_LEN.setDocValueType(DocValues.Type.BYTES_FIXED_SORTED);
- TYPE_FIXED_LEN.freeze();
- }
+ public static final FieldType TYPE_FIXED_LEN = SortedDocValuesField.TYPE;
/**
* Type for sorted bytes DocValues: can have variable lengths
*/
- public static final FieldType TYPE_VAR_LEN = new FieldType();
- static {
- TYPE_VAR_LEN.setDocValueType(DocValues.Type.BYTES_VAR_SORTED);
- TYPE_VAR_LEN.freeze();
- }
+ public static final FieldType TYPE_VAR_LEN = SortedDocValuesField.TYPE;
/**
- * Create a new variable-length sorted DocValues field.
- * <p>
- * This calls
- * {@link SortedBytesDocValuesField#SortedBytesDocValuesField(String, BytesRef, boolean)
- * SortedBytesDocValuesField(name, bytes, false}, meaning by default
- * it allows for values of different lengths. If your values are all
- * the same length, use that constructor instead.
+ * Create a new fixed or variable-length sorted DocValues field.
* @param name field name
* @param bytes binary content
* @throws IllegalArgumentException if the field name is null
*/
public SortedBytesDocValuesField(String name, BytesRef bytes) {
- this(name, bytes, false);
+ super(name, bytes);
}
/**
* Create a new fixed or variable length sorted DocValues field.
* @param name field name
* @param bytes binary content
- * @param isFixedLength true if all values have the same length.
+ * @param isFixedLength (ignored)
* @throws IllegalArgumentException if the field name is null
*/
public SortedBytesDocValuesField(String name, BytesRef bytes, boolean isFixedLength) {
- super(name, isFixedLength ? TYPE_FIXED_LEN : TYPE_VAR_LEN);
- fieldsData = bytes;
+ super(name, bytes);
}
}
Copied: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/SortedDocValuesField.java (from r1443717, lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/document/SortedDocValuesField.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/SortedDocValuesField.java?p2=lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/SortedDocValuesField.java&p1=lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/document/SortedDocValuesField.java&r1=1443717&r2=1443834&rev=1443834&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/document/SortedDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/SortedDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -36,7 +36,7 @@ import org.apache.lucene.util.BytesRef;
*
* */
-public class SortedDocValuesField extends StoredField {
+public class SortedDocValuesField extends Field {
/**
* Type for sorted bytes DocValues
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java Fri Feb 8 03:26:14 2013
@@ -17,17 +17,14 @@ package org.apache.lucene.document;
* limitations under the License.
*/
-import org.apache.lucene.index.DocValues;
+import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.util.BytesRef;
/**
* <p>
* Field that stores
- * a per-document {@link BytesRef} value. The values are
- * stored directly with no sharing, which is a good fit when
- * the fields don't share (many) values, such as a title
- * field. If values may be shared it's better to use {@link
- * DerefBytesDocValuesField}. Here's an example usage:
+ * a per-document {@link BytesRef} value. If values may be shared it's
+ * better to use {@link SortedDocValuesField}. Here's an example usage:
*
* <pre class="prettyprint">
* document.add(new StraightBytesDocValuesField(name, new BytesRef("hello")));
@@ -37,57 +34,40 @@ import org.apache.lucene.util.BytesRef;
* If you also need to store the value, you should add a
* separate {@link StoredField} instance.
*
- * @see DocValues
+ * @see BinaryDocValues
+ * @deprecated Use {@link BinaryDocValuesField} instead.
* */
+@Deprecated
+public class StraightBytesDocValuesField extends BinaryDocValuesField {
-public class StraightBytesDocValuesField extends Field {
-
- // TODO: ideally indexer figures out var vs fixed on its own!?
/**
* Type for direct bytes DocValues: all with the same length
*/
- public static final FieldType TYPE_FIXED_LEN = new FieldType();
- static {
- TYPE_FIXED_LEN.setDocValueType(DocValues.Type.BYTES_FIXED_STRAIGHT);
- TYPE_FIXED_LEN.freeze();
- }
+ public static final FieldType TYPE_FIXED_LEN = BinaryDocValuesField.TYPE;
/**
* Type for direct bytes DocValues: can have variable lengths
*/
- public static final FieldType TYPE_VAR_LEN = new FieldType();
- static {
- TYPE_VAR_LEN.setDocValueType(DocValues.Type.BYTES_VAR_STRAIGHT);
- TYPE_VAR_LEN.freeze();
- }
+ public static final FieldType TYPE_VAR_LEN = BinaryDocValuesField.TYPE;
/**
- * Create a new variable-length direct DocValues field.
- * <p>
- * This calls
- * {@link StraightBytesDocValuesField#StraightBytesDocValuesField(String, BytesRef, boolean)
- * StraightBytesDocValuesField(name, bytes, false}, meaning by default
- * it allows for values of different lengths. If your values are all
- * the same length, use that constructor instead.
+ * Create a new fixed or variable length DocValues field.
* @param name field name
* @param bytes binary content
* @throws IllegalArgumentException if the field name is null
*/
public StraightBytesDocValuesField(String name, BytesRef bytes) {
- super(name, TYPE_VAR_LEN);
- fieldsData = bytes;
+ super(name, bytes);
}
/**
* Create a new fixed or variable length direct DocValues field.
- * <p>
* @param name field name
* @param bytes binary content
- * @param isFixedLength true if all values have the same length.
+ * @param isFixedLength (ignored)
* @throws IllegalArgumentException if the field name is null
*/
public StraightBytesDocValuesField(String name, BytesRef bytes, boolean isFixedLength) {
- super(name, isFixedLength ? TYPE_FIXED_LEN : TYPE_VAR_LEN);
- fieldsData = bytes;
+ super(name, bytes);
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java?rev=1443834&r1=1443833&r2=1443834&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java Fri Feb 8 03:26:14 2013
@@ -169,19 +169,30 @@ public abstract class AtomicReader exten
}
return null;
}
-
- /**
- * Returns {@link DocValues} for this field.
- * This method may return null if the reader has no per-document
- * values stored.
- */
- public abstract DocValues docValues(String field) throws IOException;
-
- /**
- * Returns {@link DocValues} for this field's normalization values.
- * This method may return null if the field has no norms.
- */
- public abstract DocValues normValues(String field) throws IOException;
+
+ /** Returns {@link NumericDocValues} for this field, or
+ * null if no {@link NumericDocValues} were indexed for
+ * this field. The returned instance should only be
+ * used by a single thread. */
+ public abstract NumericDocValues getNumericDocValues(String field) throws IOException;
+
+ /** Returns {@link BinaryDocValues} for this field, or
+ * null if no {@link BinaryDocValues} were indexed for
+ * this field. The returned instance should only be
+ * used by a single thread. */
+ public abstract BinaryDocValues getBinaryDocValues(String field) throws IOException;
+
+ /** Returns {@link SortedDocValues} for this field, or
+ * null if no {@link SortedDocValues} were indexed for
+ * this field. The returned instance should only be
+ * used by a single thread. */
+ public abstract SortedDocValues getSortedDocValues(String field) throws IOException;
+
+ /** Returns {@link NumericDocValues} representing norms
+ * for this field, or null if no {@link NumericDocValues}
+ * were indexed. The returned instance should only be
+ * used by a single thread. */
+ public abstract NumericDocValues getNormValues(String field) throws IOException;
/**
* Get the {@link FieldInfos} describing all fields in