C# 클래스 Lucene.Net.Store.FSDirectory

Base class for Directory implementations that store index files in the file system. There are currently three core subclasses: SimpleFSDirectory is a straightforward implementation using java.io.RandomAccessFile. However, it has poor concurrent performance (multiple threads will bottleneck) as it synchronizes when multiple threads read from the same file. NIOFSDirectory uses java.nio's FileChannel's positional io when reading to avoid synchronization when reading from the same file. Unfortunately, due to a Windows-only Sun JRE bug this is a poor choice for Windows, but on all other platforms this is the preferred choice. Applications using System.Threading.Thread.Interrupt() or Future#cancel(boolean) (on Java 1.5) should use SimpleFSDirectory instead. See NIOFSDirectory java doc for details. MMapDirectory uses memory-mapped IO when reading. This is a good choice if you have plenty of virtual memory relative to your index size, eg if you are running on a 64 bit JRE, or you are running on a 32 bit JRE but your index sizes are small enough to fit into the virtual memory space. Java has currently the limitation of not being able to unmap files from user code. The files are unmapped, when GC releases the byte buffers. Due to this bug in Sun's JRE, MMapDirectory's IndexInput.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 a (possibly dangerous) workaround mentioned in the bug report, which may fail on non-Sun JVMs. Applications using System.Threading.Thread.Interrupt() or Future#cancel(boolean) (on Java 1.5) should use SimpleFSDirectory instead. See MMapDirectory java doc for details. 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.

상속: Directory
파일 보기 프로젝트 열기: apache/lucenenet 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
StaleFiles ISet
directory System.IO.DirectoryInfo

Private Properties

프로퍼티 타입 설명

공개 메소드들

메소드 설명
CreateOutput ( string name, IOContext context ) : Lucene.Net.Store.IndexOutput

Creates an IndexOutput for the file with the given name.

DeleteFile ( string name ) : void

Removes an existing file in the directory.

Dispose ( ) : void

Closes the store to future operations.

FileExists ( string name ) : bool

Returns true iff a file with the given name exists.

FileLength ( string name ) : long

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

ListAll ( ) : string[]

Lists all files (not subdirectories) in the directory.

ListAll ( DirectoryInfo dir ) : string[]

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

Open ( DirectoryInfo path ) : FSDirectory

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

Currently this returns MMapDirectory for most Solaris and Windows 64-bit JREs, NIOFSDirectory for other non-Windows JREs, and SimpleFSDirectory for other JREs on Windows. It is highly recommended that you consult the implementation's documentation for your platform before using this method.

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. For optimal performance you should consider using MMapDirectory on 64 bit JVMs.

See above

Open ( DirectoryInfo path, Lucene.Net.Store.LockFactory lockFactory ) : FSDirectory

Just like #open(File), but allows you to also specify a custom LockFactory.

Sync ( ICollection names ) : void
ToString ( ) : string

For debug output.

보호된 메소드들

메소드 설명
EnsureCanWrite ( string name ) : void
FSDirectory ( DirectoryInfo dir ) : System
FSDirectory ( DirectoryInfo path, Lucene.Net.Store.LockFactory lockFactory ) : System

Create a new FSDirectory for the named location (ctor for subclasses).

Fsync ( String name, bool isDir = false ) : void

OnIndexOutputClosed ( Lucene.Net.Store.FSIndexOutput io ) : void

메소드 상세

CreateOutput() 공개 메소드

Creates an IndexOutput for the file with the given name.
public CreateOutput ( string name, IOContext context ) : Lucene.Net.Store.IndexOutput
name string
context IOContext
리턴 Lucene.Net.Store.IndexOutput

DeleteFile() 공개 메소드

Removes an existing file in the directory.
public DeleteFile ( string name ) : void
name string
리턴 void

Dispose() 공개 메소드

Closes the store to future operations.
public Dispose ( ) : void
리턴 void

EnsureCanWrite() 보호된 메소드

protected EnsureCanWrite ( string name ) : void
name string
리턴 void

FSDirectory() 보호된 메소드

protected FSDirectory ( DirectoryInfo dir ) : System
dir System.IO.DirectoryInfo
리턴 System

FSDirectory() 보호된 메소드

Create a new FSDirectory for the named location (ctor for subclasses).
if there is a low-level I/O error
protected FSDirectory ( DirectoryInfo path, Lucene.Net.Store.LockFactory lockFactory ) : System
path System.IO.DirectoryInfo the path of the directory
lockFactory Lucene.Net.Store.LockFactory the lock factory to use, or null for the default /// ();
리턴 System

FileExists() 공개 메소드

Returns true iff a file with the given name exists.
public FileExists ( string name ) : bool
name string
리턴 bool

FileLength() 공개 메소드

Returns the length in bytes of a file in the directory.
public FileLength ( string name ) : long
name string
리턴 long

Fsync() 보호된 메소드

protected Fsync ( String name, bool isDir = false ) : void
name String
isDir bool
리턴 void

ListAll() 공개 메소드

Lists all files (not subdirectories) in the directory.
public ListAll ( ) : string[]
리턴 string[]

ListAll() 공개 정적인 메소드

Lists all files (not subdirectories) in the directory. this method never returns null (throws System.IO.IOException instead).
if the directory /// does not exist, or does exist but is not a /// directory. if list() returns null
public static ListAll ( DirectoryInfo dir ) : string[]
dir System.IO.DirectoryInfo
리턴 string[]

OnIndexOutputClosed() 보호된 메소드

protected OnIndexOutputClosed ( Lucene.Net.Store.FSIndexOutput io ) : void
io Lucene.Net.Store.FSIndexOutput
리턴 void

Open() 공개 정적인 메소드

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

Currently this returns MMapDirectory for most Solaris and Windows 64-bit JREs, NIOFSDirectory for other non-Windows JREs, and SimpleFSDirectory for other JREs on Windows. It is highly recommended that you consult the implementation's documentation for your platform before using this method.

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. For optimal performance you should consider using MMapDirectory on 64 bit JVMs.

See above

public static Open ( DirectoryInfo path ) : FSDirectory
path System.IO.DirectoryInfo
리턴 FSDirectory

Open() 공개 정적인 메소드

Just like #open(File), but allows you to also specify a custom LockFactory.
public static Open ( DirectoryInfo path, Lucene.Net.Store.LockFactory lockFactory ) : FSDirectory
path System.IO.DirectoryInfo
lockFactory Lucene.Net.Store.LockFactory
리턴 FSDirectory

Sync() 공개 메소드

public Sync ( ICollection names ) : void
names ICollection
리턴 void

ToString() 공개 메소드

For debug output.
public ToString ( ) : string
리턴 string

프로퍼티 상세

StaleFiles 보호되어 있는 프로퍼티

protected ISet StaleFiles
리턴 ISet

directory 보호되어 있는 프로퍼티

protected DirectoryInfo,System.IO directory
리턴 System.IO.DirectoryInfo