Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Properties | List of all members
Lucene.Net.Store.Directory Class Referenceabstract

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. More...

Inherits IDisposable.

Inherited by Lucene.Net.Store.FileSwitchDirectory, Lucene.Net.Store.FSDirectory, and Lucene.Net.Store.RAMDirectory.

Public Member Functions

abstract System.String[] ListAll ()
 Returns an array of strings, one for each file in the directory.
 
abstract bool FileExists (System.String name)
 Returns true iff a file with the given name exists.
 
abstract long FileModified (System.String name)
 Returns the time the named file was last modified.
 
abstract void TouchFile (System.String name)
 Set the modified time of an existing file to now.
 
abstract void DeleteFile (System.String name)
 Removes an existing file in the directory.
 
abstract long FileLength (System.String name)
 Returns the length of a file in the 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 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.
 
abstract IndexInput OpenInput (System.String name)
 Returns a stream reading an existing 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).
 
virtual 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 string ToString ()
 
void EnsureOpen ()
 <throws> AlreadyClosedException if this Directory is closed </throws>
 

Static Public Member Functions

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.
 

Protected Member Functions

abstract void Dispose (bool disposing)
 

Properties

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

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 LockFactory , and can be changed for each Directory instance using SetLockFactory.

Definition at line 42 of file Directory.cs.

Member Function Documentation

virtual void Lucene.Net.Store.Directory.ClearLock ( System.String  name)
virtual

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.

Parameters
namename of the lock to be cleared.

Definition at line 114 of file Directory.cs.

void Lucene.Net.Store.Directory.Close ( )

Definition at line 123 of file Directory.cs.

static void Lucene.Net.Store.Directory.Copy ( Directory  src,
Directory  dest,
bool  closeDirSrc 
)
static

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.

NOTE: the source directory cannot change while this method is running. Otherwise the results are undefined and you could easily hit a FileNotFoundException.

NOTE: this method only copies files that look like index files (ie, have extensions matching the known extensions of index files).

Parameters
srcsource directory
destdestination directory
closeDirSrcif true, call Close() method on source directory

<throws> IOException </throws>

Definition at line 201 of file Directory.cs.

abstract IndexOutput Lucene.Net.Store.Directory.CreateOutput ( System.String  name)
pure virtual

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

Implemented in Lucene.Net.Store.MMapDirectory, Lucene.Net.Store.RAMDirectory, Lucene.Net.Store.FileSwitchDirectory, and Lucene.Net.Store.SimpleFSDirectory.

abstract void Lucene.Net.Store.Directory.DeleteFile ( System.String  name)
pure virtual

Removes an existing file in the directory.

Implemented in Lucene.Net.Store.FSDirectory, Lucene.Net.Store.RAMDirectory, and Lucene.Net.Store.FileSwitchDirectory.

void Lucene.Net.Store.Directory.Dispose ( )

Closes the store.

Definition at line 129 of file Directory.cs.

abstract void Lucene.Net.Store.Directory.Dispose ( bool  disposing)
protectedpure virtual
void Lucene.Net.Store.Directory.EnsureOpen ( )

<throws> AlreadyClosedException if this Directory is closed </throws>

Definition at line 253 of file Directory.cs.

abstract bool Lucene.Net.Store.Directory.FileExists ( System.String  name)
pure virtual

Returns true iff a file with the given name exists.

Implemented in Lucene.Net.Store.FSDirectory, Lucene.Net.Store.FileSwitchDirectory, and Lucene.Net.Store.RAMDirectory.

abstract long Lucene.Net.Store.Directory.FileLength ( System.String  name)
pure virtual

Returns the length of a file in the directory.

Implemented in Lucene.Net.Store.FSDirectory, Lucene.Net.Store.RAMDirectory, and Lucene.Net.Store.FileSwitchDirectory.

abstract long Lucene.Net.Store.Directory.FileModified ( System.String  name)
pure virtual

Returns the time the named file was last modified.

Implemented in Lucene.Net.Store.FSDirectory, Lucene.Net.Store.FileSwitchDirectory, and Lucene.Net.Store.RAMDirectory.

virtual string Lucene.Net.Store.Directory.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 in Lucene.Net.Store.FSDirectory.

Definition at line 170 of file Directory.cs.

abstract System.String [] Lucene.Net.Store.Directory.ListAll ( )
pure virtual

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

Exceptions
System.IO.IOException

Implemented in Lucene.Net.Store.FSDirectory, Lucene.Net.Store.FileSwitchDirectory, and Lucene.Net.Store.RAMDirectory.

virtual Lock Lucene.Net.Store.Directory.MakeLock ( System.String  name)
virtual

Construct a Lock.

Parameters
namethe name of the lock file

Definition at line 104 of file Directory.cs.

abstract IndexInput Lucene.Net.Store.Directory.OpenInput ( System.String  name)
pure virtual

Returns a stream reading an existing file.

Implemented in Lucene.Net.Store.FSDirectory, Lucene.Net.Store.RAMDirectory, and Lucene.Net.Store.FileSwitchDirectory.

virtual IndexInput Lucene.Net.Store.Directory.OpenInput ( System.String  name,
int  bufferSize 
)
virtual

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

Reimplemented in Lucene.Net.Store.MMapDirectory, and Lucene.Net.Store.SimpleFSDirectory.

Definition at line 96 of file Directory.cs.

virtual void Lucene.Net.Store.Directory.SetLockFactory ( LockFactory  lockFactory)
virtual

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).

Parameters
lockFactoryinstance of LockFactory.

Definition at line 145 of file Directory.cs.

virtual void Lucene.Net.Store.Directory.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 in Lucene.Net.Store.FSDirectory, and Lucene.Net.Store.FileSwitchDirectory.

Definition at line 82 of file Directory.cs.

override string Lucene.Net.Store.Directory.ToString ( )

Definition at line 175 of file Directory.cs.

abstract void Lucene.Net.Store.Directory.TouchFile ( System.String  name)
pure virtual

Set the modified time of an existing file to now.

Implemented in Lucene.Net.Store.FSDirectory, Lucene.Net.Store.FileSwitchDirectory, and Lucene.Net.Store.RAMDirectory.

Property Documentation

bool Lucene.Net.Store.Directory.isOpen_ForNUnit
get

Definition at line 260 of file Directory.cs.

virtual LockFactory Lucene.Net.Store.Directory.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.

Definition at line 158 of file Directory.cs.


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