move some bitvector -> mutablebits

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3661@1233498 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2012-01-19 17:41:14 +00:00
parent de495a3c0d
commit da3dbb0e0c
5 changed files with 16 additions and 12 deletions

View File

@ -25,7 +25,6 @@ import java.text.NumberFormat;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.lucene40.BitVector;
import org.apache.lucene.index.DocumentsWriterDeleteQueue.DeleteSlice;
import org.apache.lucene.search.similarities.SimilarityProvider;
import org.apache.lucene.store.Directory;
@ -36,6 +35,7 @@ import org.apache.lucene.util.ByteBlockPool.Allocator;
import org.apache.lucene.util.ByteBlockPool.DirectTrackingAllocator;
import org.apache.lucene.util.InfoStream;
import org.apache.lucene.util.RamUsageEstimator;
import org.apache.lucene.util.MutableBits;
public class DocumentsWriterPerThread {
@ -114,10 +114,10 @@ public class DocumentsWriterPerThread {
static class FlushedSegment {
final SegmentInfo segmentInfo;
final BufferedDeletes segmentDeletes;
final BitVector liveDocs;
final MutableBits liveDocs;
private FlushedSegment(SegmentInfo segmentInfo,
BufferedDeletes segmentDeletes, BitVector liveDocs) {
BufferedDeletes segmentDeletes, MutableBits liveDocs) {
this.segmentInfo = segmentInfo;
this.segmentDeletes = segmentDeletes;
this.liveDocs = liveDocs;
@ -448,8 +448,7 @@ public class DocumentsWriterPerThread {
// happens when an exception is hit processing that
// doc, eg if analyzer has some problem w/ the text):
if (pendingDeletes.docIDs.size() > 0) {
flushState.liveDocs = new BitVector(numDocsInRAM);
flushState.liveDocs.invertAll();
flushState.liveDocs = codec.liveDocsFormat().newLiveDocs(numDocsInRAM);
for(int delDocID : pendingDeletes.docIDs) {
flushState.liveDocs.clear(delDocID);
}

View File

@ -27,7 +27,6 @@ import org.apache.lucene.codecs.FieldsConsumer;
import org.apache.lucene.codecs.PostingsConsumer;
import org.apache.lucene.codecs.TermStats;
import org.apache.lucene.codecs.TermsConsumer;
import org.apache.lucene.codecs.lucene40.BitVector;
import org.apache.lucene.index.FieldInfo.IndexOptions;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.FixedBitSet;
@ -461,9 +460,10 @@ final class FreqProxTermsWriterPerField extends TermsHashConsumerPerField implem
// Mark it deleted. TODO: we could also skip
// writing its postings; this would be
// deterministic (just for this Term's docs).
// nocommit: totally wrong to do this reach-around here, and this way
if (state.liveDocs == null) {
state.liveDocs = new BitVector(state.numDocs);
state.liveDocs.invertAll();
state.liveDocs = docState.docWriter.codec.liveDocsFormat().newLiveDocs(state.numDocs);
}
state.liveDocs.clear(docID);
}

View File

@ -2267,7 +2267,10 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
// shortly-to-be-opened SegmentReader and let it
// carry the changes; there's no reason to use
// filesystem as intermediary here.
flushedSegment.liveDocs.write(directory, delFileName, context);
SegmentInfo info = flushedSegment.segmentInfo;
Codec codec = info.getCodec();
codec.liveDocsFormat().writeLiveDocs(flushedSegment.liveDocs, directory, info, context);
success2 = true;
} finally {
if (!success2) {

View File

@ -18,10 +18,10 @@ package org.apache.lucene.index;
*/
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.lucene40.BitVector;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.util.InfoStream;
import org.apache.lucene.util.MutableBits;
/**
* @lucene.experimental
@ -41,7 +41,7 @@ public class SegmentWriteState {
public final BufferedDeletes segDeletes;
// Lazily created:
public BitVector liveDocs;
public MutableBits liveDocs;
public final Codec codec;
public final String segmentSuffix;

View File

@ -18,5 +18,7 @@ package org.apache.lucene.util;
*/
public interface MutableBits extends Bits {
public void clear(int bit);
// nocommit: remove this from this interface somehow? (used by DWPT infostream at least)
public int count();
}