You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/01/14 00:08:22 UTC

svn commit: r1231386 - in /lucene/dev/branches/lucene3453/lucene/src: java/org/apache/lucene/document/ java/org/apache/lucene/index/ test-framework/java/org/apache/lucene/index/ test/org/apache/lucene/codecs/lucene40/ test/org/apache/lucene/index/

Author: mikemccand
Date: Fri Jan 13 23:08:21 2012
New Revision: 1231386

URL: http://svn.apache.org/viewvc?rev=1231386&view=rev
Log:
LUCENE-3453: fix last nocommits; javadocs...

Modified:
    lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/DocValuesField.java
    lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/Field.java
    lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/FieldType.java
    lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/NumericField.java
    lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/StoredField.java
    lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/StringField.java
    lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/TextField.java
    lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/index/IndexableFieldType.java
    lucene/dev/branches/lucene3453/lucene/src/test-framework/java/org/apache/lucene/index/RandomIndexWriter.java
    lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/codecs/lucene40/TestDocValues.java
    lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java
    lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/index/TestIndexableField.java

Modified: lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/DocValuesField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/DocValuesField.java?rev=1231386&r1=1231385&r2=1231386&view=diff
==============================================================================
--- lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/DocValuesField.java (original)
+++ lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/DocValuesField.java Fri Jan 13 23:08:21 2012
@@ -24,7 +24,6 @@ import java.util.Map;
 
 import org.apache.lucene.index.DocValues.Type; // javadocs
 import org.apache.lucene.index.DocValues;
-import org.apache.lucene.index.IndexableFieldType;
 import org.apache.lucene.util.BytesRef;
 
 /**
@@ -115,6 +114,7 @@ public class DocValuesField extends Fiel
     fieldsData = bytes;
   }
 
+  /*
   public DocValuesField(String name, byte value, DocValues.Type docValueType) {
     super(name, getFieldType(docValueType));
     if (!INTS.contains(docValueType)) {
@@ -130,6 +130,7 @@ public class DocValuesField extends Fiel
     }
     fieldsData = Short.valueOf(value);
   }
+  */
 
   public DocValuesField(String name, int value, DocValues.Type docValueType) {
     super(name, getFieldType(docValueType));
@@ -164,25 +165,4 @@ public class DocValuesField extends Fiel
     }
     fieldsData = Double.valueOf(value);
   }
-
-  // nocommit maybe leave this to Field ctor...?
-  public DocValuesField(String name, Object value, IndexableFieldType type) {
-    super(name, type);
-    if (type.docValueType() == null) {
-      throw new IllegalArgumentException("docValueType cannot be null");
-    }
-    if (value == null) {
-      throw new IllegalArgumentException("value cannot be null");
-    }
-    if (BYTES.contains(type.docValueType())) {
-      if (!(value instanceof BytesRef)) {
-        throw new IllegalArgumentException("value is not a BytesRef (got: " + value.getClass() + ")");
-      }
-    } else {
-      if (!(value instanceof Number)) {
-        throw new IllegalArgumentException("value is not a Number (got: " + value.getClass() + ")");
-      }
-    }
-    fieldsData = value;
-  }
 }

Modified: lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/Field.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/Field.java?rev=1231386&r1=1231385&r2=1231386&view=diff
==============================================================================
--- lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/Field.java (original)
+++ lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/Field.java Fri Jan 13 23:08:21 2012
@@ -26,15 +26,16 @@ import org.apache.lucene.analysis.Numeri
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
+import org.apache.lucene.index.IndexWriter; // javadocs
 import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.index.IndexableFieldType;
 import org.apache.lucene.util.BytesRef;
 
 /**
  * Expert: directly creata a field for a document.  Most
- * users should use one of the sugar subclasses {@link
+ * users should use one of the sugar subclasses: {@link
  * NumericField}, {@link DocValuesField}, {@link
- * StringField}, {@link TextField}, {@link BinaryField}.
+ * StringField}, {@link TextField}, {@link StoredField}.
  *
  * <p/> A field is a section of a Document. Each field has three
  * parts: name, type andvalue. Values may be text
@@ -49,8 +50,8 @@ import org.apache.lucene.util.BytesRef;
  * changes be made after Field instantiation.
  */
 public class Field implements IndexableField {
-  
-  protected final IndexableFieldType type;
+
+  protected final FieldType type;
   protected final String name;
 
   // Field's value:
@@ -66,7 +67,7 @@ public class Field implements IndexableF
 
   protected float boost = 1.0f;
 
-  protected Field(String name, IndexableFieldType type) {
+  protected Field(String name, FieldType type) {
     if (name == null) {
       throw new IllegalArgumentException("name cannot be null");
     }
@@ -77,13 +78,10 @@ public class Field implements IndexableF
     this.type = type;
   }
 
-  // nocommit ctors taking Object as fieldsData...?  ctors
-  // taking numbers...?  then why have NumericField...?
-  
   /**
    * Create field with Reader value.
    */
-  public Field(String name, Reader reader, IndexableFieldType type) {
+  public Field(String name, Reader reader, FieldType type) {
     if (name == null) {
       throw new IllegalArgumentException("name cannot be null");
     }
@@ -108,7 +106,7 @@ public class Field implements IndexableF
   /**
    * Create field with TokenStream value.
    */
-  public Field(String name, TokenStream tokenStream, IndexableFieldType type) {
+  public Field(String name, TokenStream tokenStream, FieldType type) {
     if (name == null) {
       throw new IllegalArgumentException("name cannot be null");
     }
@@ -131,14 +129,14 @@ public class Field implements IndexableF
   /**
    * Create field with binary value.
    */
-  public Field(String name, byte[] value, IndexableFieldType type) {
+  public Field(String name, byte[] value, FieldType type) {
     this(name, value, 0, value.length, type);
   }
 
   /**
    * Create field with binary value.
    */
-  public Field(String name, byte[] value, int offset, int length, IndexableFieldType type) {
+  public Field(String name, byte[] value, int offset, int length, FieldType type) {
     this(name, new BytesRef(value, offset, length), type);
   }
 
@@ -148,7 +146,7 @@ public class Field implements IndexableF
    * <p>NOTE: the provided BytesRef is not copied so be sure
    * not to change it until you're done with this field.
    */
-  public Field(String name, BytesRef bytes, IndexableFieldType type) {
+  public Field(String name, BytesRef bytes, FieldType type) {
     if (name == null) {
       throw new IllegalArgumentException("name cannot be null");
     }
@@ -163,7 +161,7 @@ public class Field implements IndexableF
   /**
    * Create field with String value.
    */
-  public Field(String name, String value, IndexableFieldType type) {
+  public Field(String name, String value, FieldType type) {
     if (name == null) {
       throw new IllegalArgumentException("name cannot be null");
     }
@@ -185,6 +183,54 @@ public class Field implements IndexableF
   }
 
   /**
+   * Create field with an int value.
+   */
+  public Field(String name, int value, FieldType type) {
+    if (name == null) {
+      throw new IllegalArgumentException("name cannot be null");
+    }
+    this.type = type;
+    this.name = name;
+    this.fieldsData = Integer.valueOf(value);
+  }
+
+  /**
+   * Create field with an long value.
+   */
+  public Field(String name, long value, FieldType type) {
+    if (name == null) {
+      throw new IllegalArgumentException("name cannot be null");
+    }
+    this.type = type;
+    this.name = name;
+    this.fieldsData = Long.valueOf(value);
+  }
+
+  /**
+   * Create field with a float value.
+   */
+  public Field(String name, float value, FieldType type) {
+    if (name == null) {
+      throw new IllegalArgumentException("name cannot be null");
+    }
+    this.type = type;
+    this.name = name;
+    this.fieldsData = Float.valueOf(value);
+  }
+
+  /**
+   * Create field with a double value.
+   */
+  public Field(String name, double value, FieldType type) {
+    if (name == null) {
+      throw new IllegalArgumentException("name cannot be null");
+    }
+    this.type = type;
+    this.name = name;
+    this.fieldsData = Double.valueOf(value);
+  }
+
+  /**
    * The value of the field as a String, or null. If null, the Reader value or
    * binary value is used. Exactly one of stringValue(), readerValue(), and
    * getBinaryValue() must be set.
@@ -269,6 +315,7 @@ public class Field implements IndexableF
     fieldsData = value;
   }
 
+  /*
   public void setValue(byte value) {
     if (!(fieldsData instanceof Byte)) {
       throw new IllegalArgumentException("cannot change value type from " + fieldsData.getClass().getSimpleName() + " to Byte");
@@ -288,6 +335,7 @@ public class Field implements IndexableF
     }
     fieldsData = Short.valueOf(value);
   }
+  */
 
   public void setValue(int value) {
     if (!(fieldsData instanceof Integer)) {
@@ -403,8 +451,8 @@ public class Field implements IndexableF
     return result.toString();
   }
   
-  /** Returns the {@link IndexableFieldType} for this field. */
-  public IndexableFieldType fieldType() {
+  /** Returns the {@link FieldType} for this field. */
+  public FieldType fieldType() {
     return type;
   }
 
@@ -565,7 +613,7 @@ public class Field implements IndexableF
     /** Expert: Index the field's value without an Analyzer,
      * and also disable the indexing of norms.  Note that you
      * can also separately enable/disable norms by calling
-     * {@link Field#setOmitNorms}.  No norms means that
+     * {@link FieldType#setOmitNorms}.  No norms means that
      * index-time field and document boosting and field
      * length normalization are disabled.  The benefit is
      * less memory usage as norms take up one byte of RAM
@@ -833,7 +881,7 @@ public class Field implements IndexableF
   /**
    * Create a tokenized and indexed field that is not stored. Term vectors will
    * not be stored.  The Reader is read only when the Document is added to the index,
-   * i.e. you may not close the Reader until {@link IndexWriter#addDocument(Document)}
+   * i.e. you may not close the Reader until {@link IndexWriter#addDocument}
    * has been called.
    * 
    * @param name The name of the field
@@ -850,7 +898,7 @@ public class Field implements IndexableF
   /**
    * Create a tokenized and indexed field that is not stored, optionally with 
    * storing term vectors.  The Reader is read only when the Document is added to the index,
-   * i.e. you may not close the Reader until {@link IndexWriter#addDocument(Document)}
+   * i.e. you may not close the Reader until {@link IndexWriter#addDocument}
    * has been called.
    * 
    * @param name The name of the field
@@ -869,7 +917,7 @@ public class Field implements IndexableF
    * Create a tokenized and indexed field that is not stored. Term vectors will
    * not be stored. This is useful for pre-analyzed fields.
    * The TokenStream is read only when the Document is added to the index,
-   * i.e. you may not close the TokenStream until {@link IndexWriter#addDocument(Document)}
+   * i.e. you may not close the TokenStream until {@link IndexWriter#addDocument}
    * has been called.
    * 
    * @param name The name of the field
@@ -887,7 +935,7 @@ public class Field implements IndexableF
    * Create a tokenized and indexed field that is not stored, optionally with 
    * storing term vectors.  This is useful for pre-analyzed fields.
    * The TokenStream is read only when the Document is added to the index,
-   * i.e. you may not close the TokenStream until {@link IndexWriter#addDocument(Document)}
+   * i.e. you may not close the TokenStream until {@link IndexWriter#addDocument}
    * has been called.
    * 
    * @param name The name of the field
@@ -908,7 +956,7 @@ public class Field implements IndexableF
    * @param name The name of the field
    * @param value The binary value
    *
-   * @deprecated Use {@link BinaryField} instead.
+   * @deprecated Use {@link StoredField} instead.
    */
   @Deprecated
   public Field(String name, byte[] value) {
@@ -923,7 +971,7 @@ public class Field implements IndexableF
    * @param offset Starting offset in value where this Field's bytes are
    * @param length Number of bytes to use for this Field, starting at offset
    *
-   * @deprecated Use {@link BinaryField} instead.
+   * @deprecated Use {@link StoredField} instead.
    */
   @Deprecated
   public Field(String name, byte[] value, int offset, int length) {

Modified: lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/FieldType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/FieldType.java?rev=1231386&r1=1231385&r2=1231386&view=diff
==============================================================================
--- lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/FieldType.java (original)
+++ lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/FieldType.java Fri Jan 13 23:08:21 2012
@@ -20,6 +20,7 @@ package org.apache.lucene.document;
 import org.apache.lucene.index.DocValues;
 import org.apache.lucene.index.FieldInfo.IndexOptions;
 import org.apache.lucene.index.IndexableFieldType;
+import org.apache.lucene.search.NumericRangeQuery; // javadocs
 import org.apache.lucene.util.NumericUtils;
 
 public class FieldType implements IndexableFieldType {
@@ -37,7 +38,7 @@ public class FieldType implements Indexa
   private boolean frozen;
   private int numericPrecisionStep = NumericUtils.PRECISION_STEP_DEFAULT;
 
-  public FieldType(IndexableFieldType ref) {
+  public FieldType(FieldType ref) {
     this.indexed = ref.indexed();
     this.stored = ref.stored();
     this.tokenized = ref.tokenized();
@@ -156,7 +157,10 @@ public class FieldType implements Indexa
     numericType = type;
   }
 
-  @Override
+  /** Numeric {@link NumericField.DataType}; if
+   *  non-null then the field's value will be indexed
+   *  numerically so that {@link NumericRangeQuery} can be
+   *  used at search time. */
   public NumericField.DataType numericType() {
     return numericType;
   }
@@ -169,7 +173,7 @@ public class FieldType implements Indexa
     this.numericPrecisionStep = precisionStep;
   }
 
-  @Override
+  /** Precision step for numeric field. */
   public int numericPrecisionStep() {
     return numericPrecisionStep;
   }

Modified: lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/NumericField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/NumericField.java?rev=1231386&r1=1231385&r2=1231386&view=diff
==============================================================================
--- lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/NumericField.java (original)
+++ lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/NumericField.java Fri Jan 13 23:08:21 2012
@@ -18,12 +18,13 @@ package org.apache.lucene.document;
  */
 
 
-import org.apache.lucene.index.FieldInfo.IndexOptions;
+import org.apache.lucene.analysis.NumericTokenStream; // javadocs
 import org.apache.lucene.document.NumericField.DataType;
-import org.apache.lucene.util.NumericUtils;
-import org.apache.lucene.search.NumericRangeQuery; // javadocs
-import org.apache.lucene.search.NumericRangeFilter; // javadocs
+import org.apache.lucene.index.FieldInfo.IndexOptions;
 import org.apache.lucene.search.FieldCache; // javadocs
+import org.apache.lucene.search.NumericRangeFilter; // javadocs
+import org.apache.lucene.search.NumericRangeQuery; // javadocs
+import org.apache.lucene.util.NumericUtils;
 
 /**
  * <p>
@@ -73,8 +74,8 @@ import org.apache.lucene.search.FieldCac
  *
  * <p>By default, a <code>NumericField</code>'s value is not stored but
  * is indexed for range filtering and sorting.  You can use
- * the {@link #NumericField(String, FieldType)}
- * constructor if you need to change these defaults.</p>
+ * {@link Field#Field(String,Number,FieldType)}
+ * if you need to change these defaults.</p>
  *
  * <p>You may add the same field name as a <code>NumericField</code> to
  * the same document more than once.  Range querying and
@@ -100,8 +101,8 @@ import org.apache.lucene.search.FieldCac
  * but may result in faster range search performance.  The
  * default value, 4, was selected for a reasonable tradeoff
  * of disk space consumption versus performance.  You can
- * use the expert constructor {@link
- * #NumericField(String,int, FieldType)} if you'd
+ * create a custom {@link FieldType} and invoke the {@link
+ * FieldType#setNumericPrecisionStep} method if you'd
  * like to change the value.  Note that you must also
  * specify a congruent value when creating {@link
  * NumericRangeQuery} or {@link NumericRangeFilter}.
@@ -133,7 +134,6 @@ public final class NumericField extends 
   /** Data type of the value in {@link NumericField}.
    * @since 3.2
    */
-  // nocommit promote to oal.index
   public static enum DataType {INT, LONG, FLOAT, DOUBLE}
 
   /** @lucene.experimental */

Modified: lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/StoredField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/StoredField.java?rev=1231386&r1=1231385&r2=1231386&view=diff
==============================================================================
--- lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/StoredField.java (original)
+++ lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/StoredField.java Fri Jan 13 23:08:21 2012
@@ -1,5 +1,7 @@
 package org.apache.lucene.document;
 
+import org.apache.lucene.index.IndexReader; // javadocs
+import org.apache.lucene.search.IndexSearcher; // javadocs
 import org.apache.lucene.util.BytesRef;
 
 /**
@@ -20,7 +22,7 @@ import org.apache.lucene.util.BytesRef;
  */
 
 /** A field whose value is stored so that {@link
- *  IndexSearcher.doc} and {@link IndexReader.doc} will
+ *  IndexSearcher#doc} and {@link IndexReader#document} will
  *  return the field and its value. */
 public final class StoredField extends Field {
 

Modified: lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/StringField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/StringField.java?rev=1231386&r1=1231385&r2=1231386&view=diff
==============================================================================
--- lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/StringField.java (original)
+++ lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/StringField.java Fri Jan 13 23:08:21 2012
@@ -29,9 +29,6 @@ import org.apache.lucene.index.FieldInfo
  *  {@link StringField#TYPE_STORED} type (pass it to <code>new
  *  Field</code>) to store the value. */
 
-// nocommit maybe have a separate StoredField that apps add
-// to store a value; then String/TextField etc. wouldn't store...
-
 public final class StringField extends Field {
 
   /** Indexed, not tokenized, omits norms, indexes

Modified: lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/TextField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/TextField.java?rev=1231386&r1=1231385&r2=1231386&view=diff
==============================================================================
--- lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/TextField.java (original)
+++ lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/document/TextField.java Fri Jan 13 23:08:21 2012
@@ -48,7 +48,7 @@ public final class TextField extends Fie
     TYPE_STORED.freeze();
   }
 
-  // nocommit how to sugar term vectors...?
+  // TODO: add sugar for term vectors...?
 
   /** Creates a new un-stored TextField */
   public TextField(String name, Reader reader) {

Modified: lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/index/IndexableFieldType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/index/IndexableFieldType.java?rev=1231386&r1=1231385&r2=1231386&view=diff
==============================================================================
--- lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/index/IndexableFieldType.java (original)
+++ lucene/dev/branches/lucene3453/lucene/src/java/org/apache/lucene/index/IndexableFieldType.java Fri Jan 13 23:08:21 2012
@@ -19,9 +19,6 @@ package org.apache.lucene.index;
 
 import org.apache.lucene.index.FieldInfo.IndexOptions;
 
-// nocommit we should pull the NF.DataType into index package?
-import org.apache.lucene.document.NumericField;
-
 /** @lucene.experimental */
 public interface IndexableFieldType {
 
@@ -53,16 +50,4 @@ public interface IndexableFieldType {
   /** DocValues type; if non-null then the field's value
    *  will be indexed into docValues */
   public DocValues.Type docValueType();
-
-  /** Numeric {@link NumericField.DataType}; if
-   *  non-null then the field's value will be indexed
-   *  numerically so that {@link NumericRangeQuery} can be
-   *  used at search time. */
-  // nocommit: should this be in FT not IFT...?
-  public NumericField.DataType numericType();
-
-  /** Precision step for numeric field. */
-  // nocommit: should this be in FT not IFT...?
-  // but... Field holds an IFT yet needs precisionStep...
-  public int numericPrecisionStep();
 }

Modified: lucene/dev/branches/lucene3453/lucene/src/test-framework/java/org/apache/lucene/index/RandomIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3453/lucene/src/test-framework/java/org/apache/lucene/index/RandomIndexWriter.java?rev=1231386&r1=1231385&r2=1231386&view=diff
==============================================================================
--- lucene/dev/branches/lucene3453/lucene/src/test-framework/java/org/apache/lucene/index/RandomIndexWriter.java (original)
+++ lucene/dev/branches/lucene3453/lucene/src/test-framework/java/org/apache/lucene/index/RandomIndexWriter.java Fri Jan 13 23:08:21 2012
@@ -25,8 +25,8 @@ import java.util.Random;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.document.DocValuesField;
 import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.index.IndexWriter; // javadoc
 import org.apache.lucene.search.Query;
@@ -172,7 +172,10 @@ public class RandomIndexWriter implement
     String name = "random_" + type.name() + "" + docValuesFieldPrefix;
     if ("Lucene3x".equals(codec.getName()) || doc.getField(name) != null)
         return;
-    final Object value;
+    FieldType ft = new FieldType();
+    ft.setDocValueType(type);
+    ft.freeze();
+    final Field f;
     switch (type) {
     case BYTES_FIXED_DEREF:
     case BYTES_FIXED_STRAIGHT:
@@ -186,41 +189,38 @@ public class RandomIndexWriter implement
         fixedRef.grow(fixedBytesLength);
         fixedRef.length = fixedBytesLength;
       }
-      value = fixedRef;
+      f = new Field(name, fixedRef, ft);
       break;
     case BYTES_VAR_DEREF:
     case BYTES_VAR_STRAIGHT:
     case BYTES_VAR_SORTED:
-      value = new BytesRef(_TestUtil.randomUnicodeString(random, 200));
+      f = new Field(name, new BytesRef(_TestUtil.randomUnicodeString(random, 200)), ft);
       break;
     case FLOAT_32:
-      value = random.nextFloat();
+      f = new Field(name, random.nextFloat(), ft);
       break;
     case FLOAT_64:
-      value = random.nextDouble();
+      f = new Field(name, random.nextDouble(), ft);
       break;
     case VAR_INTS:
-      value = random.nextLong();
+      f = new Field(name, random.nextLong(), ft);
       break;
     case FIXED_INTS_16:
-      value = random.nextInt(Short.MAX_VALUE);
+      f = new Field(name, random.nextInt(Short.MAX_VALUE), ft);
       break;
     case FIXED_INTS_32:
-      value =random.nextInt();
+      f = new Field(name, random.nextInt(), ft);
       break;
     case FIXED_INTS_64:
-      value = random.nextLong();
+      f = new Field(name, random.nextLong(), ft);
       break;
     case FIXED_INTS_8:
-      value = random.nextInt(128);
+      f = new Field(name, random.nextInt(128), ft);
       break;
     default:
       throw new IllegalArgumentException("no such type: " + type);
     }
-    FieldType ft = new FieldType();
-    ft.setDocValueType(type);
-    ft.freeze();
-    doc.add(new DocValuesField(name, value, ft));
+    doc.add(f);
   }
 
   private void maybeCommit() throws IOException {

Modified: lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/codecs/lucene40/TestDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/codecs/lucene40/TestDocValues.java?rev=1231386&r1=1231385&r2=1231386&view=diff
==============================================================================
--- lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/codecs/lucene40/TestDocValues.java (original)
+++ lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/codecs/lucene40/TestDocValues.java Fri Jan 13 23:08:21 2012
@@ -381,15 +381,15 @@ public class TestDocValues extends Lucen
   }
 
   public void testFloats4() throws IOException {
-    runTestFloats(Type.FLOAT_32, 0.00001);
+    runTestFloats(Type.FLOAT_32);
   }
 
-  private void runTestFloats(Type type, double delta) throws IOException {
+  private void runTestFloats(Type type) throws IOException {
     DocValueHolder valueHolder = new DocValueHolder();
     Directory dir = newDirectory();
     final Counter trackBytes = Counter.newCounter();
     DocValuesConsumer w = Floats.getWriter(dir, "test", trackBytes, newIOContext(random), type);
-    final int NUM_VALUES = 777 + random.nextInt(777);;
+    final int NUM_VALUES = 777 + random.nextInt(777);
     final double[] values = new double[NUM_VALUES];
     for (int i = 0; i < NUM_VALUES; i++) {
       final double v = type == Type.FLOAT_32 ? random.nextFloat() : random
@@ -413,7 +413,7 @@ public class TestDocValues extends Lucen
   }
 
   public void testFloats8() throws IOException {
-    runTestFloats(Type.FLOAT_64, 0.0);
+    runTestFloats(Type.FLOAT_64);
   }
   
 
@@ -460,14 +460,6 @@ public class TestDocValues extends Lucen
       return bytes;
     }
 
-    // nocommit
-    /*
-    @Override
-    public Comparator<BytesRef> bytesComparator() {
-      return comp;
-    }
-    */
-
     @Override
     public Number numericValue() {
       return numberValue;

Modified: lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java?rev=1231386&r1=1231385&r2=1231386&view=diff
==============================================================================
--- lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java (original)
+++ lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java Fri Jan 13 23:08:21 2012
@@ -500,7 +500,6 @@ public class TestDuelingCodecs extends L
     assertEquals(info, leftField.binaryValue(), rightField.binaryValue());
     assertEquals(info, leftField.stringValue(), rightField.stringValue());
     assertEquals(info, leftField.numericValue(), rightField.numericValue());
-    assertEquals(info, leftField.fieldType().numericType(), rightField.fieldType().numericType());
     // TODO: should we check the FT at all?
   }
   

Modified: lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/index/TestIndexableField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/index/TestIndexableField.java?rev=1231386&r1=1231385&r2=1231386&view=diff
==============================================================================
--- lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/index/TestIndexableField.java (original)
+++ lucene/dev/branches/lucene3453/lucene/src/test/org/apache/lucene/index/TestIndexableField.java Fri Jan 13 23:08:21 2012
@@ -25,19 +25,15 @@ import java.util.Iterator;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.NumericField.DataType;
-import org.apache.lucene.document.NumericField;
 import org.apache.lucene.document.StringField;
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.NumericRangeQuery;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.NumericUtils;
 import org.apache.lucene.util._TestUtil;
 
 public class TestIndexableField extends LuceneTestCase {
@@ -90,16 +86,6 @@ public class TestIndexableField extends 
       public DocValues.Type docValueType() {
         return null;
       }
-
-      @Override
-      public NumericField.DataType numericType() {
-        return counter%10 == 9 ? DataType.INT : null;
-      }
-
-      @Override
-      public int numericPrecisionStep() {
-        return NumericUtils.PRECISION_STEP_DEFAULT;
-      }
     };
 
     public MyField(int counter) {
@@ -132,7 +118,7 @@ public class TestIndexableField extends 
     @Override
     public String stringValue() {
       final int fieldID = counter%10;
-      if (fieldID != 3 && fieldID != 7 && fieldID != 9) {
+      if (fieldID != 3 && fieldID != 7) {
         return "text " + counter;
       } else {
         return null;
@@ -150,11 +136,7 @@ public class TestIndexableField extends 
 
     @Override
     public Number numericValue() {
-      if (counter%10 == 9) {
-        return counter;
-      } else {
-        return null;
-      }
+      return null;
     }
 
     @Override
@@ -164,12 +146,8 @@ public class TestIndexableField extends 
 
     @Override
     public TokenStream tokenStream(Analyzer analyzer) throws IOException {
-      if (fieldType().numericType() != null) {
-        return new NumericField(name(), counter).tokenStream(analyzer);
-      } else {
-        return readerValue() != null ? analyzer.tokenStream(name(), readerValue()) :
-          analyzer.tokenStream(name(), new StringReader(stringValue()));
-      }
+      return readerValue() != null ? analyzer.tokenStream(name(), readerValue()) :
+        analyzer.tokenStream(name(), new StringReader(stringValue()));
     }
   }
 
@@ -251,7 +229,6 @@ public class TestIndexableField extends 
         final boolean stored = (counter&1) == 0 || fieldID == 3;
         final boolean binary = fieldID == 3;
         final boolean indexed = fieldID != 3;
-        final boolean numeric = fieldID == 9;
 
         final String stringValue;
         if (fieldID != 3 && fieldID != 9) {
@@ -272,8 +249,6 @@ public class TestIndexableField extends 
             for(int idx=0;idx<10;idx++) {
               assertEquals((byte) (idx+counter), b.bytes[b.offset+idx]);
             }
-          } else if (numeric) {
-            assertEquals(counter, f.numericValue().intValue());
           } else {
             assert stringValue != null;
             assertEquals(stringValue, f.stringValue());
@@ -309,26 +284,19 @@ public class TestIndexableField extends 
             assertTrue(vectors == null || vectors.terms(name) == null);
           }
 
-          if (numeric) {
-            NumericRangeQuery nrq = NumericRangeQuery.newIntRange(name, counter, counter, true, true);
-            final TopDocs hits2 = s.search(nrq, 1);
-            assertEquals(1, hits2.totalHits);
-            assertEquals(docID, hits2.scoreDocs[0].doc);
-          } else {
-            BooleanQuery bq = new BooleanQuery();
-            bq.add(new TermQuery(new Term("id", ""+id)), BooleanClause.Occur.MUST);
-            bq.add(new TermQuery(new Term(name, "text")), BooleanClause.Occur.MUST);
-            final TopDocs hits2 = s.search(bq, 1);
-            assertEquals(1, hits2.totalHits);
-            assertEquals(docID, hits2.scoreDocs[0].doc);
-
-            bq = new BooleanQuery();
-            bq.add(new TermQuery(new Term("id", ""+id)), BooleanClause.Occur.MUST);
-            bq.add(new TermQuery(new Term(name, ""+counter)), BooleanClause.Occur.MUST);
-            final TopDocs hits3 = s.search(bq, 1);
-            assertEquals(1, hits3.totalHits);
-            assertEquals(docID, hits3.scoreDocs[0].doc);
-          }
+          BooleanQuery bq = new BooleanQuery();
+          bq.add(new TermQuery(new Term("id", ""+id)), BooleanClause.Occur.MUST);
+          bq.add(new TermQuery(new Term(name, "text")), BooleanClause.Occur.MUST);
+          final TopDocs hits2 = s.search(bq, 1);
+          assertEquals(1, hits2.totalHits);
+          assertEquals(docID, hits2.scoreDocs[0].doc);
+
+          bq = new BooleanQuery();
+          bq.add(new TermQuery(new Term("id", ""+id)), BooleanClause.Occur.MUST);
+          bq.add(new TermQuery(new Term(name, ""+counter)), BooleanClause.Occur.MUST);
+          final TopDocs hits3 = s.search(bq, 1);
+          assertEquals(1, hits3.totalHits);
+          assertEquals(docID, hits3.scoreDocs[0].doc);
         }
 
         counter++;