Class 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 IndexWriter 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 PersistentSnapshotDeletionPolicy.
@lucene.experimental
Assembly: DistributedLucene.Net.dll
Syntax
public class SnapshotDeletionPolicy : IndexDeletionPolicy
Constructors
Name | Description |
---|---|
SnapshotDeletionPolicy(IndexDeletionPolicy) | Sole constructor, taking the incoming IndexDeletionPolicy to wrap. |
Fields
Name | Description |
---|---|
m_indexCommits | Used to map gen to IndexCommit. |
m_lastCommit | Most recently committed IndexCommit. |
m_refCounts | Records how many snapshots are held against each commit generation |
Properties
Name | Description |
---|---|
SnapshotCount | Returns the total number of snapshots currently held. |
Methods
Name | Description |
---|---|
Clone() | |
GetIndexCommit(Int64) | Retrieve an IndexCommit from its generation;
returns |
GetSnapshots() | Returns all IndexCommits held by at least one snapshot. |
IncRef(IndexCommit) | Increments the refCount for this IndexCommit. |
OnCommit<T>(IList<T>) | |
OnInit<T>(IList<T>) | |
Release(IndexCommit) | Release a snapshotted commit. |
ReleaseGen(Int64) | Release a snapshot by generation. |
Snapshot() | 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(IndexCommit) followed by a call to DeleteUnusedFiles(). NOTE: while the snapshot is held, the files it references will not be deleted, which will consume additional disk space in your index. If you take a snapshot at a particularly bad time (say just before you call ForceMerge(Int32)) then in the worst case this could consume an extra 1X of your total index size, until you release the snapshot. |