SegmentInfos
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 custom IndexDeletionPolicy is in use). This file lists each segment by name and has details about the codec and generation of deletes.
Files:
segments_N: Header, LuceneVersion, Version, NameCounter, SegCount, MinSegmentLuceneVersion,SegCount, CommitUserData, Footer
Data types:
Header -->IndexHeader
LuceneVersion --> Which Lucene code Version was used for this commit, written as three DataOutput.writeVInt: major, minor, bugfix
MinSegmentLuceneVersion --> Lucene code Version of the oldest segment, written as three DataOutput.writeVInt: major, minor, bugfix; this is only written only if there's at least one segment
NameCounter, SegCount, DeletionCount -->DataOutput.writeInt
Generation, Version, DelGen, Checksum, FieldInfosGen, DocValuesGen -->DataOutput.writeLong
SegID -->DataOutput.writeByte
SegName, SegCodec -->DataOutput.writeString
CommitUserData -->DataOutput.writeMapOfStrings
UpdatesFiles --> Map
Footer -->CodecFooter
Field Descriptions:
Version counts how often the index has been changed by adding or deleting documents.
NameCounter is used to generate names for new segment files.
SegName is the name of the segment, and is used as the file name prefix for all of the files that compose the segment's index.
DelGen is the generation count of the deletes file. If this is -1, there are no deletes. Anything above zero means there are deletes stored by LiveDocsFormat.
DeletionCount records the number of deleted documents in this segment.
SegCodec is the Codec.getName of the Codec that encoded this segment.
SegID is the identifier of the Codec that encoded this segment.
CommitUserData stores an optional user-supplied opaque Map
that was passed to IndexWriter.setLiveCommitData. FieldInfosGen is the generation count of the fieldInfos file. If this is -1, there are no updates to the fieldInfos in that segment. Anything above zero means there are updates to fieldInfos stored by FieldInfosFormat .
DocValuesGen is the generation count of the updatable DocValues. If this is -1, there are no updates to DocValues in that segment. Anything above zero means there are updates to DocValues stored by DocValuesFormat.
UpdatesFiles stores the set of files that were updated in that segment per field.
Types
Utility class for executing code that needs to do something with the current segments file. This is necessary with lock-less commits because from the time you locate the current segments file name, until you actually open it, read its contents, or check modified time, etc., it could have been deleted due to a writer commit finishing.
Properties
Returns current generation.
The Lucene version major that was used to create the index.
Returns last succesfully read or written generation.
Opaque MapuserData saved with this commit.
Functions
Appends the provided SegmentCommitInfo.
Appends the provided SegmentCommitInfos.
applies all changes caused by committing a merge to this SegmentInfos
Returns all contained segments as an unmodifiable List view.
Clear all SegmentCommitInfos.
Returns a copy of this instance, also copying each SegmentInfo.
Return true if the provided SegmentCommitInfo is contained.
Returns all file names referenced by SegmentInfo. The returned collection is recomputed on each invocation.
Returns the committed segments_N filename.
Returns the version of the oldest segment, or null if there are no segments.
Returns index of the provided SegmentCommitInfo.
Returns SegmentCommitInfo at the provided index.
Returns an unmodifiable Iterator of contained segments in order.
Call this to start a commit. This writes the new segments file, but writes an invalid checksum at the end, so that it is not visible to readers. Once this is called you must call .finishCommit to complete the commit or .rollbackCommit to abort it.
Remove the SegmentCommitInfo at the provided index.
Remove the provided SegmentCommitInfo.
Replaces all segments in this instance, but keeps generation, version, counter so that future commits remain write once.
Set the generation to be used for the next commit
Sets the commit data.
Returns number of SegmentCommitInfos.
Returns sum of all segment's maxDocs. Note that this does not include deletions
Carry over generation numbers from another SegmentInfos
Write ourselves to the provided IndexOutput