Show / Hide Table of Contents

    Class RAMDirectory

    A memory-resident Directory implementation. Locking implementation is by default the SingleInstanceLockFactory but can be changed with SetLockFactory(LockFactory).

    Warning: This class is not intended to work with huge indexes. Everything beyond several hundred megabytes will waste resources (GC cycles), because it uses an internal buffer size of 1024 bytes, producing millions of byte[1024] arrays. This class is optimized for small memory-resident indexes. It also has bad concurrency on multithreaded environments.

    It is recommended to materialize large indexes on disk and use MMapDirectory, which is a high-performance directory implementation working directly on the file system cache of the operating system, so copying data to heap space is not useful.

    Inheritance
    System.Object
    Directory
    BaseDirectory
    RAMDirectory
    Inherited Members
    BaseDirectory.IsOpen
    BaseDirectory.m_lockFactory
    BaseDirectory.MakeLock(String)
    BaseDirectory.ClearLock(String)
    BaseDirectory.SetLockFactory(LockFactory)
    BaseDirectory.LockFactory
    BaseDirectory.EnsureOpen()
    Directory.OpenChecksumInput(String, IOContext)
    Directory.Dispose()
    Directory.ToString()
    Directory.Copy(Directory, String, String, IOContext)
    Directory.CreateSlicer(String, IOContext)
    Namespace: Lucene.Net.Store
    Assembly: Lucene.Net.dll
    Syntax
    public class RAMDirectory : BaseDirectory

    Constructors

    | Improve this Doc View Source

    RAMDirectory()

    Constructs an empty Directory.

    Declaration
    public RAMDirectory()
    | Improve this Doc View Source

    RAMDirectory(Directory, IOContext)

    Creates a new RAMDirectory instance from a different Directory implementation. This can be used to load a disk-based index into memory.

    Warning: this class is not intended to work with huge indexes. Everything beyond several hundred megabytes will waste resources (GC cycles), because it uses an internal buffer size of 1024 bytes, producing millions of byte[1024] arrays. this class is optimized for small memory-resident indexes. It also has bad concurrency on multithreaded environments.

    For disk-based indexes it is recommended to use MMapDirectory, which is a high-performance directory implementation working directly on the file system cache of the operating system, so copying data to heap space is not useful.

    Note that the resulting RAMDirectory instance is fully independent from the original Directory (it is a complete copy). Any subsequent changes to the original Directory will not be visible in the RAMDirectory instance.

    Declaration
    public RAMDirectory(Directory dir, IOContext context)
    Parameters
    Type Name Description
    Directory dir

    a Directory value

    IOContext context

    io context

    Fields

    | Improve this Doc View Source

    m_fileMap

    Declaration
    protected readonly ConcurrentDictionary<string, RAMFile> m_fileMap
    Field Value
    Type Description
    ConcurrentDictionary<System.String, RAMFile>
    | Improve this Doc View Source

    m_sizeInBytes

    Declaration
    protected readonly AtomicInt64 m_sizeInBytes
    Field Value
    Type Description
    AtomicInt64

    Methods

    | Improve this Doc View Source

    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
    System.String name
    IOContext context
    Returns
    Type Description
    IndexOutput
    Overrides
    Directory.CreateOutput(String, IOContext)
    | Improve this Doc View Source

    DeleteFile(String)

    Removes an existing file in the directory.

    Declaration
    public override void DeleteFile(string name)
    Parameters
    Type Name Description
    System.String name
    Overrides
    Directory.DeleteFile(String)
    | Improve this Doc View Source

    Dispose(Boolean)

    Closes the store to future operations, releasing associated memory.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing
    Overrides
    Directory.Dispose(Boolean)
    | Improve this Doc View Source

    FileExists(String)

    Returns true iff the named file exists in this directory.

    Declaration
    public override sealed bool FileExists(string name)
    Parameters
    Type Name Description
    System.String name
    Returns
    Type Description
    System.Boolean
    Overrides
    Directory.FileExists(String)
    | Improve this Doc View Source

    FileLength(String)

    Returns the length in bytes of a file in the directory.

    Declaration
    public override sealed long FileLength(string name)
    Parameters
    Type Name Description
    System.String name
    Returns
    Type Description
    System.Int64
    Overrides
    Directory.FileLength(String)
    | Improve this Doc View Source

    GetLockID()

    Declaration
    public override string GetLockID()
    Returns
    Type Description
    System.String
    Overrides
    Directory.GetLockID()
    | Improve this Doc View Source

    GetSizeInBytes()

    Return total size in bytes of all files in this directory. This is currently quantized to Lucene.Net.Store.RAMOutputStream.BUFFER_SIZE.

    Declaration
    public long GetSizeInBytes()
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    ListAll()

    Declaration
    public override sealed string[] ListAll()
    Returns
    Type Description
    System.String[]
    Overrides
    Directory.ListAll()
    | Improve this Doc View Source

    NewRAMFile()

    Returns a new RAMFile for storing data. this method can be overridden to return different RAMFile impls, that e.g. override NewBuffer(Int32).

    Declaration
    protected virtual RAMFile NewRAMFile()
    Returns
    Type Description
    RAMFile
    | Improve this Doc View Source

    OpenInput(String, IOContext)

    Returns a stream reading an existing file.

    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)
    | Improve this Doc View Source

    Sync(ICollection<String>)

    Declaration
    public override void Sync(ICollection<string> names)
    Parameters
    Type Name Description
    ICollection<System.String> names
    Overrides
    Directory.Sync(ICollection<String>)
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)