Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class BaseDirectory

    Base implementation for a concrete Directory.

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Inheritance
    object
    Directory
    BaseDirectory
    CompoundFileDirectory
    FSDirectory
    FileSwitchDirectory
    NRTCachingDirectory
    RAMDirectory
    Implements
    IDisposable
    Inherited Members
    Directory.ListAll()
    Directory.FileExists(string)
    Directory.DeleteFile(string)
    Directory.FileLength(string)
    Directory.CreateOutput(string, IOContext)
    Directory.Sync(ICollection<string>)
    Directory.OpenInput(string, IOContext)
    Directory.OpenChecksumInput(string, IOContext)
    Directory.Dispose()
    Directory.Dispose(bool)
    Directory.GetLockID()
    Directory.ToString()
    Directory.Copy(Directory, string, string, IOContext)
    Directory.CreateSlicer(string, IOContext)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Lucene.Net.Store
    Assembly: Lucene.Net.dll
    Syntax
    public abstract class BaseDirectory : Directory, IDisposable

    Constructors

    BaseDirectory()

    Sole constructor.

    Declaration
    protected BaseDirectory()

    Fields

    m_lockFactory

    Holds the LockFactory instance (implements locking for this Directory instance).

    Declaration
    protected LockFactory m_lockFactory
    Field Value
    Type Description
    LockFactory

    Properties

    IsOpen

    Gets a value indicating whether the current Directory instance is open.

    Expert: This is useful for implementing the EnsureOpen() logic.
    Declaration
    protected virtual bool IsOpen { get; set; }
    Property Value
    Type Description
    bool

    LockFactory

    Get the LockFactory that this Directory instance is using for its locking implementation. Note that this may be null for Directory implementations that provide their own locking implementation.

    Declaration
    public override LockFactory LockFactory { get; }
    Property Value
    Type Description
    LockFactory
    Overrides
    Directory.LockFactory

    Methods

    ClearLock(string)

    Attempt to clear (forcefully unlock and remove) the specified lock. Only call this at a time when you are certain this lock is no longer in use.

    Declaration
    public override void ClearLock(string name)
    Parameters
    Type Name Description
    string name

    name of the lock to be cleared.

    Overrides
    Directory.ClearLock(string)

    CompareAndSetIsOpen(bool, bool)

    Atomically sets the value to the given updated value if the current value == the expected value.

    Expert: Use this in the Dispose(bool) call to skip duplicate calls by using the folling if block to guard the dispose logic.
    protected override void Dispose(bool disposing)
    {
        if (!CompareAndSetIsOpen(expect: true, update: false)) return;
    
    // Dispose unmanaged resources
    if (disposing)
    {
        // Dispose managed resources
    }
    

    }

    Declaration
    protected bool CompareAndSetIsOpen(bool expect, bool update)
    Parameters
    Type Name Description
    bool expect

    The expected value (the comparand).

    bool update

    The new value.

    Returns
    Type Description
    bool

    true if successful. A false return value indicates that the actual value was not equal to the expected value.

    EnsureOpen()

    Base implementation for a concrete Directory.

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Declaration
    protected override sealed void EnsureOpen()
    Overrides
    Directory.EnsureOpen()
    Exceptions
    Type Condition
    ObjectDisposedException

    if this Directory is closed

    MakeLock(string)

    Construct a Lock.

    Declaration
    public override Lock MakeLock(string name)
    Parameters
    Type Name Description
    string name

    the name of the lock file

    Returns
    Type Description
    Lock
    Overrides
    Directory.MakeLock(string)

    SetLockFactory(LockFactory)

    Set the LockFactory that this Directory instance should use for its locking implementation. Each * instance of LockFactory should only be used for one directory (ie, do not share a single instance across multiple Directories).

    Declaration
    public override void SetLockFactory(LockFactory lockFactory)
    Parameters
    Type Name Description
    LockFactory lockFactory

    instance of LockFactory.

    Overrides
    Directory.SetLockFactory(LockFactory)

    Implements

    IDisposable
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.