You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/01/28 15:34:18 UTC

svn commit: r1237064 - in /lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene: codecs/ codecs/lucene40/ codecs/simpletext/ index/ util/

Author: rmuir
Date: Sat Jan 28 14:34:18 2012
New Revision: 1237064

URL: http://svn.apache.org/viewvc?rev=1237064&view=rev
Log:
LUCENE-3661: removable MutableBits.clone()

Modified:
    lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/LiveDocsFormat.java
    lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java
    lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/simpletext/SimpleTextLiveDocsFormat.java
    lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/util/MutableBits.java

Modified: lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/LiveDocsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/LiveDocsFormat.java?rev=1237064&r1=1237063&r2=1237064&view=diff
==============================================================================
--- lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/LiveDocsFormat.java (original)
+++ lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/LiveDocsFormat.java Sat Jan 28 14:34:18 2012
@@ -28,6 +28,7 @@ import org.apache.lucene.util.MutableBit
 
 public abstract class LiveDocsFormat {
   public abstract MutableBits newLiveDocs(int size) throws IOException;
+  public abstract MutableBits newLiveDocs(Bits existing) throws IOException;
   public abstract Bits readLiveDocs(Directory dir, SegmentInfo info, IOContext context) throws IOException;
   public abstract void writeLiveDocs(MutableBits bits, Directory dir, SegmentInfo info, IOContext context) throws IOException;
   public abstract void separateFiles(Directory dir, SegmentInfo info, Set<String> files) throws IOException;

Modified: lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java?rev=1237064&r1=1237063&r2=1237064&view=diff
==============================================================================
--- lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java (original)
+++ lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/lucene40/Lucene40LiveDocsFormat.java Sat Jan 28 14:34:18 2012
@@ -24,6 +24,12 @@ public class Lucene40LiveDocsFormat exte
   }
 
   @Override
+  public MutableBits newLiveDocs(Bits existing) throws IOException {
+    final BitVector liveDocs = (BitVector) existing;
+    return liveDocs.clone();
+  }
+
+  @Override
   public Bits readLiveDocs(Directory dir, SegmentInfo info, IOContext context) throws IOException {
     String filename = IndexFileNames.fileNameFromGeneration(info.name, DELETES_EXTENSION, info.getDelGen());
     final BitVector liveDocs = new BitVector(dir, filename, context);
@@ -34,7 +40,6 @@ public class Lucene40LiveDocsFormat exte
 
   @Override
   public void writeLiveDocs(MutableBits bits, Directory dir, SegmentInfo info, IOContext context) throws IOException {
-    // nocommit: this api is ugly...
     String filename = IndexFileNames.fileNameFromGeneration(info.name, DELETES_EXTENSION, info.getDelGen());
     final BitVector liveDocs = (BitVector) bits;
     assert liveDocs.count() == info.docCount - info.getDelCount();

Modified: lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/simpletext/SimpleTextLiveDocsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/simpletext/SimpleTextLiveDocsFormat.java?rev=1237064&r1=1237063&r2=1237064&view=diff
==============================================================================
--- lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/simpletext/SimpleTextLiveDocsFormat.java (original)
+++ lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/codecs/simpletext/SimpleTextLiveDocsFormat.java Sat Jan 28 14:34:18 2012
@@ -57,6 +57,12 @@ public class SimpleTextLiveDocsFormat ex
   }
 
   @Override
+  public MutableBits newLiveDocs(Bits existing) throws IOException {
+    final SimpleTextBits bits = (SimpleTextBits) existing;
+    return bits.clone();
+  }
+
+  @Override
   public Bits readLiveDocs(Directory dir, SegmentInfo info, IOContext context) throws IOException {
     assert info.hasDeletions();
     BytesRef scratch = new BytesRef();

Modified: lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexWriter.java?rev=1237064&r1=1237063&r2=1237064&view=diff
==============================================================================
--- lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/index/IndexWriter.java Sat Jan 28 14:34:18 2012
@@ -33,6 +33,7 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.codecs.Codec;
+import org.apache.lucene.codecs.LiveDocsFormat;
 import org.apache.lucene.index.DocumentsWriterPerThread.FlushedSegment;
 import org.apache.lucene.index.FieldInfos.FieldNumberBiMap;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
@@ -475,7 +476,6 @@ public class IndexWriter implements Clos
       if (reader == null) {
         reader = new SegmentReader(info, config.getReaderTermsIndexDivisor(), context);
         if (liveDocs == null) {
-          // nocommit: nuke cast
           liveDocs = (MutableBits) reader.getLiveDocs();
         }
         //System.out.println("ADD seg=" + rld.info + " isMerge=" + isMerge + " " + readerMap.size() + " in pool");
@@ -565,11 +565,12 @@ public class IndexWriter implements Clos
         // SegmentReader sharing the current liveDocs
         // instance; must now make a private clone so we can
         // change it:
+        LiveDocsFormat liveDocsFormat = info.getCodec().liveDocsFormat();
         if (liveDocs == null) {
           //System.out.println("create BV seg=" + info);
-          liveDocs = info.getCodec().liveDocsFormat().newLiveDocs(info.docCount);
+          liveDocs = liveDocsFormat.newLiveDocs(info.docCount);
         } else {
-          liveDocs = liveDocs.clone();
+          liveDocs = liveDocsFormat.newLiveDocs(liveDocs);
         }
         shared = false;
       } else {

Modified: lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/util/MutableBits.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/util/MutableBits.java?rev=1237064&r1=1237063&r2=1237064&view=diff
==============================================================================
--- lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/util/MutableBits.java (original)
+++ lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene/util/MutableBits.java Sat Jan 28 14:34:18 2012
@@ -17,7 +17,6 @@ package org.apache.lucene.util;
  * limitations under the License.
  */
 
-public interface MutableBits extends Bits, Cloneable {
+public interface MutableBits extends Bits {
   public void clear(int bit);
-  public MutableBits clone();
 }