lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r628080 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/index/TermInfosWriter.java src/test/org/apache/lucene/index/TestIndexWriter.java
Date Fri, 15 Feb 2008 15:04:17 GMT
Author: mikemccand
Date: Fri Feb 15 07:04:16 2008
New Revision: 628080

URL: http://svn.apache.org/viewvc?rev=628080&view=rev
Log:
LUCENE-1179: allow Fields with empty string field names

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/TermInfosWriter.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=628080&r1=628079&r2=628080&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Fri Feb 15 07:04:16 2008
@@ -73,6 +73,10 @@
     without checking if the scorer is already at the right position.
     scorer.skipTo(scorer.doc()) is not a NOOP, it behaves as 
     scorer.next(). (Eks Dev, Michael Busch)
+
+ 5. LUCENE-1179: Fixed assert statement that was incorrectly
+    preventing Fields with empty-string field name from working.
+    (Sergey Kabashnyuk via Mike McCandless)
 	
 New features
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/TermInfosWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/TermInfosWriter.java?rev=628080&r1=628079&r2=628080&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/TermInfosWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/TermInfosWriter.java Fri Feb 15 07:04:16
2008
@@ -111,8 +111,15 @@
   private int compareToLastTerm(int fieldNumber, char[] termText, int start, int length)
{
     int pos = 0;
 
-    if (lastFieldNumber != fieldNumber)
-      return fieldInfos.fieldName(lastFieldNumber).compareTo(fieldInfos.fieldName(fieldNumber));
+    if (lastFieldNumber != fieldNumber) {
+      final int cmp = fieldInfos.fieldName(lastFieldNumber).compareTo(fieldInfos.fieldName(fieldNumber));
+      // If there is a field named "" (empty string) then we
+      // will get 0 on this comparison, yet, it's "OK".  But
+      // it's not OK if two different field numbers map to
+      // the same name.
+      if (cmp != 0 || lastFieldNumber != -1)
+        return cmp;
+    }
 
     while(pos < length && pos < lastTermTextLength) {
       final char c1 = lastTermText[pos];

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=628080&r1=628079&r2=628080&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java Fri Feb 15 07:04:16
2008
@@ -3113,4 +3113,14 @@
     ir.close();
     dir.close();
   }
+
+  // LUCENE-1179
+  public void testEmptyFieldName() throws IOException {
+    MockRAMDirectory dir = new MockRAMDirectory();
+    IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer());
+    Document doc = new Document();
+    doc.add(new Field("", "a b c", Field.Store.NO, Field.Index.TOKENIZED));
+    writer.addDocument(doc);
+    writer.close();
+  }
 }



Mime
View raw message