A collection of segmentInfo objects with methods for operating on
those segments in relation to the file system.

The active segments in the index are stored in the segment info file,
segments_N. There may be one or more segments_N files in the
index; however, the one with the largest generation is the active one (when
older segments_N files are present it's because they temporarily cannot be
deleted, or, a writer is in the process of committing, or a custom
IndexDeletionPolicy
is in use). This file lists each segment by name and has details about the
codec and generation of deletes.

There is also a file segments.gen. This file contains
the current generation (the _N in segments_N) of the index.
This is used only as a fallback in case the current generation cannot be
accurately determined by directory listing alone (as is the case for some NFS
clients with time-based directory cache expiration). This file simply contains
an Int32 version header
(FORMAT_SEGMENTS_GEN_CURRENT), followed by the
generation recorded as Int64, written twice.

getLastGeneration

setInfoStream

If non-null, information about retries when loading
the segments file will be printed to this.

setDefaultGenLookaheadCount

public static void setDefaultGenLookaheadCount(int count)

Advanced: set how many times to try incrementing the
gen when loading the segments file. This only runs if
the primary (listing directory) and secondary (opening
segments.gen file) methods fail to find the segments
file.

WARNING: This API is experimental and might change in incompatible ways in the next release.

files

Returns all file names referenced by SegmentInfo
instances matching the provided Directory (ie files
associated with any "external" segments are skipped).
The returned collection is recomputed on each
invocation.