public class

RAMDirectory

extends Directory
implements Serializable
java.lang.Object
   ↳ org.apache.lucene.store.Directory
     ↳ org.apache.lucene.store.RAMDirectory

Class Overview

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

Summary

[Expand]
Inherited Fields
From class org.apache.lucene.store.Directory
Public Constructors
RAMDirectory()
Constructs an empty Directory.
RAMDirectory(Directory dir)
Creates a new RAMDirectory instance from a different Directory implementation.
Public Methods
void close()
Closes the store to future operations, releasing associated memory.
IndexOutput createOutput(String name)
Creates a new, empty file in the directory with the given name.
synchronized void deleteFile(String name)
Removes an existing file in the directory.
final boolean fileExists(String name)
Returns true iff the named file exists in this directory.
final long fileLength(String name)
Returns the length in bytes of a file in the directory.
final long fileModified(String name)
Returns the time the named file was last modified.
synchronized final String[] listAll()
Returns an array of strings, one for each file in the directory.
IndexInput openInput(String name)
Returns a stream reading an existing file.
synchronized final long sizeInBytes()
Return total size in bytes of all files in this directory.
void touchFile(String name)
Set the modified time of an existing file to now.
[Expand]
Inherited Methods
From class org.apache.lucene.store.Directory
From class java.lang.Object
From interface java.io.Closeable

Public Constructors

public RAMDirectory ()

Constructs an empty Directory.

public RAMDirectory (Directory dir)

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.

Parameters
dir a Directory value
Throws
IOException if an error occurs

Public Methods

public void close ()

Closes the store to future operations, releasing associated memory.

public IndexOutput createOutput (String name)

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

Throws
IOException

public synchronized void deleteFile (String name)

Removes an existing file in the directory.

Throws
IOException if the file does not exist

public final boolean fileExists (String name)

Returns true iff the named file exists in this directory.

public final long fileLength (String name)

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

Throws
IOException if the file does not exist

public final long fileModified (String name)

Returns the time the named file was last modified.

Throws
IOException if the file does not exist

public final synchronized String[] listAll ()

Returns an array of strings, one for each file in the directory.

public IndexInput openInput (String name)

Returns a stream reading an existing file.

Throws
IOException

public final synchronized long sizeInBytes ()

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

public void touchFile (String name)

Set the modified time of an existing file to now.

Throws
IOException if the file does not exist