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.
Inherited Members
Assembly: DistributedLucene.Net.dll
Syntax
public class RAMDirectory : BaseDirectory
Constructors
Name | Description |
---|---|
RAMDirectory() | Constructs an empty Directory. |
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. |
Fields
Name | Description |
---|---|
m_fileMap | |
m_sizeInBytes |
Methods
Name | Description |
---|---|
CreateOutput(String, IOContext) | Creates a new, empty file in the directory with the given name. Returns a stream writing this file. |
DeleteFile(String) | Removes an existing file in the directory. |
Dispose(Boolean) | Closes the store to future operations, releasing associated memory. |
FileExists(String) | Returns true iff the named file exists in this directory. |
FileLength(String) | Returns the length in bytes of a file in the directory. |
GetLockID() | |
GetSizeInBytes() | Return total size in bytes of all files in this directory. This is currently quantized to Lucene.Net.Store.RAMOutputStream.BUFFER_SIZE. |
ListAll() | |
NewRAMFile() | Returns a new RAMFile for storing data. this method can be overridden to return different RAMFile impls, that e.g. override NewBuffer(Int32). |
OpenInput(String, IOContext) | Returns a stream reading an existing file. |
Sync(ICollection<String>) |