mirror of https://github.com/apache/lucene.git
LUCENE-3293: Use IOContext.READONCE in VarGapTermsIndexReader to load FST
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1145755 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9a9d84579e
commit
7dcaddec96
|
@ -90,7 +90,6 @@ public class SegmentReader extends IndexReader implements Cloneable {
|
|||
* @throws IOException if there is a low-level IO error
|
||||
*/
|
||||
public static SegmentReader get(boolean readOnly, SegmentInfo si, int termInfosIndexDivisor, IOContext context) throws CorruptIndexException, IOException {
|
||||
// TODO should we check if readOnly and context combination makes sense like asserting that if read only we don't get a default?
|
||||
return get(readOnly, si.dir, si, true, termInfosIndexDivisor, context);
|
||||
}
|
||||
|
||||
|
@ -116,7 +115,7 @@ public class SegmentReader extends IndexReader implements Cloneable {
|
|||
if (doOpenStores) {
|
||||
instance.core.openDocStores(si);
|
||||
}
|
||||
instance.loadLiveDocs();
|
||||
instance.loadLiveDocs(context);
|
||||
instance.openNorms(instance.core.cfsDir, context);
|
||||
success = true;
|
||||
} finally {
|
||||
|
@ -158,10 +157,10 @@ public class SegmentReader extends IndexReader implements Cloneable {
|
|||
return true;
|
||||
}
|
||||
|
||||
private void loadLiveDocs() throws IOException {
|
||||
private void loadLiveDocs(IOContext context) throws IOException {
|
||||
// NOTE: the bitvector is stored using the regular directory, not cfs
|
||||
if (hasDeletions(si)) {
|
||||
liveDocs = new BitVector(directory(), si.getDelFileName(), IOContext.DEFAULT);
|
||||
liveDocs = new BitVector(directory(), si.getDelFileName(), new IOContext(context, true));
|
||||
if (liveDocs.getVersion() < BitVector.VERSION_DGAPS_CLEARED) {
|
||||
liveDocs.invertAll();
|
||||
}
|
||||
|
@ -274,7 +273,7 @@ public class SegmentReader extends IndexReader implements Cloneable {
|
|||
if (!deletionsUpToDate) {
|
||||
// load deleted docs
|
||||
assert clone.liveDocs == null;
|
||||
clone.loadLiveDocs();
|
||||
clone.loadLiveDocs(IOContext.READ);
|
||||
} else if (liveDocs != null) {
|
||||
liveDocsRef.incrementAndGet();
|
||||
clone.liveDocs = liveDocs;
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.apache.lucene.index.SegmentInfo;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.IOContext;
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
import org.apache.lucene.store.IOContext.Context;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.CodecUtil;
|
||||
import org.apache.lucene.util.fst.Builder;
|
||||
|
@ -61,8 +60,7 @@ public class VariableGapTermsIndexReader extends TermsIndexReaderBase {
|
|||
final String segment;
|
||||
public VariableGapTermsIndexReader(Directory dir, FieldInfos fieldInfos, String segment, int indexDivisor, int codecId, IOContext context)
|
||||
throws IOException {
|
||||
|
||||
in = dir.openInput(IndexFileNames.segmentFileName(segment, codecId, VariableGapTermsIndexWriter.TERMS_INDEX_EXTENSION), context);
|
||||
in = dir.openInput(IndexFileNames.segmentFileName(segment, codecId, VariableGapTermsIndexWriter.TERMS_INDEX_EXTENSION), new IOContext(context, true));
|
||||
this.segment = segment;
|
||||
boolean success = false;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class IOContext {
|
|||
public IOContext(MergeInfo mergeInfo) {
|
||||
this(Context.MERGE, mergeInfo);
|
||||
}
|
||||
|
||||
|
||||
private IOContext(Context context, MergeInfo mergeInfo) {
|
||||
assert context != Context.MERGE || mergeInfo != null : "MergeInfo must not be null if context is MERGE";
|
||||
assert context != Context.FLUSH : "Use IOContext(FlushInfo) to create a FLUSH IOContext";
|
||||
|
@ -85,6 +85,18 @@ public class IOContext {
|
|||
this.mergeInfo = mergeInfo;
|
||||
this.flushInfo = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is used to initialize a {@link IOContext} instance with a new value for the readOnce variable.
|
||||
* @param ctxt {@link IOContext} object whose information is used to create the new instance except the readOnce variable.
|
||||
* @param readOnce The new {@link IOContext} object will use this value for readOnce.
|
||||
*/
|
||||
public IOContext(IOContext ctxt, boolean readOnce) {
|
||||
this.context = ctxt.context;
|
||||
this.mergeInfo = ctxt.mergeInfo;
|
||||
this.flushInfo = ctxt.flushInfo;
|
||||
this.readOnce = readOnce;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
|
Loading…
Reference in New Issue