lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r553298 - in /lucene/java/trunk/src: java/org/apache/lucene/index/DocumentsWriter.java java/org/apache/lucene/index/SegmentInfo.java test/org/apache/lucene/index/TestIndexWriter.java
Date Wed, 04 Jul 2007 19:03:21 GMT
Author: mikemccand
Date: Wed Jul  4 12:03:21 2007
New Revision: 553298

URL: http://svn.apache.org/viewvc?view=rev&rev=553298
Log:
LUCENE-843: SegmentInfo.clone() failed to copy some fields; in certain cases _x.nrm might
not be created even when fieldInfos says it has norms

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfo.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java?view=diff&rev=553298&r1=553297&r2=553298
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java Wed Jul  4 12:03:21
2007
@@ -338,7 +338,6 @@
     postingsIsFull = false;
     flushPending = false;
     segment = null;
-    hasNorms = false;
     numDocsInRAM = 0;
     nextDocID = 0;
     nextWriteDocID = 0;
@@ -1803,7 +1802,6 @@
 
     if (hasNorms) {
       writeNorms(segmentName, numDocsInRAM);
-      hasNorms = false;
       flushedFiles.add(segmentFileName(IndexFileNames.NORMS_EXTENSION));
     }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfo.java?view=diff&rev=553298&r1=553297&r2=553298
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfo.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfo.java Wed Jul  4 12:03:21
2007
@@ -248,6 +248,9 @@
     if (normGen != null) {
       si.normGen = (long[]) normGen.clone();
     }
+    si.docStoreOffset = docStoreOffset;
+    si.docStoreSegment = docStoreSegment;
+    si.docStoreIsCompoundFile = docStoreIsCompoundFile;
     return si;
   }
 

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?view=diff&rev=553298&r1=553297&r2=553298
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java Wed Jul  4 12:03:21
2007
@@ -1293,6 +1293,21 @@
       dir.close();
     }
 
+    // Make sure we can flush segment w/ norms, then add
+    // empty doc (no norms) and flush
+    public void testEmptyDocAfterFlushingRealDoc() throws IOException {
+      Directory dir = new RAMDirectory();
+      IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), true);      
+      Document doc = new Document();
+      doc.add(new Field("field", "aaa", Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
+      writer.addDocument(doc);
+      writer.flush();
+      writer.addDocument(new Document());
+      writer.close();
+      IndexReader reader = IndexReader.open(dir);
+      assertEquals(2, reader.numDocs());
+    }
+
     private void rmDir(File dir) {
         File[] files = dir.listFiles();
         if (files != null) {



Mime
View raw message