org.apache.lucene.index

## Class SnapshotDeletionPolicy.SnapshotCommitPoint

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

- All Implemented Interfaces:
    Comparable<IndexCommit>
  Enclosing class:
    SnapshotDeletionPolicy

      protected class SnapshotDeletionPolicy.SnapshotCommitPoint
      extends IndexCommit

  Wraps a provided `IndexCommit` and prevents it from being deleted.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected IndexCommit` | `cp` The `IndexCommit` we are preventing from deletion.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `SnapshotDeletionPolicy.SnapshotCommitPoint(IndexCommit cp)` Creates a `SnapshotCommitPoint` wrapping the provided `IndexCommit`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `delete()` Delete this commit point.
    `Directory` | `getDirectory()` Returns the `Directory` for the index.
    `Collection<String>` | `getFileNames()` Returns all index files referenced by this commit point.
    `long` | `getGeneration()` Returns the generation (the _N in segments_N) for this IndexCommit
    `int` | `getSegmentCount()` Returns number of segments referenced by this commit.
    `String` | `getSegmentsFileName()` Get the segments file (`segments_N`) associated with this commit point.
    `Map<String,String>` | `getUserData()` Returns userData, previously passed to `IndexWriter.setCommitData(Map)` for this commit.
    `boolean` | `isDeleted()` Returns true if this commit should be deleted; this is only used by `IndexWriter` after invoking the `IndexDeletionPolicy`.
    `protected boolean` | `shouldDelete(String segmentsFileName)` Returns true if this segment can be deleted.
    `String` | `toString()`

    - ### Methods inherited from class org.apache.lucene.index.IndexCommit

      `compareTo, equals, hashCode`

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

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

- - ### Field Detail

    - #### cp

          protected IndexCommit cp

      The `IndexCommit` we are preventing from deletion.

  - ### Constructor Detail

    - #### SnapshotDeletionPolicy.SnapshotCommitPoint

          protected SnapshotDeletionPolicy.SnapshotCommitPoint(IndexCommit cp)

      Creates a `SnapshotCommitPoint` wrapping the provided `IndexCommit`.

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### shouldDelete

          protected boolean shouldDelete(String segmentsFileName)

      Returns true if this segment can be deleted. The default implementation returns false if this segment is currently held as snapshot.

    - #### delete

          public void delete()

      Description copied from class: `IndexCommit`
      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 class `IndexCommit`

    - #### getDirectory

          public Directory getDirectory()

      Description copied from class: `IndexCommit`
      Returns the `Directory` for the index.
      Specified by:
        `getDirectory` in class `IndexCommit`

    - #### getFileNames

          public Collection<String> getFileNames()
                                          throws IOException

      Description copied from class: `IndexCommit`
      Returns all index files referenced by this commit point.
      Specified by:
        `getFileNames` in class `IndexCommit`
      Throws:
        `IOException`

    - #### getGeneration

          public long getGeneration()

      Description copied from class: `IndexCommit`
      Returns the generation (the _N in segments_N) for this IndexCommit
      Specified by:
        `getGeneration` in class `IndexCommit`

    - #### getSegmentsFileName

          public String getSegmentsFileName()

      Description copied from class: `IndexCommit`
      Get the segments file (`segments_N`) associated with this commit point.
      Specified by:
        `getSegmentsFileName` in class `IndexCommit`

    - #### getUserData

          public Map<String,String> getUserData()
                                         throws IOException

      Description copied from class: `IndexCommit`
      Returns userData, previously passed to `IndexWriter.setCommitData(Map)` for this commit. Map is String -> String.
      Specified by:
        `getUserData` in class `IndexCommit`
      Throws:
        `IOException`

    - #### isDeleted

          public boolean isDeleted()

      Description copied from class: `IndexCommit`
      Returns true if this commit should be deleted; this is only used by `IndexWriter` after invoking the `IndexDeletionPolicy`.
      Specified by:
        `isDeleted` in class `IndexCommit`

    - #### getSegmentCount

          public int getSegmentCount()

      Description copied from class: `IndexCommit`
      Returns number of segments referenced by this commit.
      Specified by:
        `getSegmentCount` in class `IndexCommit`

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