Class 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 ISet{string} must not change once passed to this class, and must allow multiple threads to call contains at once.Note
This API is experimental and might change in incompatible ways in the next release.
Implements
Inherited Members
Namespace: Lucene.Net.Store
Assembly: Lucene.Net.dll
Syntax
public class FileSwitchDirectory : BaseDirectory, IDisposable
Constructors
FileSwitchDirectory(ISet<string>, Directory, Directory, bool)
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 ISet{string} must not change once passed to this class, and must allow multiple threads to call contains at once.Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public FileSwitchDirectory(ISet<string> primaryExtensions, Directory primaryDir, Directory secondaryDir, bool doClose)
Parameters
| Type | Name | Description |
|---|---|---|
| ISet<string> | primaryExtensions | |
| Directory | primaryDir | |
| Directory | secondaryDir | |
| bool | doClose |
Properties
PrimaryDir
Return the primary directory
Declaration
public virtual Directory PrimaryDir { get; }
Property Value
| Type | Description |
|---|---|
| Directory |
SecondaryDir
Return the secondary directory
Declaration
public virtual Directory SecondaryDir { get; }
Property Value
| Type | Description |
|---|---|
| Directory |
Methods
CreateOutput(string, IOContext)
Creates a new, empty file in the directory with the given name. Returns a stream writing this file.
Declaration
public override IndexOutput CreateOutput(string name, IOContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | |
| IOContext | context |
Returns
| Type | Description |
|---|---|
| IndexOutput |
Overrides
CreateSlicer(string, IOContext)
Creates an Directory.IndexInputSlicer for the given file name. Directory.IndexInputSlicer allows other Directory implementations to efficiently open one or more sliced IndexInput instances from a single file handle. The underlying file handle is kept open until the Directory.IndexInputSlicer is closed.
Throws FileNotFoundException if the file does not exist.Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public override Directory.IndexInputSlicer CreateSlicer(string name, IOContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | |
| IOContext | context |
Returns
| Type | Description |
|---|---|
| Directory.IndexInputSlicer |
Overrides
Exceptions
| Type | Condition |
|---|---|
| IOException | if an IOException occurs |
DeleteFile(string)
Removes an existing file in the directory.
Declaration
public override void DeleteFile(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
Overrides
Dispose(bool)
Disposes the store.
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing |
Overrides
FileExists(string)
Returns true iff a file with the given name exists.
Declaration
[Obsolete("this method will be removed in 5.0")]
public override bool FileExists(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
FileLength(string)
Returns the length of a file in the directory. this method follows the following contract:
Declaration
public override long FileLength(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | the name of the file for which to return the length. |
Returns
| Type | Description |
|---|---|
| long |
Overrides
Exceptions
| Type | Condition |
|---|---|
| IOException | if there was an IO error while retrieving the file's length. |
GetExtension(string)
Utility method to return a file's extension.
Declaration
public static string GetExtension(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
Returns
| Type | Description |
|---|---|
| string |
ListAll()
Returns an array of strings, one for each file in the directory.
Declaration
public override string[] ListAll()
Returns
| Type | Description |
|---|---|
| string[] |
Overrides
Exceptions
| Type | Condition |
|---|---|
| DirectoryNotFoundException | if the directory is not prepared for any write operations (such as CreateOutput(string, IOContext)). |
| IOException | in case of other IO errors |
OpenInput(string, IOContext)
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 CompoundFileDirectory.
Throws FileNotFoundException if the file does not exist.Declaration
public override IndexInput OpenInput(string name, IOContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | |
| IOContext | context |
Returns
| Type | Description |
|---|---|
| IndexInput |
Overrides
Sync(ICollection<string>)
Ensure that any writes to these files 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.
NOTE: Clients may call this method for same files over
and over again, so some impls might optimize for that.
For other impls the operation can be a noop, for various
reasons.
Declaration
public override void Sync(ICollection<string> names)
Parameters
| Type | Name | Description |
|---|---|---|
| ICollection<string> | names |