Namespace Lucene.Net.Store
Classes
AlreadyClosedException
This exception is thrown when there is an attempt to access something that has already been closed.
BufferedIndexInput
Base implementation class for buffered Index
BufferedIndexOutput
Base implementation class for buffered Index
ChecksumIndexInput
Writes bytes through to a primary IndexOutput, computing checksum as it goes. Note that you cannot use seek().
ChecksumIndexOutput
Writes bytes through to a primary IndexOutput, computing checksum. Note that you cannot use seek().
Directory
A Directory is a flat list of files. Files may be written once, when they are created. Once a file is created it may only be opened for read, or deleted. Random access is permitted both when reading and writing.
Java's i/o APIs not used directly, but rather all i/o is through this API. This permits things such as:
Directory locking is implemented by an instance of Lock
FileSwitchDirectory
Expert: A Directory instance that switches files between two other Directory instances.
Files with the specified extensions are placed in the primary directory; others are placed in the secondary directory. The provided Set must not change once passed to this class, and must allow multiple threads to call contains at once.
NOTE: this API is new and experimental and is subject to suddenly change in the next release.
FSDirectory
Base class for Directory implementations that store index files in the file system. There are currently three core subclasses:
Unfortunately, because of system peculiarities, there is
no single overall best implementation. Therefore, we've
added the Open(IO.
The locking implementation is by default Native
FSLockFactory
Base class for file system based locking implementation.
IndexInput
Abstract base class for input from a file in a Directory. A random-access input stream. Used for all Lucene index input operations.
IndexOutput
Abstract base class for output to a file in a Directory. A random-access output stream. Used for all Lucene index output operations.
Lock
An interprocess mutex lock.
Typical use might look like:
new Lock.With(directory.makeLock("my.lock")) {
public Object doBody() {
... code to execute while locked ...
}
}.run();
Lock.With
Utility class for executing code with exclusive access.
LockFactory
Base class for Locking implementation. Directory uses instances of this class to implement locking.
Note that there are some useful tools to verify that
your LockFactory is working correctly: Verifying
LockObtainFailedException
This exception is thrown when the write.lock
could not be acquired. This
happens when a writer tries to open an index
that another writer already has open.
LockReleaseFailedException
This exception is thrown when the write.lock
could not be released.
LockStressTest
Simple standalone tool that forever acquires & releases a lock using a specific LockFactory. Run without any args to see usage.
LockVerifyServer
Simple standalone server that must be running when you
use Verifying
MMapDirectory
File-based Directory implementation that uses
mmap for reading, and Simple
NOTE: memory mapping uses up a portion of the
virtual memory address space in your process equal to the
size of the file being mapped. Before using this class,
be sure your have plenty of virtual address space, e.g. by
using a 64 bit JRE, or a 32 bit JRE with indexes that are
guaranteed to fit within the address space.
On 32 bit platforms also consult Max
Due to this bug in Sun's JRE, MMapDirectory's Close() is unable to close the underlying OS file handle. Only when GC finally collects the underlying objects, which could be quite some time later, will the file handle be closed.
This will consume additional transient disk usage: on Windows, attempts to delete or overwrite the files will result in an exception; on other platforms, which typically have a "delete on last close" semantics, while such operations will succeed, the bytes are still consuming space on disk. For many applications this limitation is not a problem (e.g. if you have plenty of disk space, and you don't rely on overwriting files on Windows) but it's still an important limitation to be aware of.
This class supplies the workaround mentioned in the bug report
(disabled by default, see Usetrue
, if the workaround
can be enabled (with no guarantees).
MMapDirectory.MultiMMapIndexInput
NativeFSLockFactory
Implements Lock
The primary benefit of Native
Note that, unlike Simple
If you suspect that this or any other LockFactory is
not working properly in your environment, you can easily
test it by using Verifying
NIOFSDirectory
Not implemented. Waiting for volunteers.
NIOFSDirectory.NIOFSIndexInput
Not implemented. Waiting for volunteers.
NoLockFactory
Use this Lock
NoSuchDirectoryException
This exception is thrown when you try to list a non-existent directory.
RAMDirectory
A memory-resident Directory implementation. Locking
implementation is by default the Single
RAMFile
RAMInputStream
A memory-resident Index
RAMOutputStream
A memory-resident Index
For lucene internal use.
SimpleFSDirectory
A straightforward implementation of FSDirectory
using java.io.RandomAccessFile. However, this class has
poor concurrent performance (multiple threads will
bottleneck) as it synchronizes when multiple threads
read from the same file. It's usually better to use
NIOFSDirectory or MMap
SimpleFSDirectory.SimpleFSIndexInput
SimpleFSDirectory.SimpleFSIndexInput.Descriptor
SimpleFSDirectory.SimpleFSIndexOutput
SimpleFSLockFactory
Implements Lock
NOTE: the javadocs
for File.createNewFile
contain a vague
yet spooky warning about not using the API for file
locking. This warning was added due to this
bug, and in fact the only known problem with using
this API for locking is that the Lucene write lock may
not be released when the JVM exits abnormally.
When this happens, a Lock
If you suspect that this or any other LockFactory is
not working properly in your environment, you can easily
test it by using Verifying
SingleInstanceLockFactory
Implements Lock
VerifyingLockFactory
A Lock