Show / Hide Table of Contents

    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.

    This is a Lucene.NET EXPERIMENTAL API, use at your own risk
    Inheritance
    System.Object
    IndexDeletionPolicy
    SnapshotDeletionPolicy
    PersistentSnapshotDeletionPolicy
    Namespace: Lucene.Net.Index
    Assembly: Lucene.Net.dll
    Syntax
    public class SnapshotDeletionPolicy : IndexDeletionPolicy

    Constructors

    | Improve this Doc View Source

    SnapshotDeletionPolicy(IndexDeletionPolicy)

    Sole constructor, taking the incoming IndexDeletionPolicy to wrap.

    Declaration
    public SnapshotDeletionPolicy(IndexDeletionPolicy primary)
    Parameters
    Type Name Description
    IndexDeletionPolicy primary

    Fields

    | Improve this Doc View Source

    m_indexCommits

    Used to map gen to IndexCommit.

    Declaration
    protected IDictionary<long?, IndexCommit> m_indexCommits
    Field Value
    Type Description
    IDictionary<System.Nullable<System.Int64>, IndexCommit>
    | Improve this Doc View Source

    m_lastCommit

    Most recently committed IndexCommit.

    Declaration
    protected IndexCommit m_lastCommit
    Field Value
    Type Description
    IndexCommit
    | Improve this Doc View Source

    m_refCounts

    Records how many snapshots are held against each commit generation

    Declaration
    protected IDictionary<long, int> m_refCounts
    Field Value
    Type Description
    IDictionary<System.Int64, System.Int32>

    Properties

    | Improve this Doc View Source

    SnapshotCount

    Returns the total number of snapshots currently held.

    Declaration
    public virtual int SnapshotCount { get; }
    Property Value
    Type Description
    System.Int32

    Methods

    | Improve this Doc View Source

    Clone()

    Declaration
    public override object Clone()
    Returns
    Type Description
    System.Object
    Overrides
    IndexDeletionPolicy.Clone()
    | Improve this Doc View Source

    GetIndexCommit(Int64)

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

    Declaration
    public virtual IndexCommit GetIndexCommit(long gen)
    Parameters
    Type Name Description
    System.Int64 gen
    Returns
    Type Description
    IndexCommit
    | Improve this Doc View Source

    GetSnapshots()

    Returns all IndexCommits held by at least one snapshot.

    Declaration
    public virtual IList<IndexCommit> GetSnapshots()
    Returns
    Type Description
    IList<IndexCommit>
    | Improve this Doc View Source

    IncRef(IndexCommit)

    Increments the refCount for this IndexCommit.

    Declaration
    protected virtual void IncRef(IndexCommit ic)
    Parameters
    Type Name Description
    IndexCommit ic
    | Improve this Doc View Source

    OnCommit<T>(IList<T>)

    Declaration
    public override void OnCommit<T>(IList<T> commits)
        where T : IndexCommit
    Parameters
    Type Name Description
    IList<T> commits
    Type Parameters
    Name Description
    T
    Overrides
    Lucene.Net.Index.IndexDeletionPolicy.OnCommit<T>(IList<T>)
    | Improve this Doc View Source

    OnInit<T>(IList<T>)

    Declaration
    public override void OnInit<T>(IList<T> commits)
        where T : IndexCommit
    Parameters
    Type Name Description
    IList<T> commits
    Type Parameters
    Name Description
    T
    Overrides
    Lucene.Net.Index.IndexDeletionPolicy.OnInit<T>(IList<T>)
    | Improve this Doc View Source

    Release(IndexCommit)

    Release a snapshotted commit.

    Declaration
    public virtual void Release(IndexCommit commit)
    Parameters
    Type Name Description
    IndexCommit commit

    the commit previously returned by Snapshot()

    | Improve this Doc View Source

    ReleaseGen(Int64)

    Release a snapshot by generation.

    Declaration
    protected virtual void ReleaseGen(long gen)
    Parameters
    Type Name Description
    System.Int64 gen
    | Improve this Doc View Source

    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.

    Declaration
    public virtual IndexCommit Snapshot()
    Returns
    Type Description
    IndexCommit

    the IndexCommit that was snapshotted.

    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)