mirror of https://github.com/apache/lucene.git
LUCENE-3661: nuke nocommit for real, split SimpleText to use read-only bits impls whenever it can
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3661@1237127 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1b8d8b4350
commit
8933cfe181
|
@ -53,13 +53,13 @@ public class SimpleTextLiveDocsFormat extends LiveDocsFormat {
|
|||
|
||||
@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 extends LiveDocsFormat {
|
|||
}
|
||||
}
|
||||
|
||||
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 extends LiveDocsFormat {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -417,7 +417,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
|
|||
// 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 Closeable, TwoPhaseCommit {
|
|||
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 Closeable, TwoPhaseCommit {
|
|||
} 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 Closeable, TwoPhaseCommit {
|
|||
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 Closeable, TwoPhaseCommit {
|
|||
// 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) {
|
||||
|
|
Loading…
Reference in New Issue