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).
Note
This API is experimental and might change in incompatible ways in the next release.
Inheritance
System.Object
NRTCachingDirectory
Implements
System.IDisposable
Inherited Members
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)
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
|
Improve this Doc
View Source
LockFactory
Declaration
public override LockFactory LockFactory { get; }
Property Value
Overrides
Methods
|
Improve this Doc
View Source
ClearLock(String)
Declaration
public override void ClearLock(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Overrides
|
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
Overrides
|
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
Overrides
|
Improve this Doc
View Source
DeleteFile(String)
Declaration
public override void DeleteFile(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Overrides
|
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
|
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
|
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
|
Improve this Doc
View Source
GetLockID()
Declaration
public override string GetLockID()
Returns
Type |
Description |
System.String |
|
Overrides
|
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
|
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
Overrides
|
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
Overrides
|
Improve this Doc
View Source
SetLockFactory(LockFactory)
Declaration
public override void SetLockFactory(LockFactory lockFactory)
Parameters
Overrides
|
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
|
Improve this Doc
View Source
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
Implements
System.IDisposable