C# Class Lucene.Net.Store.RAMDirectory

A memory-resident Directory implementation. Locking implementation is by default the SingleInstanceLockFactory but can be changed with #setLockFactory.

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 {@code 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 Java heap space is not useful.

Inheritance: Lucene.Net.Store.BaseDirectory
Show file Open project: synhershko/lucene.net Class Usage Examples

Protected Properties

Property Type Description
fileMap RAMFile>.HashMap
internalSizeInBytes long

Public Methods

Method Description
CreateOutput ( System name ) : Lucene.Net.Store.IndexOutput

Creates a new, empty file in the directory with the given name. Returns a stream writing this file.

DeleteFile ( System name ) : void

Removes an existing file in the directory.

FileExists ( System name ) : bool

Returns true iff the named file exists in this directory.

FileLength ( System name ) : long

Returns the length in bytes of a file in the directory.

FileModified ( System name ) : long

Returns the time the named file was last modified.

ListAll ( ) : System.String[]
OpenInput ( System name ) : IndexInput

Returns a stream reading an existing file.

RAMDirectory ( ) : System

Constructs an empty Directory.

RAMDirectory ( Directory dir ) : System

Creates a new RAMDirectory instance from a different Directory implementation. This can be used to load a disk-based index into memory.

This should be used only with indices that can fit into memory.

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.

SizeInBytes ( ) : long

Return total size in bytes of all files in this directory. This is currently quantized to RAMOutputStream.BUFFER_SIZE.

TouchFile ( System name ) : void

Set the modified time of an existing file to now.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Closes the store to future operations, releasing associated memory.

Private Methods

Method Description
OnDeserialized ( System context ) : void
RAMDirectory ( Directory dir, bool closeDir ) : System

Method Details

CreateOutput() public method

Creates a new, empty file in the directory with the given name. Returns a stream writing this file.
public CreateOutput ( System name ) : Lucene.Net.Store.IndexOutput
name System
return Lucene.Net.Store.IndexOutput

DeleteFile() public method

Removes an existing file in the directory.
public DeleteFile ( System name ) : void
name System
return void

Dispose() protected method

Closes the store to future operations, releasing associated memory.
protected Dispose ( bool disposing ) : void
disposing bool
return void

FileExists() public method

Returns true iff the named file exists in this directory.
public FileExists ( System name ) : bool
name System
return bool

FileLength() public method

Returns the length in bytes of a file in the directory.
public FileLength ( System name ) : long
name System
return long

FileModified() public method

Returns the time the named file was last modified.
public FileModified ( System name ) : long
name System
return long

ListAll() public method

public ListAll ( ) : System.String[]
return System.String[]

OpenInput() public method

Returns a stream reading an existing file.
public OpenInput ( System name ) : IndexInput
name System
return IndexInput

RAMDirectory() public method

Constructs an empty Directory.
public RAMDirectory ( ) : System
return System

RAMDirectory() public method

Creates a new RAMDirectory instance from a different Directory implementation. This can be used to load a disk-based index into memory.

This should be used only with indices that can fit into memory.

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.

if an error occurs ///
public RAMDirectory ( Directory dir ) : System
dir Directory a Directory value ///
return System

SizeInBytes() public method

Return total size in bytes of all files in this directory. This is currently quantized to RAMOutputStream.BUFFER_SIZE.
public SizeInBytes ( ) : long
return long

TouchFile() public method

Set the modified time of an existing file to now.
public TouchFile ( System name ) : void
name System
return void

Property Details

fileMap protected property

protected HashMap fileMap
return RAMFile>.HashMap

internalSizeInBytes protected property

protected long internalSizeInBytes
return long