Class IndexCommit
- java.lang.Object
-
- org.apache.lucene.index.IndexCommit
-
- All Implemented Interfaces:
Comparable<IndexCommit>
- Direct Known Subclasses:
SnapshotDeletionPolicy.SnapshotCommitPoint
public abstract class IndexCommit extends Object implements Comparable<IndexCommit>
Expert: represents a single commit into an index as seen by the
IndexDeletionPolicy
orIndexReader
.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 Constructor Description IndexCommit()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
compareTo(IndexCommit commit)
abstract void
delete()
Delete this commit point.boolean
equals(Object other)
Two IndexCommits are equal if both their Directory and versions are equal.abstract Directory
getDirectory()
Returns theDirectory
for the index.abstract Collection<String>
getFileNames()
Returns all index files referenced by this commit point.abstract long
getGeneration()
Returns the generation (the _N in segments_N) for this IndexCommitabstract int
getSegmentCount()
Returns number of segments referenced by this commit.abstract String
getSegmentsFileName()
Get the segments file (segments_N
) associated with this commit point.long
getTimestamp()
Deprecated.If you need to track commit time of an index, you can store it in the commit data (seeIndexWriter.commit(Map)
abstract Map<String,String>
getUserData()
Returns userData, previously passed toIndexWriter.commit(Map)
for this commit.abstract long
getVersion()
Deprecated.usegetGeneration()
insteadint
hashCode()
abstract boolean
isDeleted()
-
-
-
Method Detail
-
getSegmentsFileName
public abstract String getSegmentsFileName()
Get the segments file (segments_N
) associated with this commit point.
-
getFileNames
public abstract Collection<String> getFileNames() throws IOException
Returns all index files referenced by this commit point.- Throws:
IOException
-
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
IndexDeletionPolicy
in effect and therefore this should only be called by itsonInit()
oronCommit()
methods.
-
isDeleted
public abstract boolean isDeleted()
-
getSegmentCount
public abstract int getSegmentCount()
Returns number of segments referenced by this commit.
-
equals
public boolean equals(Object other)
Two IndexCommits are equal if both their Directory and versions are equal.
-
getVersion
@Deprecated public abstract long getVersion()
Deprecated.usegetGeneration()
insteadReturns the version for this IndexCommit. This is the same value thatIndexReader.getVersion()
would return if it were opened on this commit.
-
getGeneration
public abstract long getGeneration()
Returns the generation (the _N in segments_N) for this IndexCommit
-
getTimestamp
@Deprecated public long getTimestamp() throws IOException
Deprecated.If you need to track commit time of an index, you can store it in the commit data (seeIndexWriter.commit(Map)
Convenience method that returns the last modified time of the segments_N file corresponding to this index commit, equivalent to getDirectory().fileModified(getSegmentsFileName()).- Throws:
IOException
-
getUserData
public abstract Map<String,String> getUserData() throws IOException
Returns userData, previously passed toIndexWriter.commit(Map)
for this commit. Map is String -> String.- Throws:
IOException
-
compareTo
public int compareTo(IndexCommit commit)
- Specified by:
compareTo
in interfaceComparable<IndexCommit>
-
-