lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1237127 - in /lucene/dev/branches/lucene3661/lucene/src/java/org/apache/lucene: codecs/simpletext/SimpleTextLiveDocsFormat.java index/IndexWriter.java
Date Sat, 28 Jan 2012 18:22:50 GMT
Author: rmuir
Date: Sat Jan 28 18:22:49 2012
New Revision: 1237127

URL: http://svn.apache.org/viewvc?rev=1237127&view=rev
Log:
LUCENE-3661: nuke nocommit for real, split SimpleText to use read-only bits impls whenever
it can

Modified:
    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

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=1237127&r1=1237126&r2=1237127&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 18:22:49 2012
@@ -53,13 +53,13 @@ public class SimpleTextLiveDocsFormat ex
   
   @Override
   public MutableBits newLiveDocs(int size) throws IOException {
-    return new SimpleTextBits(size);
+    return new SimpleTextMutableBits(size);
   }
 
   @Override
   public MutableBits newLiveDocs(Bits existing) throws IOException {
     final SimpleTextBits bits = (SimpleTextBits) existing;
-    return bits.clone();
+    return new SimpleTextMutableBits((BitSet)bits.bits.clone(), bits.size);
   }
 
   @Override
@@ -144,16 +144,11 @@ public class SimpleTextLiveDocsFormat ex
     }
   }
   
-  static class SimpleTextBits implements MutableBits {
+  // read-only
+  static class SimpleTextBits implements Bits {
     final BitSet bits;
     final int size;
     
-    SimpleTextBits(int size) {
-      this.size = size;
-      bits = new BitSet(size);
-      bits.set(0, size);
-    }
-    
     SimpleTextBits(BitSet bits, int size) {
       this.bits = bits;
       this.size = size;
@@ -168,16 +163,23 @@ public class SimpleTextLiveDocsFormat ex
     public int length() {
       return size;
     }
+  }
+  
+  // read-write
+  static class SimpleTextMutableBits extends SimpleTextBits implements MutableBits {
 
+    SimpleTextMutableBits(int size) {
+      this(new BitSet(size), size);
+      bits.set(0, size);
+    }
+    
+    SimpleTextMutableBits(BitSet bits, int size) {
+      super(bits, size);
+    }
+    
     @Override
     public void clear(int bit) {
       bits.clear(bit);
     }
-
-    @Override
-    public SimpleTextBits clone() {
-      BitSet clonedBits = (BitSet) bits.clone();
-      return new SimpleTextBits(clonedBits, size);
-    }
   }
 }

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=1237127&r1=1237126&r2=1237127&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 18:22:49 2012
@@ -417,7 +417,7 @@ public class IndexWriter implements Clos
     // docs, and it's copy-on-write (cloned whenever we need
     // to change it but it's been shared to an external NRT
     // reader).
-    public MutableBits liveDocs;
+    public Bits liveDocs;
 
     // How many further deletions we've done against
     // liveDocs vs when we loaded it or last wrote it:
@@ -494,8 +494,7 @@ public class IndexWriter implements Clos
       if (reader == null) {
         reader = new SegmentReader(info, config.getReaderTermsIndexDivisor(), context);
         if (liveDocs == null) {
-          // nocommit: still don't like this cast, gotta be a cleaner way.
-          liveDocs = (MutableBits) reader.getLiveDocs();
+          liveDocs = reader.getLiveDocs();
         }
         //System.out.println("ADD seg=" + rld.info + " isMerge=" + isMerge + " " + readerMap.size()
+ " in pool");
       }
@@ -522,7 +521,7 @@ public class IndexWriter implements Clos
         } else {
           mergeReader = new SegmentReader(info, -1, context);
           if (liveDocs == null) {
-            liveDocs = (MutableBits) mergeReader.getLiveDocs();
+            liveDocs = mergeReader.getLiveDocs();
           }
         }
       }
@@ -538,7 +537,7 @@ public class IndexWriter implements Clos
       assert !shared;
       final boolean didDelete = liveDocs.get(docID);
       if (didDelete) {
-        liveDocs.clear(docID);
+       ((MutableBits) liveDocs).clear(docID);
         pendingDeleteCount++;
         //System.out.println("  new del seg=" + info + " docID=" + docID + " pendingDelCount="
+ pendingDeleteCount + " totDelCount=" + (info.docCount-liveDocs.count()));
       }
@@ -627,7 +626,7 @@ public class IndexWriter implements Clos
         // until segments file is written:
         boolean success = false;
         try {
-          info.getCodec().liveDocsFormat().writeLiveDocs(liveDocs, dir, info, IOContext.DEFAULT);
+          info.getCodec().liveDocsFormat().writeLiveDocs((MutableBits)liveDocs, dir, info,
IOContext.DEFAULT);
           success = true;
         } finally {
           if (!success) {



Mime
View raw message