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
RAMDirectory
Assembly: Lucene.Net.dll
Syntax
public class RAMDirectory : BaseDirectory
Constructors
|
Improve this Doc
View Source
RAMDirectory()
Declaration
|
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
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
Overrides
|
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
|
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
|
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
|
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
|
Improve this Doc
View Source
GetLockID()
Declaration
public override string GetLockID()
Returns
Type |
Description |
System.String |
|
Overrides
|
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
|
Improve this Doc
View Source
NewRAMFile()
Declaration
protected virtual RAMFile NewRAMFile()
Returns
|
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
Overrides
|
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