Apache Lucene.Net 2.4.0 Class Library API

Lucene.Net.Store Namespace

Namespace hierarchy

Classes

Class Description
AlreadyClosedException This exception is thrown when there is an attempt to access something that has already been closed.
BufferedIndexInput Base implementation class for buffered {@link IndexInput}.
BufferedIndexOutput Base implementation class for buffered {@link IndexOutput}.
ChecksumIndexInput  
ChecksumIndexOutput  
Directory  
FSDirectory Straightforward implementation of {@link Directory} as a directory of files. Locking implementation is by default the {@link SimpleFSLockFactory}, but can be changed either by passing in a {@link LockFactory} instance to
getDirectory
, or specifying the LockFactory class by setting
Lucene.Net.Store.FSDirectoryLockFactoryClass
Java system property, or by calling {@link #setLockFactory} after creating the Directory.

Directories are cached, so that, for a given canonical path, the same FSDirectory instance will always be returned by

getDirectory
. This permits synchronization on directories.

FSDirectory.FSIndexInput  
FSDirectory.FSIndexInput.Descriptor  
FSDirectory.FSIndexOutput  
IndexInput Abstract base class for input from a file in a {@link 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  
Lock.With Utility class for executing code with exclusive access.
LockFactory

Base class for Locking implementation. {@link Directory} uses instances of this class to implement locking.

Note that there are some useful tools to verify that your LockFactory is working correctly: {@link VerifyingLockFactory}, {@link LockStressTest}, {@link LockVerifyServer}.

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  
LockVerifyServer Simple standalone server that must be running when you use {@link VerifyingLockFactory}. This server simply verifies at most one process holds the lock at a time. Run without any args to see usage.
MMapDirectory  
NativeFSLockFactory

Implements {@link LockFactory} using native OS file locks. Note that because this LockFactory relies on java.nio.* APIs for locking, any problems with those APIs will cause locking to fail. Specifically, on certain NFS environments the java.nio.* locks will fail (the lock can incorrectly be double acquired) whereas {@link SimpleFSLockFactory} worked perfectly in those same environments. For NFS based access to an index, it's recommended that you try {@link SimpleFSLockFactory} first and work around the one limitation that a lock file could be left when the JVM exits abnormally.

The primary benefit of {@link NativeFSLockFactory} is that lock files will be properly removed (by the OS) if the JVM has an abnormal exit.

Note that, unlike {@link SimpleFSLockFactory}, the existence of leftover lock files in the filesystem on exiting the JVM is fine because the OS will free the locks held against these files even though the files still remain.

If you suspect that this or any other LockFactory is not working properly in your environment, you can easily test it by using {@link VerifyingLockFactory}, {@link LockVerifyServer} and {@link LockStressTest}.

NoLockFactory Use this {@link LockFactory} to disable locking entirely. This LockFactory is used when you call {@link FSDirectory#setDisableLocks}. Only one instance of this lock is created. You should call {@link #GetNoLockFactory()} to get the instance.
RAMDirectory A memory-resident {@link Directory} implementation. Locking implementation is by default the {@link SingleInstanceLockFactory} but can be changed with {@link #setLockFactory}.
RAMFile  
RAMInputStream A memory-resident {@link IndexInput} implementation.
RAMOutputStream A memory-resident {@link IndexOutput} implementation.
SimpleFSLockFactory

Implements {@link LockFactory} using {@link File#createNewFile()}. This is the default LockFactory for {@link FSDirectory}.

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 {@link LockObtainFailedException} is hit when trying to create a writer, in which case you need to explicitly clear the lock file first. You can either manually remove the file, or use the {@link Lucene.Net.Index.IndexReader#Unlock(Directory)} API. But, first be certain that no writer is in fact writing to the index otherwise you can easily corrupt your index.

If you suspect that this or any other LockFactory is not working properly in your environment, you can easily test it by using {@link VerifyingLockFactory}, {@link LockVerifyServer} and {@link LockStressTest}.

SingleInstanceLockFactory Implements {@link LockFactory} for a single in-process instance, meaning all locking will take place through this one instance. Only use this {@link LockFactory} when you are certain all IndexReaders and IndexWriters for a given index are running against a single shared in-process Directory instance. This is currently the default locking for RAMDirectory.
VerifyingLockFactory