lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r893177 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/document/Field.java
Date Tue, 22 Dec 2009 14:25:03 GMT
Author: mikemccand
Date: Tue Dec 22 14:25:02 2009
New Revision: 893177

URL: http://svn.apache.org/viewvc?rev=893177&view=rev
Log:
LUCENE-2177: don't accept Store for binary fields -- it must always be YES

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/document/Field.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=893177&r1=893176&r2=893177&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Tue Dec 22 14:25:02 2009
@@ -46,6 +46,10 @@
 * LUCENE-1972: Restore SortField.getComparatorSource (it was
   accidentally removed in 3.0.0)  (John Wang via Uwe Schindler)
 
+* LUCENE-2177: Deprecate the Field ctors that take byte[] and Store.
+  Since the removal of compressed fields, Store can only be YES, so
+  it's not necessary to specify.  (Erik Hatcher via Mike McCandless)
+
 Bug fixes
 
 * LUCENE-2092: BooleanQuery was ignoring disableCoord in its hashCode

Modified: lucene/java/trunk/src/java/org/apache/lucene/document/Field.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/document/Field.java?rev=893177&r1=893176&r2=893177&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/document/Field.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/document/Field.java Tue Dec 22 14:25:02 2009
@@ -521,11 +521,27 @@
    * 
    * @param name The name of the field
    * @param value The binary value
-   * @param store How <code>value</code> should be stored (compressed or not)
+   * @param store Must be Store.YES
    * @throws IllegalArgumentException if store is <code>Store.NO</code> 
+   * @deprecated Use {@link #Field(String, byte[]) instead}
    */
+  @Deprecated
   public Field(String name, byte[] value, Store store) {
-    this(name, value, 0, value.length, store);
+    this(name, value, 0, value.length);
+
+    if (store == Store.NO) {
+      throw new IllegalArgumentException("binary values can't be unstored");
+    }
+  }
+
+  /**
+   * Create a stored field with binary value. Optionally the value may be compressed.
+   * 
+   * @param name The name of the field
+   * @param value The binary value
+   */
+  public Field(String name, byte[] value) {
+    this(name, value, 0, value.length);
   }
 
   /**
@@ -537,8 +553,26 @@
    * @param length Number of bytes to use for this Field, starting at offset
    * @param store How <code>value</code> should be stored (compressed or not)
    * @throws IllegalArgumentException if store is <code>Store.NO</code> 
+   * @deprecated Use {@link #Field(String, byte[], int, int) instead}
    */
+  @Deprecated
   public Field(String name, byte[] value, int offset, int length, Store store) {
+    this(name, value, offset, length);
+
+    if (store == Store.NO) {
+      throw new IllegalArgumentException("binary values can't be unstored");
+    }
+  }
+
+  /**
+   * Create a stored field with binary value. Optionally the value may be compressed.
+   * 
+   * @param name The name of the field
+   * @param value The binary value
+   * @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
+   */
+  public Field(String name, byte[] value, int offset, int length) {
 
     if (name == null)
       throw new IllegalArgumentException("name cannot be null");
@@ -548,10 +582,7 @@
     this.name = StringHelper.intern(name);        // field names are interned
     fieldsData = value;
     
-    if (store == Store.NO)
-      throw new IllegalArgumentException("binary values can't be unstored");
-    
-    isStored = store.isStored();
+    isStored = true;
     isIndexed   = false;
     isTokenized = false;
     omitTermFreqAndPositions = false;



Mime
View raw message