List of usage examples for org.apache.lucene.index SegmentInfos files
public Collection<String> files(boolean includeSegmentsFile) throws IOException
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; }