Search in sources :

Example 1 with MergeSpecification

use of org.apache.lucene.index.MergePolicy.MergeSpecification in project lucene-solr by apache.

the class SegmentsInfoRequestHandler method getMergeCandidatesNames.

private List<String> getMergeCandidatesNames(SolrQueryRequest req, SegmentInfos infos) throws IOException {
    List<String> result = new ArrayList<String>();
    RefCounted<IndexWriter> refCounted = req.getCore().getSolrCoreState().getIndexWriter(req.getCore());
    try {
        IndexWriter indexWriter = refCounted.get();
        //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) {
                    result.add(mergeSegmentInfo.info.name);
                }
            }
        }
        return result;
    } finally {
        refCounted.decref();
    }
}
Also used : OneMerge(org.apache.lucene.index.MergePolicy.OneMerge) SegmentCommitInfo(org.apache.lucene.index.SegmentCommitInfo) IndexWriter(org.apache.lucene.index.IndexWriter) MergePolicy(org.apache.lucene.index.MergePolicy) MergeSpecification(org.apache.lucene.index.MergePolicy.MergeSpecification) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 IndexWriter (org.apache.lucene.index.IndexWriter)1 MergePolicy (org.apache.lucene.index.MergePolicy)1 MergeSpecification (org.apache.lucene.index.MergePolicy.MergeSpecification)1 OneMerge (org.apache.lucene.index.MergePolicy.OneMerge)1 SegmentCommitInfo (org.apache.lucene.index.SegmentCommitInfo)1