lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1049502 - in /lucene/dev/trunk/lucene/src: java/org/apache/lucene/index/ test/org/apache/lucene/index/
Date Wed, 15 Dec 2010 11:06:07 GMT
Author: mikemccand
Date: Wed Dec 15 11:06:07 2010
New Revision: 1049502

URL: http://svn.apache.org/viewvc?rev=1049502&view=rev
Log:
LUCENE-2811: simplify tracking of hasVectors during merge

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MergePolicy.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestDoc.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java?rev=1049502&r1=1049501&r2=1049502&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java Wed Dec 15 11:06:07
2010
@@ -2241,8 +2241,8 @@ public class IndexWriter implements Clos
       int docCount = merger.merge();                // merge 'em
       
       SegmentInfo info = new SegmentInfo(mergedName, docCount, directory,
-                                         false, -1, null, false, merger.hasProx(), merger.getSegmentCodecs(),
-                                         merger.hasVectors());
+                                         false, -1, null, false, merger.fieldInfos().hasProx(),
merger.getSegmentCodecs(),
+                                         merger.fieldInfos().hasVectors());
       setDiagnostics(info, "addIndexes(IndexReader...)");
 
       boolean useCompoundFile;
@@ -2719,7 +2719,7 @@ public class IndexWriter implements Clos
     // format as well:
     setMergeDocStoreIsCompoundFile(merge);
 
-    merge.info.setHasProx(merger.hasProx());
+    merge.info.setHasProx(merger.fieldInfos().hasProx());
 
     segmentInfos.subList(start, start + merge.segments.size()).clear();
     assert !segmentInfos.contains(merge.info);
@@ -3039,7 +3039,6 @@ public class IndexWriter implements Clos
       updatePendingMerges(1, false);
     }
 
-    merge.hasVectors = hasVectors;
     merge.mergeDocStores = mergeDocStores;
 
     // Bind a new segment name here so even with
@@ -3051,7 +3050,7 @@ public class IndexWriter implements Clos
                                  docStoreIsCompoundFile,
                                  false,
                                  null,
-                                 false);
+                                 hasVectors);
 
     Map<String,String> details = new HashMap<String,String>();
     details.put("optimize", Boolean.toString(merge.optimize));
@@ -3282,7 +3281,6 @@ public class IndexWriter implements Clos
 
       // Record which codec was used to write the segment
       merge.info.setSegmentCodecs(merger.getSegmentCodecs());
-      merge.info.setHasVectors(merger.hasVectors() || merge.hasVectors);
 
       if (infoStream != null) {
         message("merge segmentCodecs=" + merger.getSegmentCodecs());
@@ -3294,7 +3292,7 @@ public class IndexWriter implements Clos
       // because codec must know if prox was written for
       // this segment:
       //System.out.println("merger set hasProx=" + merger.hasProx() + " seg=" + merge.info.name);
-      merge.info.setHasProx(merger.hasProx());
+      merge.info.setHasProx(merger.fieldInfos().hasProx());
 
       boolean useCompoundFile;
       synchronized (this) { // Guard segmentInfos

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MergePolicy.java?rev=1049502&r1=1049501&r2=1049502&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MergePolicy.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MergePolicy.java Wed Dec 15 11:06:07
2010
@@ -68,7 +68,6 @@ public abstract class MergePolicy implem
 
     SegmentInfo info;               // used by IndexWriter
     boolean mergeDocStores;         // used by IndexWriter
-    boolean hasVectors;             // used by IndexWriter
     boolean optimize;               // used by IndexWriter
     boolean registerDone;           // used by IndexWriter
     long mergeGen;                  // used by IndexWriter

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentMerger.java?rev=1049502&r1=1049501&r2=1049502&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentMerger.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentMerger.java Wed Dec 15
11:06:07 2010
@@ -75,7 +75,6 @@ final class SegmentMerger {
   private final CodecProvider codecs;
   private Codec codec;
   private SegmentWriteState segmentWriteState;
-  private boolean hasVectors;
 
   private PayloadProcessorProvider payloadProcessorProvider;
   
@@ -96,13 +95,9 @@ final class SegmentMerger {
     }
     this.termIndexInterval = termIndexInterval;
   }
-  
-  boolean hasProx() {
-    return fieldInfos.hasProx();
-  }
 
-  boolean hasVectors() {
-    return hasVectors;
+  public FieldInfos fieldInfos() {
+    return fieldInfos;
   }
 
   /**
@@ -147,8 +142,9 @@ final class SegmentMerger {
     mergeTerms();
     mergeNorms();
 
-    if (mergeDocStores && fieldInfos.hasVectors())
+    if (mergeDocStores && fieldInfos.hasVectors()) {
       mergeVectors();
+    }
 
     return mergedDocs;
   }
@@ -432,7 +428,7 @@ final class SegmentMerger {
   private final void mergeVectors() throws IOException {
     TermVectorsWriter termVectorsWriter = 
       new TermVectorsWriter(directory, segment, fieldInfos);
-    hasVectors = true;
+
     try {
       int idx = 0;
       for (final IndexReader reader : readers) {

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestDoc.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestDoc.java?rev=1049502&r1=1049501&r2=1049502&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestDoc.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestDoc.java Wed Dec 15 11:06:07
2010
@@ -201,8 +201,8 @@ public class TestDoc extends LuceneTestC
       r2.close();
       
       final SegmentInfo info = new SegmentInfo(merged, si1.docCount + si2.docCount, si1.dir,
-                                               useCompoundFile, -1, null, false, merger.hasProx(),
merger.getSegmentCodecs(),
-                                               merger.hasVectors());
+                                               useCompoundFile, -1, null, false, merger.fieldInfos().hasProx(),
merger.getSegmentCodecs(),
+                                               merger.fieldInfos().hasVectors());
       
       if (useCompoundFile) {
         Collection<String> filesToDelete = merger.createCompoundFile(merged + ".cfs",
info);

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java?rev=1049502&r1=1049501&r2=1049502&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java Wed Dec
15 11:06:07 2010
@@ -80,7 +80,8 @@ public class TestSegmentMerger extends L
     assertTrue(docsMerged == 2);
     //Should be able to open a new SegmentReader against the new directory
     SegmentReader mergedReader = SegmentReader.get(false, mergedDir, new SegmentInfo(mergedSegment,
docsMerged, mergedDir, false, -1,
-                                                                                     null,
false, merger.hasProx(), merger.getSegmentCodecs(), merger.hasVectors()),
+                                                                                     null,
false, merger.fieldInfos().hasProx(),
+                                                                                     merger.getSegmentCodecs(),
merger.fieldInfos().hasVectors()),
                                                    BufferedIndexInput.BUFFER_SIZE, true,
IndexReader.DEFAULT_TERMS_INDEX_DIVISOR);
 
     assertTrue(mergedReader != null);



Mime
View raw message