mirror of https://github.com/apache/lucene.git
Add mergeProgress into MergeState
Signed-off-by: luyuncheng <luyuncheng@bytedance.com>
This commit is contained in:
parent
53d1c2bd2f
commit
5e7aab1d6b
|
@ -69,7 +69,8 @@ final class PerFieldMergeState {
|
|||
in.maxDocs,
|
||||
in.infoStream,
|
||||
in.intraMergeTaskExecutor,
|
||||
in.needsIndexSort);
|
||||
in.needsIndexSort,
|
||||
in.mergeProgress);
|
||||
}
|
||||
|
||||
private static class FilterFieldInfos extends FieldInfos {
|
||||
|
|
|
@ -3453,7 +3453,8 @@ public class IndexWriter
|
|||
trackingDir,
|
||||
globalFieldNumberMap,
|
||||
context,
|
||||
intraMergeExecutor);
|
||||
intraMergeExecutor,
|
||||
merge.getMergeProgress());
|
||||
|
||||
if (!merger.shouldMerge()) {
|
||||
return;
|
||||
|
@ -5254,7 +5255,8 @@ public class IndexWriter
|
|||
dirWrapper,
|
||||
globalFieldNumberMap,
|
||||
context,
|
||||
intraMergeExecutor);
|
||||
intraMergeExecutor,
|
||||
merge.getMergeProgress());
|
||||
merge.info.setSoftDelCount(Math.toIntExact(softDeleteCount.get()));
|
||||
merge.checkAborted();
|
||||
|
||||
|
|
|
@ -91,17 +91,22 @@ public class MergeState {
|
|||
/** Indicates if the index needs to be sorted * */
|
||||
public boolean needsIndexSort;
|
||||
|
||||
/** Progress and state for an executing merge. */
|
||||
public final MergePolicy.OneMergeProgress mergeProgress;
|
||||
|
||||
/** Sole constructor. */
|
||||
MergeState(
|
||||
List<CodecReader> readers,
|
||||
SegmentInfo segmentInfo,
|
||||
InfoStream infoStream,
|
||||
Executor intraMergeTaskExecutor)
|
||||
Executor intraMergeTaskExecutor,
|
||||
MergePolicy.OneMergeProgress mergeProgress)
|
||||
throws IOException {
|
||||
verifyIndexSort(readers, segmentInfo);
|
||||
this.infoStream = infoStream;
|
||||
int numReaders = readers.size();
|
||||
this.intraMergeTaskExecutor = intraMergeTaskExecutor;
|
||||
this.mergeProgress = mergeProgress;
|
||||
|
||||
maxDocs = new int[numReaders];
|
||||
fieldsProducers = new FieldsProducer[numReaders];
|
||||
|
@ -284,7 +289,8 @@ public class MergeState {
|
|||
int[] maxDocs,
|
||||
InfoStream infoStream,
|
||||
Executor intraMergeTaskExecutor,
|
||||
boolean needsIndexSort) {
|
||||
boolean needsIndexSort,
|
||||
MergePolicy.OneMergeProgress mergeProgress) {
|
||||
this.docMaps = docMaps;
|
||||
this.segmentInfo = segmentInfo;
|
||||
this.mergeFieldInfos = mergeFieldInfos;
|
||||
|
@ -301,5 +307,6 @@ public class MergeState {
|
|||
this.infoStream = infoStream;
|
||||
this.intraMergeTaskExecutor = intraMergeTaskExecutor;
|
||||
this.needsIndexSort = needsIndexSort;
|
||||
this.mergeProgress = mergeProgress;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,13 +59,15 @@ final class SegmentMerger {
|
|||
Directory dir,
|
||||
FieldInfos.FieldNumbers fieldNumbers,
|
||||
IOContext context,
|
||||
Executor intraMergeTaskExecutor)
|
||||
Executor intraMergeTaskExecutor,
|
||||
MergePolicy.OneMergeProgress mergeProgress)
|
||||
throws IOException {
|
||||
if (context.context() != IOContext.Context.MERGE) {
|
||||
throw new IllegalArgumentException(
|
||||
"IOContext.context should be MERGE; got: " + context.context());
|
||||
}
|
||||
mergeState = new MergeState(readers, segmentInfo, infoStream, intraMergeTaskExecutor);
|
||||
mergeState =
|
||||
new MergeState(readers, segmentInfo, infoStream, intraMergeTaskExecutor, mergeProgress);
|
||||
mergeStateCreationThread = Thread.currentThread();
|
||||
directory = dir;
|
||||
this.codec = segmentInfo.getCodec();
|
||||
|
|
|
@ -230,7 +230,6 @@ public class TestDoc extends LuceneTestCase {
|
|||
StringHelper.randomId(),
|
||||
new HashMap<>(),
|
||||
null);
|
||||
|
||||
SegmentMerger merger =
|
||||
new SegmentMerger(
|
||||
Arrays.<CodecReader>asList(r1, r2),
|
||||
|
@ -239,8 +238,8 @@ public class TestDoc extends LuceneTestCase {
|
|||
trackingDir,
|
||||
new FieldInfos.FieldNumbers(null, null),
|
||||
context,
|
||||
new SameThreadExecutorService());
|
||||
|
||||
new SameThreadExecutorService(),
|
||||
new MergePolicy.OneMergeProgress());
|
||||
merger.merge();
|
||||
r1.close();
|
||||
r2.close();
|
||||
|
|
|
@ -107,7 +107,8 @@ public class TestSegmentMerger extends LuceneTestCase {
|
|||
mergedDir,
|
||||
new FieldInfos.FieldNumbers(null, null),
|
||||
newIOContext(random(), new IOContext(new MergeInfo(-1, -1, false, -1))),
|
||||
new SameThreadExecutorService());
|
||||
new SameThreadExecutorService(),
|
||||
new MergePolicy.OneMergeProgress());
|
||||
MergeState mergeState = merger.merge();
|
||||
int docsMerged = mergeState.segmentInfo.maxDoc();
|
||||
assertTrue(docsMerged == 2);
|
||||
|
|
Loading…
Reference in New Issue