Java Code Examples for org.apache.lucene.index.MergeTrigger

The following examples show how to use org.apache.lucene.index.MergeTrigger. These examples are extracted from open source projects. 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 Project: lucene-solr   Source File: SegmentsInfoRequestHandler.java    License: Apache License 2.0 6 votes vote down vote up
private SimpleOrderedMap<Object> getMergeInformation(SolrQueryRequest req, SegmentInfos infos, List<String> mergeCandidates) throws IOException {
  SimpleOrderedMap<Object> result = new SimpleOrderedMap<>();
  RefCounted<IndexWriter> refCounted = req.getCore().getSolrCoreState().getIndexWriter(req.getCore());
  try {
    IndexWriter indexWriter = refCounted.get();
    if (indexWriter instanceof SolrIndexWriter) {
      result.addAll(((SolrIndexWriter)indexWriter).getRunningMerges());
    }
    //get chosen merge policy
    MergePolicy mp = indexWriter.getConfig().getMergePolicy();
    //Find merges
    MergeSpecification findMerges = mp.findMerges(MergeTrigger.EXPLICIT, infos, indexWriter);
    if (findMerges != null && findMerges.merges != null && findMerges.merges.size() > 0) {
      for (OneMerge merge : findMerges.merges) {
        //TODO: add merge grouping
        for (SegmentCommitInfo mergeSegmentInfo : merge.segments) {
          mergeCandidates.add(mergeSegmentInfo.info.name);
        }
      }
    }

    return result;
  } finally {
    refCounted.decref();
  }
}
 
Example 2
Source Project: Elasticsearch   Source File: ElasticsearchMergePolicy.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public MergeSpecification findMerges(MergeTrigger mergeTrigger,
    SegmentInfos segmentInfos, IndexWriter writer) throws IOException {
    return upgradedMergeSpecification(delegate.findMerges(mergeTrigger, segmentInfos, writer));
}
 
Example 3
Source Project: linden   Source File: SortingMergePolicyDecorator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public MergeSpecification findMerges(MergeTrigger mergeTrigger, SegmentInfos segmentInfos,
                                     IndexWriter writer) throws IOException {
  return sortingMergePolicy.findMerges(mergeTrigger, segmentInfos, writer);
}