• API

    Show / Hide Table of Contents

    Class MMapDirectory

    File-based Directory implementation that uses System.IO.MemoryMappedFiles.MemoryMappedFile for reading, and FSDirectory.FSIndexOutput for writing.

    NOTE: memory mapping uses up a portion of the virtual memory address space in your process equal to the size of the file being mapped. Before using this class, be sure your have plenty of virtual address space, e.g. by using a 64 bit runtime, or a 32 bit runtime with indexes that are guaranteed to fit within the address space. On 32 bit platforms also consult MMapDirectory(DirectoryInfo, LockFactory, Int32) if you have problems with mmap failing because of fragmented address space. If you get an System.OutOfMemoryException, it is recommended to reduce the chunk size, until it works.

    NOTE: Accessing this class either directly or indirectly from a thread while it's interrupted can close the underlying channel immediately if at the same time the thread is blocked on IO. The channel will remain closed and subsequent access to MMapDirectory will throw a System.ObjectDisposedException.

    Inheritance
    System.Object
    Directory
    BaseDirectory
    FSDirectory
    MMapDirectory
    Implements
    System.IDisposable
    Inherited Members
    FSDirectory.DEFAULT_READ_CHUNK_SIZE
    FSDirectory.m_directory
    FSDirectory.Open(DirectoryInfo)
    FSDirectory.Open(String)
    FSDirectory.Open(DirectoryInfo, LockFactory)
    FSDirectory.Open(String, LockFactory)
    FSDirectory.SetLockFactory(LockFactory)
    FSDirectory.ListAll(DirectoryInfo)
    FSDirectory.ListAll()
    FSDirectory.FileExists(String)
    FSDirectory.FileLength(String)
    FSDirectory.DeleteFile(String)
    FSDirectory.CreateOutput(String, IOContext)
    FSDirectory.EnsureCanWrite(String)
    FSDirectory.OnIndexOutputClosed(FSDirectory.FSIndexOutput)
    FSDirectory.Sync(ICollection<String>)
    FSDirectory.GetLockID()
    FSDirectory.Dispose(Boolean)
    FSDirectory.Directory
    FSDirectory.ToString()
    FSDirectory.ReadChunkSize
    BaseDirectory.IsOpen
    BaseDirectory.m_lockFactory
    BaseDirectory.MakeLock(String)
    BaseDirectory.ClearLock(String)
    BaseDirectory.LockFactory
    BaseDirectory.EnsureOpen()
    Directory.OpenChecksumInput(String, IOContext)
    Directory.Dispose()
    Directory.Copy(Directory, String, String, IOContext)
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: Lucene.Net.Store
    Assembly: Lucene.Net.dll
    Syntax
    public class MMapDirectory : FSDirectory, IDisposable

    Constructors

    | Improve this Doc View Source

    MMapDirectory(DirectoryInfo)

    Create a new MMapDirectory for the named location and NativeFSLockFactory.

    Declaration
    public MMapDirectory(DirectoryInfo path)
    Parameters
    Type Name Description
    System.IO.DirectoryInfo path

    the path of the directory

    Exceptions
    Type Condition
    System.IO.IOException

    if there is a low-level I/O error

    | Improve this Doc View Source

    MMapDirectory(DirectoryInfo, LockFactory)

    Create a new MMapDirectory for the named location.

    Declaration
    public MMapDirectory(DirectoryInfo path, LockFactory lockFactory)
    Parameters
    Type Name Description
    System.IO.DirectoryInfo path

    the path of the directory

    LockFactory lockFactory

    the lock factory to use, or null for the default (NativeFSLockFactory);

    Exceptions
    Type Condition
    System.IO.IOException

    if there is a low-level I/O error

    | Improve this Doc View Source

    MMapDirectory(DirectoryInfo, LockFactory, Int32)

    Create a new MMapDirectory for the named location, specifying the maximum chunk size used for memory mapping.

    Declaration
    public MMapDirectory(DirectoryInfo path, LockFactory lockFactory, int maxChunkSize)
    Parameters
    Type Name Description
    System.IO.DirectoryInfo path

    the path of the directory

    LockFactory lockFactory

    the lock factory to use, or null for the default (NativeFSLockFactory);

    System.Int32 maxChunkSize

    maximum chunk size (default is 1 GiBytes for 64 bit runtimes and 256 MiBytes for 32 bit runtimes) used for memory mapping.

    Especially on 32 bit platform, the address space can be very fragmented, so large index files cannot be mapped. Using a lower chunk size makes the directory implementation a little bit slower (as the correct chunk may be resolved on lots of seeks) but the chance is higher that mmap does not fail. On 64 bit platforms, this parameter should always be 1 << 30, as the address space is big enough.

    Please note: The chunk size is always rounded down to a power of 2.

    Exceptions
    Type Condition
    System.IO.IOException

    if there is a low-level I/O error

    | Improve this Doc View Source

    MMapDirectory(String)

    Create a new MMapDirectory for the named location and NativeFSLockFactory.

    LUCENENET specific overload for convenience using string instead of System.IO.DirectoryInfo.

    Declaration
    public MMapDirectory(string path)
    Parameters
    Type Name Description
    System.String path

    the path of the directory

    Exceptions
    Type Condition
    System.IO.IOException

    if there is a low-level I/O error

    | Improve this Doc View Source

    MMapDirectory(String, LockFactory)

    Create a new MMapDirectory for the named location.

    LUCENENET specific overload for convenience using string instead of System.IO.DirectoryInfo.

    Declaration
    public MMapDirectory(string path, LockFactory lockFactory)
    Parameters
    Type Name Description
    System.String path

    the path of the directory

    LockFactory lockFactory

    the lock factory to use, or null for the default (NativeFSLockFactory);

    Exceptions
    Type Condition
    System.IO.IOException

    if there is a low-level I/O error

    | Improve this Doc View Source

    MMapDirectory(String, LockFactory, Int32)

    Create a new MMapDirectory for the named location, specifying the maximum chunk size used for memory mapping.

    LUCENENET specific overload for convenience using string instead of System.IO.DirectoryInfo.

    Declaration
    public MMapDirectory(string path, LockFactory lockFactory, int maxChunkSize)
    Parameters
    Type Name Description
    System.String path

    the path of the directory

    LockFactory lockFactory

    the lock factory to use, or null for the default (NativeFSLockFactory);

    System.Int32 maxChunkSize

    maximum chunk size (default is 1 GiBytes for 64 bit runtimes and 256 MiBytes for 32 bit runtimes) used for memory mapping.

    Especially on 32 bit platform, the address space can be very fragmented, so large index files cannot be mapped. Using a lower chunk size makes the directory implementation a little bit slower (as the correct chunk may be resolved on lots of seeks) but the chance is higher that mmap does not fail. On 64 bit platforms, this parameter should always be 1 << 30, as the address space is big enough.

    Please note: The chunk size is always rounded down to a power of 2.

    Exceptions
    Type Condition
    System.IO.IOException

    if there is a low-level I/O error

    Fields

    | Improve this Doc View Source

    DEFAULT_MAX_BUFF

    Default max chunk size.

    Declaration
    public static readonly int DEFAULT_MAX_BUFF
    Field Value
    Type Description
    System.Int32
    See Also
    MMapDirectory(DirectoryInfo, LockFactory, Int32)

    Properties

    | Improve this Doc View Source

    MaxChunkSize

    Returns the current mmap chunk size.

    Declaration
    public int MaxChunkSize { get; }
    Property Value
    Type Description
    System.Int32
    See Also
    MMapDirectory(DirectoryInfo, LockFactory, Int32)

    Methods

    | Improve this Doc View Source

    CreateSlicer(String, IOContext)

    Declaration
    public override Directory.IndexInputSlicer CreateSlicer(string name, IOContext context)
    Parameters
    Type Name Description
    System.String name
    IOContext context
    Returns
    Type Description
    Directory.IndexInputSlicer
    Overrides
    Directory.CreateSlicer(String, IOContext)
    | Improve this Doc View Source

    OpenInput(String, IOContext)

    Creates an IndexInput for the file with the given name.

    Declaration
    public override IndexInput OpenInput(string name, IOContext context)
    Parameters
    Type Name Description
    System.String name
    IOContext context
    Returns
    Type Description
    IndexInput
    Overrides
    Directory.OpenInput(String, IOContext)

    Implements

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