• API

    Show / Hide Table of Contents

    Class NRTCachingDirectory

    Wraps a RAMDirectory around any provided delegate directory, to be used during NRT search.

    This class is likely only useful in a near-real-time context, where indexing rate is lowish but reopen rate is highish, resulting in many tiny files being written. This directory keeps such segments (as well as the segments produced by merging them, as long as they are small enough), in RAM.

    This is safe to use: when your app calls Commit(), all cached files will be flushed from the cached and sync'd.

    Here's a simple example usage:

        Directory fsDir = FSDirectory.Open(new DirectoryInfo("/path/to/index"));
        NRTCachingDirectory cachedFSDir = new NRTCachingDirectory(fsDir, 5.0, 60.0);
        IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_48, analyzer);
        IndexWriter writer = new IndexWriter(cachedFSDir, conf);

    This will cache all newly flushed segments, all merges whose expected segment size is <= 5 MB, unless the net cached bytes exceeds 60 MB at which point all writes will not be cached (until the net bytes falls below 60 MB).

    This is a Lucene.NET EXPERIMENTAL API, use at your own risk
    Inheritance
    System.Object
    Directory
    NRTCachingDirectory
    Implements
    System.IDisposable
    Inherited Members
    Directory.OpenChecksumInput(String, IOContext)
    Directory.Dispose()
    Directory.Copy(Directory, String, String, IOContext)
    Directory.EnsureOpen()
    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 NRTCachingDirectory : Directory, IDisposable

    Constructors

    | Improve this Doc View Source

    NRTCachingDirectory(Directory, Double, Double)

    We will cache a newly created output if 1) it's a flush or a merge and the estimated size of the merged segment is <= maxMergeSizeMB, and 2) the total cached bytes is <= maxCachedMB

    Declaration
    public NRTCachingDirectory(Directory delegate, double maxMergeSizeMB, double maxCachedMB)
    Parameters
    Type Name Description
    Directory delegate
    System.Double maxMergeSizeMB
    System.Double maxCachedMB

    Properties

    | Improve this Doc View Source

    Delegate

    Declaration
    public virtual Directory Delegate { get; }
    Property Value
    Type Description
    Directory
    | Improve this Doc View Source

    LockFactory

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

    Methods

    | Improve this Doc View Source

    ClearLock(String)

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

    CreateOutput(String, IOContext)

    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

    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

    DeleteFile(String)

    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)

    Dispose this directory, which flushes any cached files to the delegate and then disposes the delegate.

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

    DoCacheWrite(String, IOContext)

    Subclass can override this to customize logic; return true if this file should be written to the RAMDirectory.

    Declaration
    protected virtual bool DoCacheWrite(string name, IOContext context)
    Parameters
    Type Name Description
    System.String name
    IOContext context
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    FileExists(String)

    Declaration
    [Obsolete("this method will be removed in 5.0")]
    public override 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)

    Declaration
    public override 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()

    Returns how many bytes are being used by the RAMDirectory cache

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

    ListAll()

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

    ListCachedFiles()

    Declaration
    public virtual string[] ListCachedFiles()
    Returns
    Type Description
    System.String[]
    | Improve this Doc View Source

    MakeLock(String)

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

    OpenInput(String, IOContext)

    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

    SetLockFactory(LockFactory)

    Declaration
    public override void SetLockFactory(LockFactory lockFactory)
    Parameters
    Type Name Description
    LockFactory lockFactory
    Overrides
    Directory.SetLockFactory(LockFactory)
    | Improve this Doc View Source

    Sync(ICollection<String>)

    Declaration
    public override void Sync(ICollection<string> fileNames)
    Parameters
    Type Name Description
    System.Collections.Generic.ICollection<System.String> fileNames
    Overrides
    Directory.Sync(ICollection<String>)
    | Improve this Doc View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    Directory.ToString()

    Implements

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