Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class FileSwitchDirectory

    Expert: A Directory instance that switches files between two other Directory instances.

    Files with the specified extensions are placed in the primary directory; others are placed in the secondary directory. The provided ISet{string} must not change once passed to this class, and must allow multiple threads to call contains at once.

    Note

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

    Inheritance
    object
    Directory
    BaseDirectory
    FileSwitchDirectory
    Implements
    IDisposable
    Inherited Members
    BaseDirectory.IsOpen
    BaseDirectory.CompareAndSetIsOpen(bool, bool)
    BaseDirectory.m_lockFactory
    BaseDirectory.MakeLock(string)
    BaseDirectory.ClearLock(string)
    BaseDirectory.SetLockFactory(LockFactory)
    BaseDirectory.LockFactory
    BaseDirectory.EnsureOpen()
    Directory.OpenChecksumInput(string, IOContext)
    Directory.Dispose()
    Directory.GetLockID()
    Directory.ToString()
    Directory.Copy(Directory, string, 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 class FileSwitchDirectory : BaseDirectory, IDisposable

    Constructors

    FileSwitchDirectory(ISet<string>, Directory, Directory, bool)

    Expert: A Directory instance that switches files between two other Directory instances.

    Files with the specified extensions are placed in the primary directory; others are placed in the secondary directory. The provided ISet{string} must not change once passed to this class, and must allow multiple threads to call contains at once.

    Note

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

    Declaration
    public FileSwitchDirectory(ISet<string> primaryExtensions, Directory primaryDir, Directory secondaryDir, bool doClose)
    Parameters
    Type Name Description
    ISet<string> primaryExtensions
    Directory primaryDir
    Directory secondaryDir
    bool doClose

    Properties

    PrimaryDir

    Return the primary directory

    Declaration
    public virtual Directory PrimaryDir { get; }
    Property Value
    Type Description
    Directory

    SecondaryDir

    Return the secondary directory

    Declaration
    public virtual Directory SecondaryDir { get; }
    Property Value
    Type Description
    Directory

    Methods

    CreateOutput(string, IOContext)

    Creates a new, empty file in the directory with the given name. Returns a stream writing this file.

    Declaration
    public override IndexOutput CreateOutput(string name, IOContext context)
    Parameters
    Type Name Description
    string name
    IOContext context
    Returns
    Type Description
    IndexOutput
    Overrides
    Directory.CreateOutput(string, IOContext)

    CreateSlicer(string, IOContext)

    Creates an Directory.IndexInputSlicer for the given file name. Directory.IndexInputSlicer allows other Directory implementations to efficiently open one or more sliced IndexInput instances from a single file handle. The underlying file handle is kept open until the Directory.IndexInputSlicer is closed.

    Throws FileNotFoundException if the file does not exist.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Note

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

    Declaration
    public override Directory.IndexInputSlicer CreateSlicer(string name, IOContext context)
    Parameters
    Type Name Description
    string name
    IOContext context
    Returns
    Type Description
    Directory.IndexInputSlicer
    Overrides
    Directory.CreateSlicer(string, IOContext)
    Exceptions
    Type Condition
    IOException

    if an IOException occurs

    DeleteFile(string)

    Removes an existing file in the directory.

    Declaration
    public override void DeleteFile(string name)
    Parameters
    Type Name Description
    string name
    Overrides
    Directory.DeleteFile(string)

    Dispose(bool)

    Disposes the store.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing
    Overrides
    Directory.Dispose(bool)

    FileExists(string)

    Returns true iff a file with the given name exists.

    Declaration
    [Obsolete("this method will be removed in 5.0")]
    public override bool FileExists(string name)
    Parameters
    Type Name Description
    string name
    Returns
    Type Description
    bool
    Overrides
    Directory.FileExists(string)

    FileLength(string)

    Returns the length of a file in the directory. this method follows the following contract:

    Declaration
    public override long FileLength(string name)
    Parameters
    Type Name Description
    string name

    the name of the file for which to return the length.

    Returns
    Type Description
    long
    Overrides
    Directory.FileLength(string)
    Exceptions
    Type Condition
    IOException

    if there was an IO error while retrieving the file's length.

    GetExtension(string)

    Utility method to return a file's extension.

    Declaration
    public static string GetExtension(string name)
    Parameters
    Type Name Description
    string name
    Returns
    Type Description
    string

    ListAll()

    Returns an array of strings, one for each file in the directory.

    Declaration
    public override string[] ListAll()
    Returns
    Type Description
    string[]
    Overrides
    Directory.ListAll()
    Exceptions
    Type Condition
    DirectoryNotFoundException

    if the directory is not prepared for any write operations (such as CreateOutput(string, IOContext)).

    IOException

    in case of other IO errors

    OpenInput(string, IOContext)

    Returns a stream reading an existing file, with the specified read buffer size. The particular Directory implementation may ignore the buffer size. Currently the only Directory implementations that respect this parameter are FSDirectory and CompoundFileDirectory.

    Throws FileNotFoundException if the file does not exist.
    Declaration
    public override IndexInput OpenInput(string name, IOContext context)
    Parameters
    Type Name Description
    string name
    IOContext context
    Returns
    Type Description
    IndexInput
    Overrides
    Directory.OpenInput(string, IOContext)

    Sync(ICollection<string>)

    Ensure that any writes to these files are moved to stable storage. Lucene uses this to properly commit changes to the index, to prevent a machine/OS crash from corrupting the index.

    NOTE: Clients may call this method for same files over and over again, so some impls might optimize for that. For other impls the operation can be a noop, for various reasons.

    Declaration
    public override void Sync(ICollection<string> names)
    Parameters
    Type Name Description
    ICollection<string> names
    Overrides
    Directory.Sync(ICollection<string>)

    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.