/** * Returns all file names referenced by SegmentInfo. The returned collection is recomputed on each * invocation. */ public Collection<String> files(boolean includeSegmentsFile) throws IOException { HashSet<String> files = new HashSet<>(); if (includeSegmentsFile) { final String segmentFileName = getSegmentsFileName(); if (segmentFileName != null) { files.add(segmentFileName); } } final int size = size(); for (int i = 0; i < size; i++) { final SegmentCommitInfo info = info(i); files.addAll(info.files()); } return files; }