Package org.apache.lucene.index
Class IndexCommit
java.lang.Object
org.apache.lucene.index.IndexCommit
- All Implemented Interfaces:
Comparable<IndexCommit>
Expert: represents a single commit into an index as seen by the
IndexDeletionPolicy or
IndexReader.
Changes to the content of an index are made visible only after the writer who made that change
commits by writing a new segments file (segments_N). This point in time, when the
action of writing of a new segments file to the directory is completed, is an index commit.
Each index commit point has a unique segments file associated with it. The segments file associated with a later index commit point would have a larger N.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(IndexCommit commit) abstract voiddelete()Delete this commit point.booleanTwo IndexCommits are equal if both their Directory and versions are equal.abstract DirectoryReturns theDirectoryfor the index.abstract Collection<String> Returns all index files referenced by this commit point.abstract longReturns the generation (the _N in segments_N) for this IndexCommitabstract intReturns number of segments referenced by this commit.abstract StringGet the segments file (segments_N) associated with this commit point.Returns userData, previously passed toIndexWriter.setLiveCommitData(Iterable)for this commit.inthashCode()abstract booleanReturns true if this commit should be deleted; this is only used byIndexWriterafter invoking theIndexDeletionPolicy.
-
Constructor Details
-
IndexCommit
protected IndexCommit()Sole constructor. (For invocation by subclass constructors, typically implicit.)
-
-
Method Details
-
getSegmentsFileName
Get the segments file (segments_N) associated with this commit point. -
getFileNames
Returns all index files referenced by this commit point.- Throws:
IOException
-
getDirectory
Returns theDirectoryfor the index. -
delete
public abstract void delete()Delete this commit point. This only applies when using the commit point in the context of IndexWriter's IndexDeletionPolicy.Upon calling this, the writer is notified that this commit point should be deleted.
Decision that a commit-point should be deleted is taken by the
IndexDeletionPolicyin effect and therefore this should only be called by itsonInit()oronCommit()methods. -
isDeleted
public abstract boolean isDeleted()Returns true if this commit should be deleted; this is only used byIndexWriterafter invoking theIndexDeletionPolicy. -
getSegmentCount
public abstract int getSegmentCount()Returns number of segments referenced by this commit. -
equals
Two IndexCommits are equal if both their Directory and versions are equal. -
hashCode
public int hashCode() -
getGeneration
public abstract long getGeneration()Returns the generation (the _N in segments_N) for this IndexCommit -
getUserData
Returns userData, previously passed toIndexWriter.setLiveCommitData(Iterable)for this commit. Map isString -> String.- Throws:
IOException
-
compareTo
- Specified by:
compareToin interfaceComparable<IndexCommit>
-