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).
@lucene.experimental
Inherited Members
Assembly: DistributedLucene.Net.dll
Syntax
public class NRTCachingDirectory : Directory
Constructors
Name | Description |
---|---|
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 |
Properties
Name | Description |
---|---|
Delegate | |
LockFactory |
Methods
Name | Description |
---|---|
ClearLock(String) | |
CreateOutput(String, IOContext) | |
CreateSlicer(String, IOContext) | |
DeleteFile(String) | |
Dispose(Boolean) | Dispose this directory, which flushes any cached files to the delegate and then disposes the delegate. |
DoCacheWrite(String, IOContext) | Subclass can override this to customize logic; return
|
FileExists(String) | |
FileLength(String) | |
GetLockID() | |
GetSizeInBytes() | Returns how many bytes are being used by the RAMDirectory cache |
ListAll() | |
ListCachedFiles() | |
MakeLock(String) | |
OpenInput(String, IOContext) | |
SetLockFactory(LockFactory) | |
Sync(ICollection<String>) | |
ToString() |