Lucene.Net  3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Properties | List of all members
Lucene.Net.Store.FSDirectory Class Reference

Base class for Directory implementations that store index files in the file system. There are currently three core subclasses: More...

Inherits Lucene.Net.Store.Directory.

Inherited by Lucene.Net.Store.MMapDirectory, Lucene.Net.Store.NIOFSDirectory, and Lucene.Net.Store.SimpleFSDirectory.

Public Member Functions

override System.String[] ListAll ()
 Lists all files (not subdirectories) in the directory.
 
override bool FileExists (System.String name)
 Returns true iff a file with the given name exists.
 
override long FileModified (System.String name)
 Returns the time the named file was last modified.
 
override void TouchFile (System.String name)
 Set the modified time of an existing file to now.
 
override long FileLength (System.String name)
 Returns the length in bytes of a file in the directory.
 
override void DeleteFile (System.String name)
 Removes an existing file in the directory.
 
override void Sync (System.String name)
 Ensure that any writes to this file are moved to stable storage. Lucene uses this to properly commit changes to the index, to prevent a machine/OS crash from corrupting the index.
 
override IndexInput OpenInput (System.String name)
 Returns a stream reading an existing file.
 
override string GetLockId ()
 Return a string identifier that uniquely differentiates this Directory instance from other Directory instances. This ID should be the same if two Directory instances (even in different JVMs and/or on different machines) are considered "the same index". This is how locking "scopes" to the right index.
 
override System.String ToString ()
 For debug output.
 
- Public Member Functions inherited from Lucene.Net.Store.Directory
abstract IndexOutput CreateOutput (System.String name)
 Creates a new, empty file in the directory with the given name. Returns a stream writing this file.
 
virtual IndexInput OpenInput (System.String name, int bufferSize)
 Returns a stream reading an existing file, with the specified read buffer size. The particular Directory implementation may ignore the buffer size. Currently the only Directory implementations that respect this parameter are FSDirectory and Lucene.Net.Index.CompoundFileReader
 
virtual Lock MakeLock (System.String name)
 Construct a Lock.
 
virtual void ClearLock (System.String name)
 Attempt to clear (forcefully unlock and remove) the specified lock. Only call this at a time when you are certain this lock is no longer in use.
 
void Close ()
 
void Dispose ()
 Closes the store.
 
virtual void SetLockFactory (LockFactory lockFactory)
 Set the LockFactory that this Directory instance should use for its locking implementation. Each * instance of LockFactory should only be used for one directory (ie, do not share a single instance across multiple Directories).
 
override string ToString ()
 
void EnsureOpen ()
 <throws> AlreadyClosedException if this Directory is closed </throws>
 

Static Public Member Functions

static FSDirectory Open (string path)
 Creates an FSDirectory instance, trying to pick the best implementation given the current environment. The directory returned uses the NativeFSLockFactory.
 
static FSDirectory Open (System.IO.DirectoryInfo path)
 Creates an FSDirectory instance, trying to pick the best implementation given the current environment. The directory returned uses the NativeFSLockFactory.
 
static FSDirectory Open (System.IO.DirectoryInfo path, LockFactory lockFactory)
 Just like Open(System.IO.DirectoryInfo), but allows you to also specify a custom LockFactory.
 
static System.String[] ListAll (System.IO.DirectoryInfo dir)
 Lists all files (not subdirectories) in the directory. This method never returns null (throws System.IO.IOException instead).
 
static long FileModified (System.IO.FileInfo directory, System.String name)
 Returns the time the named file was last modified.
 
- Static Public Member Functions inherited from Lucene.Net.Store.Directory
static void Copy (Directory src, Directory dest, bool closeDirSrc)
 Copy contents of a directory src to a directory dest. If a file in src already exists in dest then the one in dest will be blindly overwritten.
 

Static Public Attributes

static readonly int DEFAULT_READ_CHUNK_SIZE = Constants.JRE_IS_64BIT ? int.MaxValue: 100 * 1024 * 1024
 Default read chunk size. This is a conditional default: on 32bit JVMs, it defaults to 100 MB. On 64bit JVMs, it's Integer.MAX_VALUE.
 

Protected Member Functions

override void Dispose (bool disposing)
 

Properties

virtual DirectoryInfo Directory [get]
 
int ReadChunkSize [get, set]
 The maximum number of bytes to read at once from the underlying file during IndexInput.ReadBytes(byte[],int,int).
 
- Properties inherited from Lucene.Net.Store.Directory
virtual LockFactory LockFactory [get]
 Get the LockFactory that this Directory instance is using for its locking implementation. Note that this may be null for Directory implementations that provide their own locking implementation.
 
bool isOpen_ForNUnit [get]
 

Detailed Description

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(System.IO.DirectoryInfo) method, to allow Lucene to choose the best FSDirectory implementation given your environment, and the known limitations of each implementation. For users who have no reason to prefer a specific implementation, it's best to simply use FSDirectory.Open(System.IO.DirectoryInfo) . For all others, you should instantiate the desired implementation directly.

The locking implementation is by default NativeFSLockFactory , but can be changed by passing in a custom LockFactory instance.

Definition at line 104 of file FSDirectory.cs.

Member Function Documentation

override void Lucene.Net.Store.FSDirectory.DeleteFile ( System.String  name)
virtual

Removes an existing file in the directory.

Implements Lucene.Net.Store.Directory.

Definition at line 374 of file FSDirectory.cs.

override void Lucene.Net.Store.FSDirectory.Dispose ( bool  disposing)
protectedvirtual

Implements Lucene.Net.Store.Directory.

Definition at line 470 of file FSDirectory.cs.

override bool Lucene.Net.Store.FSDirectory.FileExists ( System.String  name)
virtual

Returns true iff a file with the given name exists.

Implements Lucene.Net.Store.Directory.

Definition at line 335 of file FSDirectory.cs.

override long Lucene.Net.Store.FSDirectory.FileLength ( System.String  name)
virtual

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

Implements Lucene.Net.Store.Directory.

Definition at line 366 of file FSDirectory.cs.

override long Lucene.Net.Store.FSDirectory.FileModified ( System.String  name)
virtual

Returns the time the named file was last modified.

Implements Lucene.Net.Store.Directory.

Definition at line 343 of file FSDirectory.cs.

static long Lucene.Net.Store.FSDirectory.FileModified ( System.IO.FileInfo  directory,
System.String  name 
)
static

Returns the time the named file was last modified.

Definition at line 351 of file FSDirectory.cs.

override string Lucene.Net.Store.FSDirectory.GetLockId ( )
virtual

Return a string identifier that uniquely differentiates this Directory instance from other Directory instances. This ID should be the same if two Directory instances (even in different JVMs and/or on different machines) are considered "the same index". This is how locking "scopes" to the right index.

Reimplemented from Lucene.Net.Store.Directory.

Definition at line 440 of file FSDirectory.cs.

static System.String [] Lucene.Net.Store.FSDirectory.ListAll ( System.IO.DirectoryInfo  dir)
static

Lists all files (not subdirectories) in the directory. This method never returns null (throws System.IO.IOException instead).

<throws> NoSuchDirectoryException if the directory </throws>

does not exist, or does exist but is not a directory.

<throws> IOException if list() returns null </throws>

Definition at line 297 of file FSDirectory.cs.

override System.String [] Lucene.Net.Store.FSDirectory.ListAll ( )
virtual

Lists all files (not subdirectories) in the directory.

See Also
ListAll(System.IO.DirectoryInfo)

Implements Lucene.Net.Store.Directory.

Definition at line 328 of file FSDirectory.cs.

static FSDirectory Lucene.Net.Store.FSDirectory.Open ( string  path)
static

Creates an FSDirectory instance, trying to pick the best implementation given the current environment. The directory returned uses the NativeFSLockFactory.

Currently this returns SimpleFSDirectory as NIOFSDirectory is currently not supported.

NOTE: this method may suddenly change which implementation is returned from release to release, in the event that higher performance defaults become possible; if the precise implementation is important to your application, please instantiate it directly, instead. On 64 bit systems, it may also good to return MMapDirectory, but this is disabled because of officially missing unmap support in Java. For optimal performance you should consider using this implementation on 64 bit JVMs.

See above

Definition at line 234 of file FSDirectory.cs.

static FSDirectory Lucene.Net.Store.FSDirectory.Open ( System.IO.DirectoryInfo  path)
static

Creates an FSDirectory instance, trying to pick the best implementation given the current environment. The directory returned uses the NativeFSLockFactory.

Currently this returns SimpleFSDirectory as NIOFSDirectory is currently not supported.

NOTE: this method may suddenly change which implementation is returned from release to release, in the event that higher performance defaults become possible; if the precise implementation is important to your application, please instantiate it directly, instead. On 64 bit systems, it may also good to return MMapDirectory, but this is disabled because of officially missing unmap support in Java. For optimal performance you should consider using this implementation on 64 bit JVMs.

See above

Definition at line 259 of file FSDirectory.cs.

static FSDirectory Lucene.Net.Store.FSDirectory.Open ( System.IO.DirectoryInfo  path,
LockFactory  lockFactory 
)
static

Just like Open(System.IO.DirectoryInfo), but allows you to also specify a custom LockFactory.

Definition at line 267 of file FSDirectory.cs.

override IndexInput Lucene.Net.Store.FSDirectory.OpenInput ( System.String  name)
virtual

Returns a stream reading an existing file.

Implements Lucene.Net.Store.Directory.

Definition at line 430 of file FSDirectory.cs.

override void Lucene.Net.Store.FSDirectory.Sync ( System.String  name)
virtual

Ensure that any writes to this file are moved to stable storage. Lucene uses this to properly commit changes to the index, to prevent a machine/OS crash from corrupting the index.

Reimplemented from Lucene.Net.Store.Directory.

Definition at line 388 of file FSDirectory.cs.

override System.String Lucene.Net.Store.FSDirectory.ToString ( )

For debug output.

Definition at line 491 of file FSDirectory.cs.

override void Lucene.Net.Store.FSDirectory.TouchFile ( System.String  name)
virtual

Set the modified time of an existing file to now.

Implements Lucene.Net.Store.Directory.

Definition at line 358 of file FSDirectory.cs.

Member Data Documentation

readonly int Lucene.Net.Store.FSDirectory.DEFAULT_READ_CHUNK_SIZE = Constants.JRE_IS_64BIT ? int.MaxValue: 100 * 1024 * 1024
static

Default read chunk size. This is a conditional default: on 32bit JVMs, it defaults to 100 MB. On 64bit JVMs, it's Integer.MAX_VALUE.

See Also
ReadChunkSize

Definition at line 502 of file FSDirectory.cs.

Property Documentation

virtual DirectoryInfo Lucene.Net.Store.FSDirectory.Directory
get

Definition at line 482 of file FSDirectory.cs.

int Lucene.Net.Store.FSDirectory.ReadChunkSize
getset

The maximum number of bytes to read at once from the underlying file during IndexInput.ReadBytes(byte[],int,int).

See Also
ReadChunkSize

Definition at line 513 of file FSDirectory.cs.


The documentation for this class was generated from the following file: