org.apache.lucene.index

## Class IndexCommit

- java.lang.Object
- - org.apache.lucene.index.IndexCommit

- All Implemented Interfaces:
    IndexCommitPoint

      public abstract class IndexCommit
      extends java.lang.Object
      implements IndexCommitPoint

  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 a new and experimental and may suddenly change.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `IndexCommit()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `delete()` Delete this commit point.
    `boolean` | `equals(java.lang.Object other)` Two IndexCommits are equal if both their Directory and versions are equal.
    `abstract Directory` | `getDirectory()` Returns the `Directory` for the index.
    `abstract java.util.Collection` | `getFileNames()` Returns all index files referenced by this commit point.
    `abstract long` | `getGeneration()` Returns the generation (the _N in segments_N) for this IndexCommit
    `abstract java.lang.String` | `getSegmentsFileName()` Get the segments file (`segments_N`) associated with this commit point.
    `long` | `getTimestamp()` Convenience method that returns the last modified time of the segments_N file corresponding to this index commit, equivalent to getDirectory().fileModified(getSegmentsFileName()).
    `abstract java.util.Map` | `getUserData()` Returns userData, previously passed to `IndexWriter.commit(Map)` for this commit.
    `abstract long` | `getVersion()` Returns the version for this IndexCommit.
    `int` | `hashCode()`
    `abstract boolean` | `isDeleted()`
    `abstract boolean` | `isOptimized()` Returns true if this commit is an optimized index.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### IndexCommit

          public IndexCommit()

  - ### Method Detail

    - #### getSegmentsFileName

          public abstract java.lang.String getSegmentsFileName()

      Get the segments file (`segments_N`) associated with this commit point.
      Specified by:
        `getSegmentsFileName` in interface `IndexCommitPoint`

    - #### getFileNames

          public abstract java.util.Collection getFileNames()
                                                     throws java.io.IOException

      Returns all index files referenced by this commit point.
      Specified by:
        `getFileNames` in interface `IndexCommitPoint`
      Throws:
        `java.io.IOException`

    - #### getDirectory

          public abstract Directory getDirectory()

      Returns the `Directory` for 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 `IndexDeletionPolicy` in effect and therefore this should only be called by its `onInit()` or `onCommit()` methods.

      Specified by:
        `delete` in interface `IndexCommitPoint`

    - #### isDeleted

          public abstract boolean isDeleted()

    - #### isOptimized

          public abstract boolean isOptimized()

      Returns true if this commit is an optimized index.

    - #### equals

          public boolean equals(java.lang.Object other)

      Two IndexCommits are equal if both their Directory and versions are equal.
      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### getVersion

          public abstract long getVersion()

      Returns the version for this IndexCommit. This is the same value that `IndexReader.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

          public long getTimestamp()
                            throws java.io.IOException

      Convenience method that returns the last modified time of the segments_N file corresponding to this index commit, equivalent to getDirectory().fileModified(getSegmentsFileName()).
      Throws:
        `java.io.IOException`

    - #### getUserData

          public abstract java.util.Map getUserData()
                                             throws java.io.IOException

      Returns userData, previously passed to `IndexWriter.commit(Map)` for this commit. Map is String -> String.
      Throws:
        `java.io.IOException`

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.