Class PersistentSnapshotDeletionPolicy
A SnapshotDeletionPolicy which adds a persistence layer so that snapshots can be maintained across the life of an application. The snapshots are persisted in a Directory and are committed as soon as Snapshot() or Release(IndexCommit) is called.
NOTE: Sharing PersistentSnapshotDeletionPolicys that write to the same directory across IndexWriters will corrupt snapshots. You should make sure every IndexWriter has its own PersistentSnapshotDeletionPolicy and that they all write to a different Directory. It is OK to use the same Directory that holds the index.
This class adds a Release(Int64) method to release commits from a previous snapshot's Generation.
Note
This API is experimental and might change in incompatible ways in the next release.
Inheritance
Inherited Members
Namespace: Lucene.Net.Index
Assembly: Lucene.Net.dll
Syntax
public class PersistentSnapshotDeletionPolicy : SnapshotDeletionPolicy
Constructors
| Improve this Doc View SourcePersistentSnapshotDeletionPolicy(IndexDeletionPolicy, Directory)
PersistentSnapshotDeletionPolicy wraps another IndexDeletionPolicy to enable flexible snapshotting, passing CREATE_OR_APPEND by default.
Declaration
public PersistentSnapshotDeletionPolicy(IndexDeletionPolicy primary, Directory dir)
Parameters
Type | Name | Description |
---|---|---|
IndexDeletionPolicy | primary | the IndexDeletionPolicy that is used on non-snapshotted commits. Snapshotted commits, by definition, are not deleted until explicitly released via Release(IndexCommit). |
Directory | dir | the Directory which will be used to persist the snapshots information. |
PersistentSnapshotDeletionPolicy(IndexDeletionPolicy, Directory, OpenMode)
PersistentSnapshotDeletionPolicy wraps another IndexDeletionPolicy to enable flexible snapshotting.
Declaration
public PersistentSnapshotDeletionPolicy(IndexDeletionPolicy primary, Directory dir, OpenMode mode)
Parameters
Type | Name | Description |
---|---|---|
IndexDeletionPolicy | primary | the IndexDeletionPolicy that is used on non-snapshotted commits. Snapshotted commits, by definition, are not deleted until explicitly released via Release(IndexCommit). |
Directory | dir | the Directory which will be used to persist the snapshots information. |
OpenMode | mode | specifies whether a new index should be created, deleting all existing snapshots information (immediately), or open an existing index, initializing the class with the snapshots information. |
Fields
| Improve this Doc View SourceSNAPSHOTS_PREFIX
Prefix used for the save file.
Declaration
public const string SNAPSHOTS_PREFIX = "snapshots_"
Field Value
Type | Description |
---|---|
System.String |
Properties
| Improve this Doc View SourceLastSaveFile
Returns the file name the snapshots are currently
saved to, or null
if no snapshots have been saved.
Declaration
public virtual string LastSaveFile { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceRelease(IndexCommit)
Deletes a snapshotted commit. Once this method returns, the snapshot information is persisted in the directory.
Declaration
public override void Release(IndexCommit commit)
Parameters
Type | Name | Description |
---|---|---|
IndexCommit | commit |
Overrides
See Also
| Improve this Doc View SourceRelease(Int64)
Deletes a snapshotted commit by generation. Once this method returns, the snapshot information is persisted in the directory.
Declaration
public virtual void Release(long gen)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | gen |
See Also
| Improve this Doc View SourceSnapshot()
Snapshots the last commit. Once this method returns, the snapshot information is persisted in the directory.
Declaration
public override IndexCommit Snapshot()
Returns
Type | Description |
---|---|
IndexCommit |