SnapshotDeletionPolicy

An IndexDeletionPolicy that wraps any other IndexDeletionPolicy and adds the ability to hold and later release snapshots of an index. While a snapshot is held, the [ ] will not remove any files associated with it even if the index is otherwise being actively, arbitrarily changed. Because we wrap another arbitrary IndexDeletionPolicy, this gives you the freedom to continue using whatever IndexDeletionPolicy you would normally want to use with your index.

This class maintains all snapshots in-memory, and so the information is not persisted and not protected against system failures. If persistence is important, you can use [ ].

Inheritors

Constructors

Link copied to clipboard
constructor(primary: IndexDeletionPolicy)

Functions

Link copied to clipboard

Retrieve an IndexCommit from its generation; returns null if this IndexCommit is not currently snapshotted

Link copied to clipboard

Returns the total number of snapshots currently held.

Link copied to clipboard

Returns all IndexCommits held by at least one snapshot.

Link copied to clipboard
open override fun onCommit(commits: MutableList<out IndexCommit>)

This is called each time the writer completed a commit. This gives the policy a chance to remove old commit points with each commit.

Link copied to clipboard
open override fun onInit(commits: MutableList<out IndexCommit>)

This is called once when a writer is first instantiated to give the policy a chance to remove old commit points.

Link copied to clipboard
open fun release(commit: IndexCommit)

Release a snapshotted commit.

Link copied to clipboard
open fun snapshot(): IndexCommit

Snapshots the last commit and returns it. Once a commit is 'snapshotted,' it is protected from deletion (as long as this IndexDeletionPolicy is used). The snapshot can be removed by calling .release followed by a call to .