Example usage for org.apache.lucene.index SegmentInfos files

List of usage examples for org.apache.lucene.index SegmentInfos files

Introduction

In this page you can find the example usage for org.apache.lucene.index SegmentInfos files.

Prototype

public Collection<String> files(boolean includeSegmentsFile) throws IOException 

Source Link

Document

Returns all file names referenced by SegmentInfo.

Usage

From source file:org.apache.solr.handler.IndexFetcher.java

License:Apache License

private boolean hasUnusedFiles(Directory indexDir, IndexCommit commit) throws IOException {
    String segmentsFileName = commit.getSegmentsFileName();
    SegmentInfos infos = SegmentInfos.readCommit(indexDir, segmentsFileName);
    Set<String> currentFiles = new HashSet<>(infos.files(true));
    String[] allFiles = indexDir.listAll();
    for (String file : allFiles) {
        if (!file.equals(segmentsFileName) && !currentFiles.contains(file) && !file.endsWith(".lock")) {
            LOG.info("Found unused file: " + file);
            return true;
        }/*w w w  . j a  v  a  2  s.  com*/
    }
    return false;
}