Java Code Examples for org.apache.lucene.index.MergePolicy#OneMerge

The following examples show how to use org.apache.lucene.index.MergePolicy#OneMerge . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestMergeSchedulerExternal.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
protected MergeThread getMergeThread(MergeSource mergeSource, MergePolicy.OneMerge merge) throws IOException {
  MergeThread thread = new MyMergeThread(mergeSource, merge);
  thread.setDaemon(true);
  thread.setName("MyMergeThread");
  return thread;
}
 
Example 2
Source File: ElasticsearchConcurrentMergeScheduler.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("sync-override")
protected MergeThread getMergeThread(IndexWriter writer, MergePolicy.OneMerge merge) throws IOException {
    MergeThread thread = super.getMergeThread(writer, merge);
    thread.setName(EsExecutors.threadName(indexSettings, "[" + shardId.getIndexName() + "][" + shardId.id() + "]: " + thread.getName()));
    return thread;
}
 
Example 3
Source File: OnGoingMerge.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public OnGoingMerge(MergePolicy.OneMerge merge) {
    this.id = Integer.toString(System.identityHashCode(merge));
    this.mergedSegments = merge.segments;
}
 
Example 4
Source File: TestMergeSchedulerExternal.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public MyMergeThread(MergeSource mergeSource, MergePolicy.OneMerge merge) {
  super(mergeSource, merge);
  mergeThreadCreated = true;
}
 
Example 5
Source File: TestMergeSchedulerExternal.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
protected void doMerge(MergeSource mergeSource, MergePolicy.OneMerge merge) throws IOException {
  mergeCalled = true;
  super.doMerge(mergeSource, merge);
}
 
Example 6
Source File: ElasticsearchConcurrentMergeScheduler.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
protected void doMerge(IndexWriter writer, MergePolicy.OneMerge merge) throws IOException {
    int totalNumDocs = merge.totalNumDocs();
    long totalSizeInBytes = merge.totalBytesSize();
    long timeNS = System.nanoTime();
    OnGoingMerge onGoingMerge = new OnGoingMerge(merge);
    onGoingMerges.add(onGoingMerge);

    if (logger.isTraceEnabled()) {
        logger.trace("merge [{}] starting..., merging [{}] segments, [{}] docs, [{}] size, into [{}] estimated_size", OneMergeHelper.getSegmentName(merge), merge.segments.size(), totalNumDocs, new ByteSizeValue(totalSizeInBytes), new ByteSizeValue(merge.estimatedMergeBytes));
    }
    try {
        beforeMerge(onGoingMerge);
        super.doMerge(writer, merge);
    } finally {
        long tookMS = TimeValue.nsecToMSec(System.nanoTime() - timeNS);

        onGoingMerges.remove(onGoingMerge);
        afterMerge(onGoingMerge);

        long stoppedMS = TimeValue.nsecToMSec(
            merge.getMergeProgress().getPauseTimes().get(MergePolicy.OneMergeProgress.PauseReason.STOPPED)
        );
        long throttledMS = TimeValue.nsecToMSec(
            merge.getMergeProgress().getPauseTimes().get(MergePolicy.OneMergeProgress.PauseReason.PAUSED)
        );
        final Thread thread = Thread.currentThread();
        long totalBytesWritten = OneMergeHelper.getTotalBytesWritten(thread, merge);
        double mbPerSec = OneMergeHelper.getMbPerSec(thread, merge);

        String message = String.format(
            Locale.ROOT,
            "merge segment [%s] done: took [%s], [%,.1f MB], [%,d docs], [%s stopped], [%s throttled], [%,.1f MB written], [%,.1f MB/sec throttle]",
            OneMergeHelper.getSegmentName(merge),
            TimeValue.timeValueMillis(tookMS),
            totalSizeInBytes / 1024f / 1024f,
            totalNumDocs,
            TimeValue.timeValueMillis(stoppedMS),
            TimeValue.timeValueMillis(throttledMS),
            totalBytesWritten / 1024f / 1024f,
            mbPerSec
        );

        if (tookMS > 20000) { // if more than 20 seconds, DEBUG log it
            logger.debug("{}", message);
        } else if (logger.isTraceEnabled()) {
            logger.trace("{}", message);
        }
    }
}
 
Example 7
Source File: OnGoingMerge.java    From crate with Apache License 2.0 4 votes vote down vote up
public OnGoingMerge(MergePolicy.OneMerge merge) {
    this.id = Integer.toString(System.identityHashCode(merge));
    this.oneMerge = merge;
}